Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @jddingemanse,validated by @Razovsky,@Timinator and @iggy12345.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @jddingemanse,validated by @Razovsky,@Timinator and @iggy12345.
If you have any issues, feel free to ping them.
I was not able to pass the 5th test. I submitted and surprisingly I got 100%. I think the final submission’s tests should at least cover the open evaluation tests.
Thank you for this mind opening puzzle.
I’m a bit confused about rounding in this problem. The example in the description only covers integer efficiencies but the problems contain floating point efficiencies, are we meant to be tracking fractional minutes or not?
I have same problem as IIIThinkAboutIt !
When I make rounding ServiceTime all tests are passing, but 5-th validator isn’t. When do with just float variables - all validators are passing, but 5-th test isn’t.
I see you mostly do your puzzles in Python. If you did this puzzle in Python, I’d love to take a look. I’ll need you to make sure your code is published. If it says it is already published, please unpublish and republish.
I never do any rounding and I pass all tests and all validators.
While replying to @Oliverri, I think the same issue bothers both @IIIThinkAboutIt and @cfehunter2: rounding.
Let me start with saying apologies and thanks: I simply did not think about rounding. After I get to the bottom of this, I will turn it into one or more proper edge cases. Apparently, at the moment it is a hidden edge case, popping up either in the validator or test case, and that should not be so.
But, as @Timinator already said, this puzzle should be done without rounding. I am a bit surprised by the ‘passing one with rounding, passing the other without rounding’. I am now checking the behavior of rounding vs not rounding at the point of combining helptime with efficiency → there I indeed found some edge case issues, differing on whether you round down to an integer, whether you round (up or down) to the nearest integer, whether you round up, or whether you do not round at all.
Rounding down to an integer
Checking in detail my iterations, rounding is a problem at some point for test case 5 in a situation like this: without rounding some counter has worked for 13,333 minutes and then gets another task for 6,6667 minutes. This brings that counter exactly at the 20 minutes of worktime, earning that counter a break. If instead you would round down to an integer, the counter would only have worked 13 + 6 = 19 minutes, which is not enough to earn a break yet.Since HAB likes to be fair to their employees regarding breaks (after all, Breaks is in their company name), and in that case the counter can in fact claim it worked 20 minutes instead of 19, rounding should not happen.
edit, add: rounding up and down
Besides rounding down to an integer, there is also the case of rounding (rounding up or down, depending on what the nearest integer is). In that case, indeed you pass test 5 while failing validator 5. Indeed, if you use rounding, test 5 will not be a problem, but validator 5 will be a problem. I have checked that case in detail, and found the following for validator 5:
40/0.75 -> 53.333; +10 -> 63.333; +10/0.75 -> 76.666
, while at the same time another counter (counter B) works itself through 40/1.25 -> 32; +10 -> 42; +30/1.25 -> 66; +10 -> 76
. There is a point in the day (at minute 76), when a visitor needs to choose between one of those counters, and will go for counter B, since counter A comes available 0.666 minute later.53 -> +10 = 63 -> +10/0.75 = 76
. Now counter A and B seemingly come available at the same minute, and the visitor will then go for counter A, because that one is lower in number than counter B.edit 2: rounding up
With rounding up, there is the special (especially unwanted) situation that you pass all validators, but fail test 5. Thank you @IIIThinkAboutIt for publishing your code - this is the case for you. Below the details of test 5.
110; +20/1.5 -> 123.333; +10/1.5 -> 130.000
. There is also another counter (counter B) that ends up available at exactly 130 minutes. At minute 130, the next visitor in line will go for counter A.110; +20/1.5 -> 124; +10/1.5 -> 131
. At minute 130, counter A is seemingly not yet available, so visitor will go for counter B instead.In any case, I have added to the statement that you should not round at all. I hope that solves all questions - on the small chance that not rounding at all for some reason (maybe in other languages) gives other behavior, I will revisit this point. Also, I might split test/validator 5 into multiple cases, dedicated to the different problems of rounding down, up or both. If I alter any of the cases, I will make sure that it will not break solution code for anyone currently passing all tests and validators.
I saw this thread and decided to check it out for myself.
@Oliverri You may publish your solution in the IDE area if it has passed all the validators, or PM your solution to the author directly. Please do not post your code on the forum. I’ve deleted your post. Thanks.
It maybe does not look good if I have a question on my own Puzzle, but it is what it is;
Question to full-stack developers / people using other languages than Python:
I only know Python. Is there a possibility that the not-rounding in Python leads to other behavior than not-rounding in any other programming language? In other words: might it be possible that at this moment, this puzzle works for Python, but not in all programming languages?
@jddingemanse You can be calm, the programming language has nothing to do with it. I’m not solving in Python. Who does not succeed - most likely the usual errors in the algorithm.
I should note that I did pass this in the end just by using floating point minutes. I think if you were to use an efficiency with a fractional result in the example then that should remove any confusion.
Phew, thanks!
I’ve added it in the last sentence of the statement (that 15 minutes with efficiency of 2 leads to 7.5 minutes). The fact that efficiencies itself can also be floats/fractional should follow both from the input instructions and what players will encounter in the cases.
Furthermore, announcement on a change in the puzzle
Thanks a lot to all of you for your quick feedback!
I’m trying this one in C++, applied no rounding and only fail test/validator 5
As the terminal output on here is truncated, I’d probably have to run it in an offline IDE to analyse where this breaks.
@jeetee can you paste here what your output for test and validator 5 is?
In general, test/val 5 and 6 are edge cases with respect to rounding: test/val 5 fails if there is rounding (up), test/val 6 fails if there is rounding (down). I’m not familiar with C+: might there be some unintended rounding going on if you use particular variable types?
Here’s my output for 5:
4 3 4 6 9 4
3 2 1 4 5 3
I’m currently using single precision floating point numbers to track time. I’ll try with doubles mlinstead, though I doubt this is due to a precision rounding error.
Much more likely that I messed up assigning the next available counter to the next visitor -_-’
EDIT: Solved!
Apparently it was a precision rounding error on the single floating data type; changing it to double precision made it pass
Ah good job! Indeed something rounding-related seemed the most likely reason given that you passed all other tests/validators. I think it is hard to have a wrong visitor-assignment that passes all those except five.