Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Ok, thank you all, I will try to take my time with better understanding my solution and how to improve it.
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:
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.
You should use
console.log
to print inputs, and probably some other variables too. This way you'll know exactly which test case failed.@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 ?
Your solution fails other test than you showed above.
Your solution has a bug, it is not a kata issue.
I passed all exampe tests and random tests besides this one(the one random test I append to test suite in example tests):
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 ?
I passed all exampe tests and random tests besides this one(the one random test I append to test suite in example tests):
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.
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.
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 ?