Pawns (Chess)
Add pawns: one square forward if empty, two from the starting rank if both are empty, and one square diagonally forward to capture an enemy. White moves up the board, black down.
Input: As before.
Output: As before.
Difficulty: Medium. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Direction = +1 for white, −1 for black; the starting rank is 2 or 7.