forked from lperichon/Phonepad-Chess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
28 lines (22 loc) · 1.19 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
The "Programming Problem": Chess Moves
Write an application that takes as input:
The name of a chess piece (King, Queen, Bishop, Knight, Rook, Pawn)
A starting digit, 0 to 9
As output the program should produce a list of all the legal phone numbers that can be generated by moving the piece around a standard phone pad, starting from the given digit. You should also supply the total number of different phone numbers that are produced for the case of a Queen starting on digit '5'.
A legal phone number has the following requirements:
Must be 10 digits long
Can contain only digits (no * or #)
The phone pad layout is:
1 2 3
4 5 6
7 8 9
* 0 #
But be careful, a legal move is defined as any move that would normally be legal for the piece in chess, with the following additions:
Staying in place is a legal move for all pieces
When a Pawn reaches the top row, it becomes a Queen
For the case where the piece is a Pawn, starting on one of the bottom two rows (i.e. any of the digits 7, 8, 9 and 0), the Pawn may move either one or two spaces forward, but only the first time it moves.
Installation
1) git clone git@github.com:Boltmade/Phonepad-Chess.git
2) cd Phonepad-Chess
3) bundle install
4) ruby main.rb