IPSC Logo

Internet Problem Solving Contest

IPSC 1999

Solution to Problem E – Labyrinth

This problem was one of the easiest. The only trick was to rewrite the numbers in the input file to usual digital form by hand and then to write a program that simulates the mouse. The program is a straightforward translation of the rules given in problem description into chosen programming language.

The only tasks that should be programmed are counting the number of digits and reversing numbers. Also one should be aware that some inputs require 4-byte integers. In node 7 one should compute (X*X) mod 7. However X*X can be too large even for 4-byte integers, therefore it is advisable to compute the result as ((X mod 7)*(X mod 7)) mod 7.