Canadian Computing Competition: 2006 Stage 1, Junior #5
Othello (also known as Reversi or Black & White Chess) is a game played on an
The game starts with some discs already placed on the board.
A move is valid if the following two conditions are satisfied:
- The piece placed on the board is adjacent to a piece on the board (i.e., beside a piece either horizontally, vertically or diagonally).
- At least one of your opponents' discs must be "flipped." If you are playing black pieces, you flip your opponents' (white) pieces (to black) so long as your opponents' pieces are on a line (either horizontally, vertically or diagonally) between the latest piece placed on the board and another black piece, with no other black pieces or empty squares in between the most recently placed black piece and the given white piece. The same rule applies if the player is placing white pieces.
Here are a couple of sample valid moves, starting from various configurations of the board:
Board at the beginning of the game | Board after the black player has placed a disc in row |
---|---|
![]() |
![]() |
Board after several plays by each player | Board after the white player has placed a disc in row |
![]() |
![]() |
Board after several plays by each player | Board after the white player has placed a disc in row |
![]() |
![]() |
In the CCC version of Othello, the board may start with one of
Input Specification
The user will enter three components of input (via the keyboard).
First, the user will enter a letter representing the configuration of the initial board (either a
, b
or c
).
Here are the initial configurations for the board.
Configuration a |
Configuration b |
Configuration c |
---|---|---|
![]() |
![]() |
![]() |
The second component of input will be an integer
The third component of input is
Remember that the first move will be made by the black player, the next move will be made by the white player, then the black player, then the white player, and so on. You may also assume that all moves
Output Specification
The program will output the number of black discs showing followed by the number of white discs showing on the board after the moves have been made. You are not responsible for displaying a picture of the board during the game. However, during your own testing, this may be useful.
Sample Input 1
a 1 5 6
Sample Output 1
4 1
Sample Input 2
b 0
Sample Output 2
8 8
Sample Input 3
c 3 1 7 2 2 2 1
Sample Output 3
22 13
Comments