Ad
  • Default User Avatar

    the word "java" is not similar to "heaven".

  • Custom User Avatar

    kata solution != kata suggestion

    Please do not post solution in discourse, and if you intend to post any hints or tips after solving, do apply the Spoiler flag

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    done some time ago

  • Default User Avatar

    This was great!

  • Default User Avatar

    I know this comment was left a while ago but the reason is because using the program is taking to long when using the while loop and random module.

    The random module isn't great to use in this case it's not the most reliable. You're basically throwing randoms so may get the same results a few times. The while parameters is a little tricky as well.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Ok, thank you all, I will try to take my time with better understanding my solution and how to improve it.

  • Custom User Avatar

    Your reasoning is more or less okay, the problem is with the test you think to be failing. When I try to run your solution, I see that it fails following test case:

    recipe:  { cream: 200, flour: 300, sugar: 150, milk: 100, oil: 100 }
    available:  { sugar: 1700, flour: 20000, milk: 20000, oil: 30000, cream: 5000 }
    

    Your solution has a bug which fails for the input above, but it works for the input which you showed and I am not sure what exactly leads you to the conclusion that your solution fails your test, and not the one I found.

  • Custom User Avatar

    You should use console.log to print inputs, and probably some other variables too. This way you'll know exactly which test case failed.

  • Custom User Avatar

    @hobovsky Thank you for reply. Could you give me example what other test my solution is failing against ?
    When I comment out this one test case:

    // recipe = {flour: 500, sugar: 200, eggs: 1};
    // available = {flour: 1200, sugar: 1200, eggs: 5, milk: 200};
    // assert.equal(cakes(recipe, available), 11);

    then assertions pass.

    Also would you tell me if there is gap or wrong logic in the way I explained this to work ?

  • Custom User Avatar

    Your solution fails other test than you showed above.
    Your solution has a bug, it is not a kata issue.

  • Custom User Avatar

    I passed all exampe tests and random tests besides this one(the one random test I append to test suite in example tests):

    recipe = {flour: 500, sugar: 200, eggs: 1};
    available = {flour: 1200, sugar: 1200, eggs: 5, milk: 200};
    assert.equal(cakes(recipe, available), 11);
    

    Based on how logically it would work I would expect having the smaller ratio between same igredient from available divided same ingredient ie. flour in recipe having 500 and flour in available having 1200. I understand it as 1200 / 500 = 2.

    Can someone please help me better undestand if this kata random test is correctly done ?

  • Custom User Avatar

    I passed all exampe tests and random tests besides this one(the one random test I append to test suite in example tests):

    recipe = {flour: 500, sugar: 200, eggs: 1};
    available = {flour: 1200, sugar: 1200, eggs: 5, milk: 200};
    assert.equal(cakes(recipe, available), 11);
    

    Based on how logically it would work I would expect having the smaller ratio between same igredient from available divided same ingredient ie. flour in recipe having 500 and flour in available having 1200. I understand it as 1200 / 500 = 2.

  • Custom User Avatar

    Thank you, saved my day!

  • Loading more items...