[Community puzzle] Elevator

Has anyone got passed test 6?

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.

The first digit it expects is 1. That is not the whole number. It is called “Lots of Steps” for a reason. :slight_smile:

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 :sob:

@bgura test 5 wants you to answer IMPOSSIBLE

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.

I’ve passed all tests now. Woohoo!

blargh, thanks. I’ve got test 5 solved but not validator 5 (just to make sure theres no confusion). Still hacking away asdfjkl; :confounded:

I solved the question using recursion and it wasn’t passing validator 5
I was calling a step function recursively
Initially the code was -

int up=step(k+a);
int down=step(k-b);

and it didn’t pass validator 5 but when i changed it to

int down=step(k-b);
int up=step(k+a);

it worked, so obviously the code is still not completely correct but I can’t figure out what the problem is

1 Like

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… :cold_sweat:

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

1 Like

im in the same boat - tried multiple different solution, all of them fail on validator 6 only

Based on my experience with validator 6, I believe it relates to an index out of range issue in your code.

Try running your code with a n=10000 a=1 b=1 k=1 m=10000

When I ran with those values in a Jupyter Notebook I was quickly able to figure out the bug in my code

I think it was a timeout or recursion limit. i ended up optimizing my solution and it worked fine - thanks for the help though

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?

Maybe add a test with: ‘2000 3 11 1000 1’ or something similar? =)

Hi! I passed all tests but have a problem with validator 6. Could anyone help?

Maybe a problem when the elevator reaches the floor or the roof?

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!

1 Like

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?

Thanks