DWITE Online Computer Programming Contest

Four-player Pong with no players

January 2009
Problem 1

This “game” has been simplified so much that all the players left. Incidentally, with no paddles left on the screen, it makes it even simpler, as there is nothing to bounce off. The only objective left now is to figure out where the ball will hit the edge of the playfield.

The playfield is a rectangle of the size 100 wide by 50 high. The lower-left corner is at (0,0) and the upper right is at (100,50). The ball is the size of a single pixel, and the score counts as that pixel lands on the edge. The ball starts out at the center at (50,25), and its velocity will be provided in the input file.

The input file DATA1.txt will contain 5 sets of input, 2 lines each. The first line will be an integer value −10 ≤ H ≤ 10, the horizontal component of the velocity. The second line will be an integer value −10 ≤ V ≤ 10, the vertical component of the velocity. There will be no 0,0 input, and thus there will always be a solution.

The output file OUT1.txt will contain 5 lines, the location where the ball hits the edge, in the x,y format.

Note: If one was to simulate the game using a loop, the integer values in all of the cases will land exactly on an edge during one of the steps.

Another note: Some might want to draw to screen while developing or debugging their code – this could be helpful to get a better idea of what’s going on, but please remember to comment out any graphical code before submitting a solution.

Sample Input (3 of 5 shown):
Sample Output (3 of 5 shown):