Skip to content

Commit a6f8318

Browse files
committed
added Toy Robot challenge
Reorganized challenges, moving "Connect Four" a bit earlier in the list.
1 parent 3223626 commit a6f8318

File tree

3 files changed

+89
-12
lines changed

3 files changed

+89
-12
lines changed
File renamed without changes.

07-toy-robot/README.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Challenge: Toy Robot Simulator
2+
3+
## Description
4+
5+
- The application is a simulation of a toy robot moving on a square tabletop, of dimensions 5 units x 5 units.
6+
- There are no other obstructions on the table surface.
7+
- The robot is free to roam around the surface of the table, but must be prevented from falling to destruction. Any movement that would result in the robot falling from the table must be prevented, however further valid movement commands must still be allowed.
8+
9+
#### Create an application that can read in commands of the following form
10+
11+
PLACE X,Y,F
12+
MOVE
13+
LEFT
14+
RIGHT
15+
REPORT
16+
17+
- `PLACE` will put the toy robot on the table in position X,Y and facing NORTH,
18+
SOUTH, EAST or WEST.
19+
- The origin (0,0) can be considered to be the SOUTH WEST most corner.
20+
- The first valid command to the robot is a `PLACE` command, after that, any
21+
sequence of commands may be issued, in any order, including another `PLACE`
22+
command. The application should discard all commands in the sequence until a
23+
valid `PLACE` command has been executed.
24+
- `MOVE` will move the toy robot one unit forward in the direction it is
25+
currently facing.
26+
- `LEFT` and `RIGHT` will rotate the robot 90 degrees in the specified direction
27+
without changing the position of the robot.
28+
- `REPORT` will announce the X,Y and F of the robot. This can be in any form,
29+
but standard output is sufficient.
30+
- A robot that is not on the table can choose to ignore the `MOVE`, `LEFT`,
31+
`RIGHT`, and `REPORT` commands.
32+
- Input can be from a file, or from standard input, as the developer chooses.
33+
- Provide test data to exercise the application.
34+
35+
## Constraints
36+
37+
The toy robot must not fall off the table during movement. This also includes the initial placement of the toy robot.
38+
Any move that would cause the robot to fall must be ignored.
39+
40+
## Example Input and Output:
41+
42+
*Example 1*
43+
44+
PLACE 0,0,NORTH
45+
MOVE
46+
REPORT
47+
48+
Output: 0,1,NORTH
49+
50+
51+
*Example 2*
52+
53+
PLACE 0,0,NORTH
54+
LEFT
55+
REPORT
56+
57+
Output: 0,0,WEST
58+
59+
60+
*Example 3*
61+
62+
PLACE 1,2,EAST
63+
MOVE
64+
MOVE
65+
LEFT
66+
MOVE
67+
REPORT
68+
69+
Output: 3,3,NORTH
70+
71+
72+
---
73+
74+
Interview question by [Jon Eaves][jon_eaves] (he acknowledges it is not that original).
75+
76+
[jon_eaves]: https://joneaves.wordpress.com/2014/07/21/toy-robot-coding-test/
77+

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
These are some additional coding challenges to sharpen your Python programming skills.
44

5-
0. [Warm Up: Sorting](https://github.com/PDXPythonPirates/code-challenges/blob/master/00-sorting/)
6-
0. [Matrix Rotation](https://github.com/PDXPythonPirates/code-challenges/blob/master/01-matrix-rotate/)
7-
0. [Caesar Cipher](https://github.com/PDXPythonPirates/code-challenges/blob/master/02-caesar-cipher/)
8-
0. [Scrabble Word Finder](https://github.com/PDXPythonPirates/code-challenges/blob/master/03-scrabble-words/)
9-
0. [Shakespeare Word Frequency](https://github.com/PDXPythonPirates/code-challenges/blob/master/04-shakespeare-frequency/)
10-
0. TBD
11-
0. [A Grep Clone](https://github.com/PDXPythonPirates/code-challenges/tree/master/06-pygrep/)
12-
0. [Connect Four](https://github.com/PDXPythonPirates/code-challenges/tree/master/07-connect-four/)
13-
0. [Check the Weather](https://github.com/PDXPythonPirates/code-challenges/tree/master/08-weather-check/)
14-
0. [Sudoku Solver](https://github.com/PDXPythonPirates/code-challenges/tree/master/09-sudoku/)
15-
0. [URL Shortener](https://github.com/PDXPythonPirates/code-challenges/tree/master/10-url-shortener/)
5+
0. [Warm Up: Sorting](00-sorting/README.md)
6+
0. [Matrix Rotation](01-matrix-rotate/README.md)
7+
0. [Caesar Cipher](02-caesar-cipher/README.md)
8+
0. [Scrabble Word Finder](03-scrabble-words/README.md)
9+
0. [Shakespeare Word Frequency](04-shakespeare-frequency/README.md)
10+
0. [Connect Four](05-connect-four/README.md)
11+
0. [A Grep Clone](06-pygrep/README.md)
12+
0. [Toy Robot](07-toy-robot/README.md)
13+
0. [Check the Weather](08-weather-check/README.md)
14+
0. [Sudoku Solver](09-sudoku/README.md)
15+
0. [URL Shortener](10-url-shortener/README.md)
1616

1717

1818
## How to Contribute
1919

2020
See [CONTRIBUTE.md][contribute_howto] for guidelines on contributing additional challenges and updates.
2121

2222

23-
[contribute_howto]:https://github.com/PDXPythonPirates/code-challenges/blob/master/CONTRIBUTE.md
23+
[contribute_howto]:CONTRIBUTE.md

0 commit comments

Comments
 (0)