Ad
  • 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

    @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

    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

    I solved it with using replace with regexp. However I am still confused why there was error with toUpperCase function called. There is only string as input as I need to dig this deeper.

  • Custom User Avatar

    clean, clever and quite readable.

    Just wondering what Big O notation in terms of space and time your solution would be.
    I would guess that Big O notation in terms of time would be O(n*m), where n is size of input and m is size of markers.
    About Big O notation in terms of size complexity it would be just O(1), constant as no variables are explicitly declared in function ? Can someone please correct me ?