L.A.11.3 o ACSLSr

lab exercise 11-3

 

ACSLland - senior Division

 

 

American Computer Science League - Senior 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 31 cells.  The first one is labeled START, the last cell END, and the remaining cells are numbered 1 through 29.

 

    There are three players, A, B, and C.  The game starts with all players on the START cell.  Player A always goes first, then B, then C, then A, and so on.  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, move backwards that many cells (but don't go before START!); if the die shows a 6, the player doesn't move at all and forfeits the next turn.  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 C, 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, B, and C.  The position of all three players must be correct to receive credit for each output; there is no partial credit.

 

Sample Input:                                                                    Sample output:

 

Line #1:  1,2,3,5,7,1,2,5,2,0                                       Output #1:  A-8, B-14, C-6

Line #2:  8,7,5,7,4,7,8,2,5,8,1,0                                 Output #2:  A-END, B-5, C-17

Line #3:  7,5,2,3,5,8,5,1,4,7,3,5,3,8,4,0                     Output #3:  A-15, B-12, C-7

Line #4:  3,7,2,6,5,3,2,4,7,8,5,4,8,2,0                        Output #4:  A-6, B-END, C-START

Line #5:  1,7,5,2,8,4,1,3,3,6,4,2,8,1,7,8,5,0               Output #5:  A-7, B-END, C-START

 

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.