I did the problems on CodeSignal and got a full score, 600/600. The next day HR told me: "After reviewing your Codesignal results, we found that they did not meet the required passing score to move forward." What kind of company is this?
The problem was called BouncyCosmo, similar to Flappy Bird, and had to be implemented in Python as should_bounce(params), which controls the character's jumping so it gets through all the pipes. The input includes the character's position, velocity, gravity, and the full map, and each frame you return whether to jump. They provide a simulator, a visualization UI, and tests, and you can read the source directly to understand the physics rules.
There is one key detail: each frame, gravity is added first, then the position is updated and collisions are checked, and only at the end is the jump velocity set, so a jump only takes effect on the next frame.
I used state search, recording the position, velocity, and jump path for each frame, and deduplicating identical states. I first kept only some of the candidate routes for a fast search, and if that found nothing I ran the full search. The hard parts were mainly the narrow pipes and the running time. In the end all 21 tests passed, taking about 66 seconds.
My advice is to understand simulator.py first, then write the strategy, and watch the collision boundaries and the time limit. Hope this is useful for everyone!
Discussion
Loading comments…