University of Lethbridge - Mathematics & Computer Science

Problem #6 Super Skier

Super skier always wants to take the steepest slope possible, and to make as few turns as he can. Your job is to help him find his way down the slopes. You will be given a 10x10 array of heights, and the coordinates of Super Skier's starting location. From his location he can move to the next adjacent square, either horizontally, vertically, or diagonally. You should find the steepest slope for him to descend to an adjacent location. If two or more slopes have the same drop, he wants to continue in as close to the same direction as possible. If there are two steepest slopes, each with the same amount of turn from his current direction, being right handed he would prefer to turn right. He will continue in this fashion from square to adjacent square until he reaches the bottom of the slope, that is, a location with no lower neighbor. For simplicity, your program may assume that the starting point has a unique lowest neighbor. Your program should read in a 10 by 10 array of integers, ten lines of ten integers, followed by a line containing the x and y coordinates of his starting location. The first integer read in is location 1,1, the next is location 2,1, etc.

You should print out the x and y coordinates of his path down the hill in the form shown, starting with his initial position.

For example:

Input File (skier.dat):

95 95 18 05 19 95 95 95 95 95
14 23 38 55 39 95 00 70 95 95
44 88 54 87 91 95 95 80 80 95
33 11 01 49 76 95 95 90 95 70
98 32 56 88 39 95 99 95 95 60
12 13 14 15 16 95 95 95 50 95
65 54 43 32 21 87 95 40 40 40
66 77 88 77 66 95 30 95 95 95
38 00 00 01 95 95 20 95 95 95
43 05 06 07 95 10 10 09 08 07
7 5
Output File (skier.out):
**********************
* Team  x, Problem 15*
**********************

(7,5)
(8,4)
(9,3)
(10,4)
(10,5)
(9,6)
(8,7)
(7,8)
(7,9)
(8,10)
(9,10)
(10,10)

***** End of Output *****

Original problem: Rocky Mountain Region ACM contest, 1993