IPSC 2016
Solution to Problem D – Dumb clicking
There are two main ways how to solve this task. You can either generate the log using your own program (which requires understanding of the inner workings of the game) or put a small program into the javascript console in your browser to make it play the game for you much faster.
The easy subproblem is pretty straighforward, since the rectangles and squares do not move. But there are several gotchas which you could encounter:
- The instruction for the first level is not in easy-data.js but in the html source.
- Some of the later levels have two commands instead of one.
- After the last level you should write “done” instead of “next” (not after “next”).
The hard subproblem adds some more tricks on top:
- The source code for game is minified.
- There is a timestamp in the logs. And also instructions about waiting between clicks. And on top of that, you are required to produce valid timestamps that all lie within the duration of the contest (more precisely, between the beginning of the contest and the moment when you submit). The grader rejected submissions with timestamps outside this range. One side effect of this check: it was impossible to submit D2 during first half hour of the contest.
- The squares and rectangles are changing positions. To handle this, you can either read the game’s source code to find the pseudorandom algorithm, or let it generate the levels and then query the generated image to find which shape is where. We find the second option much easier.