Reversi row rudiments
Description:
Introduction:
Reversi is a game usually played by 2 people on a 8x8 board. Here we're only going to consider a single 8x1 row.
Players take turns placing pieces, which are black on one side and white on the other, onto the board with their colour facing up. If one or more of the opponents pieces are sandwiched by the piece just played and another piece of the current player's colour, the opponents pieces are flipped to the current players colour.
Note that the flipping stops when the first piece of the player's colour is reached.
Task:
Your task is to take an array of moves and convert this into a string representing the state of the board after all those moves have been played.
Input:
The input to your function will be an array of moves. Moves are represented by integers from 0 to 7 corresponding to the 8 squares on the board. Black plays first, and black and white alternate turns. Input is guaranteed to be valid. (No duplicates, all moves in range, but array may be empty)
Output:
8 character long string representing the final state of the board.
Use '*'
for black and 'O'
for white and '.'
for empty.
Examples:
moves | result
--------------------------
[] --> "........"
[3] --> "...*...."
[3,4] --> "...*O..."
[3,4,5] --> "...***.."
Similar Kata:
Stats:
Created | Jul 18, 2015 |
Published | Jul 18, 2015 |
Warriors Trained | 625 |
Total Skips | 88 |
Total Code Submissions | 3285 |
Total Times Completed | 273 |
Ruby Completions | 65 |
Python Completions | 154 |
JavaScript Completions | 71 |
CoffeeScript Completions | 8 |
Total Stars | 32 |
% of votes with a positive feedback rating | 95% of 86 |
Total "Very Satisfied" Votes | 79 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 12 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |