lab exercise 11-2
ACSLland - intermediate Division
American Computer Science League - Intermediate Division, Contest #1,
1989-90.
Problem: The game of ACSLLand, not to be confused with the popular children's game of Candyland, consists of moving a marker from a starting location through a series of calls to an ending location. Here are the details:
• The game board has 41 cells. The first one is labeled START, the last cell END, and the remaining cells are numbered 1 through 39.
• There are two players, A and B. The game starts with both players on the START cell. Player A always goes first. Thereafter, the players alternate turns. The game ends when a player reaches the END cell or beyond.
• Each move consists of rolling an 8-sided die and moving that many cells forward. However, if the die shows a 4 or 6, move backwards that many cells (but don't go before START!). If a player lands on a cell occupied by the other player, the player that was on the cell jumps immediately to START.
Input: The rolls of the 8-sided die for five games. Each game consists of positive integers representing the rolls, terminated by a 0. The first number is for player A, then B, then A, and so on. Each game ends as described above or when the 0 is read.
Output: For each game, print the final position of the players A and B. The position of both players must be correct to receive credit for each output; there is no partial credit.
Sample Input: Sample output:
Line #1: 3,5,1,8,2,7,0 Output #1: A-6, B-20
Line #2: 5,7,8,7,5,5,3,8,7,3,7,7,8,8,0 Output #2: A-END, B-37
Line #3: 3,3,1,2,2,7,5,7,0 Output #3: A-8, B-19
Line #4: 5,7,4,1,3,8,7,6,4,6,0 Output #4: A-7, B-4
Line #5: 1,2,3,5,3,8,1,8,5,7,0 Output #5: A-5, B-15
A Reminder: The gist of the ACSL rules are as follows: You have 72 hours to complete the program and test it on your own data. You may use any computer you can access, and you must work alone. Your program is run just once with the ACSL Test Data. This means that your program must accept all the data without ending. Because the test data becomes more difficult towards the end, we suggest that you output answers as you compute them.