Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 556157?s=100

    thanks for your reply, Andrew
    I added an extra line in the rules for this

  • Profile pic

    This could just be me, but I was somewhat confused by the description. It could be more clear that the goal is the next size pandigital numbers greater than offset. Perhaps that was obvious to others and I was just being dense!

    Anyways, fun problem!

  • 556157?s=100

    You're absolutely right, (I messed up the numbers myself)
    Should be better now

    thanks

  • 7867810?s=100
    Returned price doesn't match expected value.
    

    It does not help to debug
    Please use assertEquals([message ,]expected, actual) instead of assertTrue...

  • 7867810?s=100

    Ah, that's a lot easier to understand, i misunderstood that you is a shop owner or some that buys from suppilers and sells to demands...
    From the desc there is

    using 14.84 would give following results
    supply sequence [ [750, 14.75], [650, 14.84], [850, 14.85] ]
    and a revenue of 14.84 * 250 = 3710
    

    Shouldn't it be a revenue of 14.84 * 0 = 0
    Because the second buyer does'nt go over 14.50?

  • 556157?s=100

    I extended the initial example in the kata with the same explanation to clarify.

    thanks

  • 556157?s=100

    Hi,

    Those details are described in the rules.
    The crucial part is following:
    The demand is filled in the same sequence as set in the challenge (from left to right), the supply is used up from lowest price to highest.
    The capacity of the supplier with the lowest price is used up for all demands, before the next is consumed.

    Let's say you set a price of 19.19.
    In the example this means first 2000 pieces are consumed from supplier with price 16.00.

    After fulfilling supplier 1, following demand is remaining:
    [ [100, 23.10], [888, 19.19], [3000, 11.8] ]

    This is all consumed from the second supplier who has a capacity of 5000.

    So if your price is 19.19 then no demand is left to fullfull.

    Also the way you calculate your revenue is wrong.
    It is the amount of your capacity sold for the price you set.
    For 16.99 your revenue is 500 * 16.99 because all can be sold in that case.
    For 19.19 your revenue is 0 * 19.19 because nobody want to buy from you.

    Does that help?

  • 7867810?s=100

    More detail is required on examples in the desc.
    Like this one

    Example 1 - supply > demand
    + demand = [ [1100, 25.13], [1000, 23.10], [888, 19.19], [3000, 11.8] ]
    + supply = [ [5000, 17], [2000, 16] ]
    + capacity = 500
    + => optimal price = 16.99
    

    So i guess

    revenue = (16.99 - 16) * min(1100,500) + (16.99 - 16) * min(1000,500) + (16.99 - 16) * min(888,500)
            = 0.99 * 500 + 0.99 * 500 + 0.99 * 500 = 1485
    

    Then why cant we set price at like 19.19, then we get

    revenue = (19.19 - 16) * min(1100,500) + (19.19 - 16) * min(1000,500) + (19.19 - 16) * min(888,500)
            = 4785
    
  • 556157?s=100

    you're right
    I will remove it

  • 556157?s=100

    ok thanks, this is fixed

  • 556157?s=100

    you're right, is fixed now thanks

  • 14909989?s=100
  • 7867810?s=100

    Sample Tests expect wrong results

    BigInteger.valueOf(3), BigInteger.valueOf(4)), new BigInteger[]{BigInteger.valueOf(2), BigInteger.valueOf(4), BigInteger.valueOf(32)}
    
    3/4 != 1/2 + 1/4 + 1/32
    
    BigInteger.valueOf(4), BigInteger.valueOf(6)), new BigInteger[]{BigInteger.valueOf(2), BigInteger.valueOf(6), BigInteger.valueOf(72)}
    
    4/6 != 1/2 + 1/6 + 1/72
    
    
  • 7867810?s=100

    Tests expect BigInteger[] but initial code is public static List<BigInteger>

  • 556157?s=100

    Hi,

    Ok thanks
    I'll add some addititional random tests.

  • Loading more items...