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.

2 Likes

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).

1 Like

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

Hi,
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.

NO DAMN FULL CODE

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

1 Like

O_o
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

3 Likes

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.

Thoughts?

The input I am seeing is
3
100
100
1
60.

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 :
3
100
100
1
60

the system expects :
1
49
50

I think the result should be :
39
1
60

?

2 Likes

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.