Doctor Who - The Gift puzzle discussion

Feel free to send your feedback or ask some help here!

Just a quick feedback on “the Gift”: I had the feeling that it was significantly easier than the other medium puzzles. It is often difficult to determine how “trivial” an algorithm is, because it is a matter of experience, training, or just luck to find the “right” way on the first attempt. Yet, for this one, the first thing that came to my mind (sort and print minimal budgets until the rest can be shared among large budgets) happened to be a 10 minute / 20 lines of C++ code / 100% solution. Does the order of puzzles is meaningful? If yes, this one might be moved among the first ones.


I concur. I found it really easy and had it working in like 5mn, although I used a completely different approach (from smallest to largest, always assign the remaining mean, or as much as possible).

I pass all tests (even the test Impossible) but when I submit my code the test Impossible does not pass. I don’t understand why.

1 Like

The exact same thing happened to me :frowning: maybe the test Impossible is not exactly the same when we submit our code…

1 Like

Continuing the discussion from [Doctor Who - The Gift puzzle discussion]

EDIT: nope, talk about the puzzle in the appropriate puzzle topic, don’t create an unnecessary long title either please

System tests are not the same tests as presented to avoid hard coding of solutions.
If your code not pass a test, your code is not optimized for all situations “like” the situation tested.
Try to optimize your code.

1 Like

I had the same problem with the TEADS problem.
In fact, my solution was buggy. I edited it, now it’s 100% validated.


here is my solution.can some1 tell me what is the problem here

Your solution is far more complicated than mine.

i got strange bug here: my code did not pass test #8 “Several solution fast” from ide window, but 100% tests are completed on submit somehow
checking my code…
yep - after some rewrites i passed all tests before submit, but i think there should be achievment for this :smile:
seriously, if you have different validation tests before submission and after it - you should expect reverse results sometimes

1 Like

Why my solution passes all test exept “big random”?

Edited: No full code even in png :smiley:

i suppose this is due to rounding / division errors, no need to use division in this task:
Edit : No full Code


Potential error with Test Case 3.

Input provided by automated test case is 1, 100, 60, with result 1, 49, 50. I think there is a typo with 60 and it should read as 100.


The input I am seeing is

I got all of the tests running except the last one ‘Big Random’. When writing debugging system prints, I’m learning that the program is cutting off a part of my ArrayList (implemented with Java). I would store all of the 85614 numbers in an ArrayList to work with. Printing out this ArrayList shows the number fine, but immediately printing this list again, without any other code in between will list only a handful of numbers, all in the [160;164] interval. So essentially, it cut off a huge part of the list from the beginning and only saved about 30 or so at the tail. I’m assuming I’m working with memory constraints here then?

I find it weird it would store the values in my ArrayList fine and show them correctly when I print them the first time, but upon printing them out again immediately, it would return a shortened version.

Changing them into an array worked fine. Weird.

Why by input :

the system expects :

I think the result should be :


So, yeah, I also built a way to do it very quickly, but I got a very strange bug with the last testcase “big random”. At some point, where the participants were spending 70, one of them spent 69 (based on my calculations). I couldn’t find a way to get an idea of what was going on, so I applied a patch so ugly my own momma would slap me silly:
if( uCurrentSpending < uLastCurrentSpend )
uCurrentSpending = uLastCurrentSpend;
Now it’s eating me alive…

1 Like

IIRC, I found the ceiling function useful. Or the floor. One or the other.