The inputs for the test are 1999 1000 999 2 1, which seems like a result of IMPOSSIBLE but the test expects a result of 1.
Given the rules of the puzzle, if you start on floor 2 and up is 1000 floors and down is 999 floors, there is no way you can reach floor 1 with 1 button press.
Press Up, press Down - will go up one floor.
Repeat 998 time (1996 press the buttons) - will go up 998 floors, stand 2+ 998 = 1000th floor. Press Down - stand 1000-999 = 1nd floor. In total 1997 press the buttons, not IMPOSSIBLE.
You get past validator 5? Iâm stuck on it as well. Passed all other test cases and validators. According to the known test case âAbove and Belowâ im not sure what else it is testing⌠hmm. Ready to smash a keyboard⌠I wish these validators had named tests
Thanks everyone for the help with test 6. I didnât realise that when it says âexpected 1â that just means the first character and not the entire answer.
Well thats really annoying⌠That was my issue as well it turns out. I wonder if we overflow the stack or something? How much space do we get??. Argghh, anyway⌠its passing now
How the heck did you think of that?
Edit: There still may be a bug im overlooking but if thats not the caseâŚ
The FAQ says we get 768 MB and Iâm almost certain it wasnât overflow but Iâm not completely sure.
The code still isnât correct as the test could be reversed and it wouldnât pass, but I stole the 2nd ranked code and modified it a bit to make it work for test case 8 and I think that one should work for all possible cases.
Does anybody know the purpose of validator 6?
Because itâs the only validator that I fail.
It would be enough for me a similar input in order to find out the bug.
Thanks
In my case I donât think itâs a timeout problem, because in a test the code was able to count 17997 buttons pressed.
It could be a stupid problem, but I am unable to find it.Could you suggest me some input that gave you trouble?
Hi! Solved it without a single loop directive. Solution can be obtained by solving linear Diophantine equation with special restrictions. Extended Euclidean algorithm fits the case perfectly. Loved the puzzle, thank you!
I would suggest adding better description about how the floors are counted.
Some buildings have the Ground floor at the bottom, and then 1st, 2nd floors upward. âGâ is practically the first floor.
Some buildings count from 1 as the bottom floor.
Some others have basements, -1, -2 floors.
So, for this puzzle, can my position be 0? Or be negative?