I believe that the test cases have been luckily tailored to allow this solution. 9 mangos that cost 5 each cost 30 in total. But if you apply the above with 8 mangos costing 5 each you should get the same result (you are not taking advantage of 1 free mango) but instead you get a float which makes no sense because the result should always be a multiple of 5.
I'm not sure what you mean with your question :) While this:
quantity-quantity/3
means you drop every third mango from the calculation (because it's free by definition), your snippet - ((quantity / 3 ) * 2) * 2 - is not mathematically equivalent to the former (hint: integer division is not exactly like float division).
why is it that this does pass the Kata but #((quantity / 3 ) * 2) * 2 * price will not do the trick if they return the same value when calculated in a scientific calculator? Just curious I am new here.
The kata requires you to sort the list even with repeats of the same face value. Your code is simply removing all the repeated elements using set(), also it removes all cases of a repeated value using a list comprehension and only replaces it with one value. The task requires you to just sort it, but your code is removing values of a repeated values.
however when I go to submit I get the following in the output
test_caffeineBuzz(CaffeineBuzz_Test)
expected: but was:
Any ideas on what to do?
EDIT: I added assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(13)); and assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(67));
both tests return true
@fran_Cesco: No, that's not the case, read about integer division.
I believe that the test cases have been luckily tailored to allow this solution. 9 mangos that cost 5 each cost 30 in total. But if you apply the above with 8 mangos costing 5 each you should get the same result (you are not taking advantage of 1 free mango) but instead you get a float which makes no sense because the result should always be a multiple of 5.
NO code specification, closing, read this
I'm not sure what you mean with your question :) While this:
means you drop every third mango from the calculation (because it's free by definition), your snippet -
((quantity / 3 ) * 2) * 2
- is not mathematically equivalent to the former (hint: integer division is not exactly like float division).why is it that this does pass the Kata but #((quantity / 3 ) * 2) * 2 * price will not do the trick if they return the same value when calculated in a scientific calculator? Just curious I am new here.
ok, thanks for the clarification
The code fails for
['A', '2', '3', '6', '7', '7', '7', '8', '9', 'J', 'J']
(input)Your code returns
['A', '2', '3', '6', '7', '8', '9', 'J']
(output)The kata requires you to sort the list even with repeats of the same face value. Your code is simply removing all the repeated elements using set(), also it removes all cases of a repeated value using a list comprehension and only replaces it with one value. The task requires you to just sort it, but your code is removing values of a repeated values.
This comment is hidden because it contains spoiler information about the solution
I have the following test cases that all pass in java
assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(1));
assertEquals("JavaScript",CaffeineBuzz.caffeineBuzz(6));
assertEquals("CoffeeScript",CaffeineBuzz.caffeineBuzz(12));
assertEquals("CoffeeScript",CaffeineBuzz.caffeineBuzz(-12));
however when I go to submit I get the following in the output
test_caffeineBuzz(CaffeineBuzz_Test)
expected: but was:
Any ideas on what to do?
EDIT: I added assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(13)); and assertEquals("mocha_missing",CaffeineBuzz.caffeineBuzz(67));
both tests return true