Skip to content

Latest commit

 

History

History
204 lines (188 loc) · 6.96 KB

README.mkd

File metadata and controls

204 lines (188 loc) · 6.96 KB

Bored on a plane. A nice puzzle on vacation. Because why not...

also:

  • no use of the internet to lookup anything* (including code docs)
  • stdlib libraries only (on a plane, with no internet access)

* except to lookup some hard puzzles to independantly test my program

python board_filler.py: Will build a random board from scratch python puzzle_creator.py: Will build a board and then randomly remove some numbers so you can play sodoku

Eventually I got on the internet and found a really hard sodoku board and solved it:

Alt text

Confirmed solution: http://www.telegraph.co.uk/news/science/science-news/9360022/Worlds-hardest-sudoku-the-answer.html

$ python puzzle_solver.py arto-inkala-board.txt
Game board:
 8  _  _  _  _  _  _  _  _
 _  _  3  6  _  _  _  _  _
 _  7  _  _  9  _  2  _  _
 _  5  _  _  _  7  _  _  _
 _  _  _  _  4  5  7  _  _
 _  _  _  1  _  _  _  3  _
 _  _  1  _  _  _  _  6  8
 _  _  8  5  _  _  _  1  _
 _  9  _  _  _  _  4  _  _

Solution:
 8  1  2  7  5  3  6  4  9
 9  4  3  6  8  2  1  7  5
 6  7  5  4  9  1  2  8  3
 1  5  4  2  3  7  8  9  6
 3  6  9  8  4  5  7  2  1
 2  8  7  1  6  9  5  3  4
 5  2  1  9  7  4  3  6  8
 4  3  8  5  2  6  9  1  7
 7  9  6  3  1  8  4  5  2

Some sample game boards made with puzzle_creator.py.

+---+---+---+---+---+---+---+---+---+
| 2 | 9 | 8 | 4 | 6 | 5 | 1 | 7 | 3 |
+---+---+---+---+---+---+---+---+---+
| 6 | 7 | 4 | 3 | 1 | _ | 9 | 8 | 5 |
+---+---+---+---+---+---+---+---+---+
| 5 | 1 | 3 | 9 | 8 | 7 | 6 | 2 | _ |
+---+---+---+---+---+---+---+---+---+
| 3 | 2 | 5 | 8 | 7 | 6 | 4 | 1 | _ |
+---+---+---+---+---+---+---+---+---+
| 7 | 4 | 9 | 2 | 3 | 1 | 8 | _ | 6 |
+---+---+---+---+---+---+---+---+---+
| 8 | 6 | 1 | 5 | 9 | 4 | 7 | 3 | 2 |
+---+---+---+---+---+---+---+---+---+
| 1 | 5 | 2 | 7 | 4 | 9 | 3 | 6 | 8 |
+---+---+---+---+---+---+---+---+---+
| 4 | 8 | 7 | 6 | 2 | _ | 5 | 9 | 1 |
+---+---+---+---+---+---+---+---+---+
| 9 | 3 | 6 | 1 | 5 | 8 | 2 | 4 | 7 |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| _ | _ | 9 | 2 | 7 | 4 | 1 | _ | 5 |
+---+---+---+---+---+---+---+---+---+
| 5 | 7 | 4 | 1 | 8 | 6 | 3 | 9 | 2 |
+---+---+---+---+---+---+---+---+---+
| 2 | _ | 1 | 3 | 5 | 9 | 4 | _ | 7 |
+---+---+---+---+---+---+---+---+---+
| 4 | 2 | 3 | 7 | 6 | 5 | 8 | 1 | 9 |
+---+---+---+---+---+---+---+---+---+
| 6 | 1 | 7 | 9 | 3 | 8 | _ | 2 | 4 |
+---+---+---+---+---+---+---+---+---+
| 9 | _ | 8 | 4 | 2 | _ | 6 | 7 | _ |
+---+---+---+---+---+---+---+---+---+
| 1 | 9 | 5 | _ | 4 | 7 | 2 | 3 | 6 |
+---+---+---+---+---+---+---+---+---+
| 7 | 4 | 2 | 6 | 1 | _ | 9 | 5 | 8 |
+---+---+---+---+---+---+---+---+---+
| 3 | 8 | 6 | 5 | 9 | 2 | 7 | _ | 1 |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| 8 | _ | 1 | _ | 5 | 2 | 6 | 9 | _ |
+---+---+---+---+---+---+---+---+---+
| 6 | 3 | 5 | 9 | 4 | 7 | _ | 8 | _ |
+---+---+---+---+---+---+---+---+---+
| 2 | 4 | 9 | 6 | 1 | 8 | 5 | _ | 3 |
+---+---+---+---+---+---+---+---+---+
| 5 | _ | _ | 1 | 9 | 3 | 8 | 4 | 7 |
+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | 5 | _ | 6 | 3 | 2 | 1 |
+---+---+---+---+---+---+---+---+---+
| 1 | 8 | 3 | 2 | 7 | 4 | 9 | 5 | 6 |
+---+---+---+---+---+---+---+---+---+
| 4 | 1 | 7 | 8 | 6 | 5 | 2 | 3 | _ |
+---+---+---+---+---+---+---+---+---+
| 3 | 5 | _ | 4 | _ | 9 | _ | 1 | 8 |
+---+---+---+---+---+---+---+---+---+
| 9 | _ | 8 | 7 | _ | 1 | _ | 6 | 5 |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| 9 | _ | 6 | _ | 3 | 5 | _ | _ | 8 |
+---+---+---+---+---+---+---+---+---+
| 3 | 8 | _ | 2 | 6 | 9 | 7 | 4 | 5 |
+---+---+---+---+---+---+---+---+---+
| 2 | 4 | 5 | 7 | 1 | 8 | 6 | _ | 3 |
+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | 1 | 8 | _ | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+
| _ | 5 | 2 | 6 | _ | _ | 9 | 8 | 1 |
+---+---+---+---+---+---+---+---+---+
| 1 | _ | _ | _ | 5 | 2 | 4 | 7 | 6 |
+---+---+---+---+---+---+---+---+---+
| 5 | 1 | 7 | 3 | 2 | 4 | 8 | 6 | 9 |
+---+---+---+---+---+---+---+---+---+
| _ | 2 | 3 | _ | 9 | 6 | 1 | _ | 7 |
+---+---+---+---+---+---+---+---+---+
| 8 | _ | _ | 5 | 7 | 1 | _ | _ | 4 |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| 3 | _ | 7 | 1 | 8 | _ | 6 | _ | 4 |
+---+---+---+---+---+---+---+---+---+
| _ | 9 | 1 | 7 | _ | _ | 2 | _ | 3 |
+---+---+---+---+---+---+---+---+---+
| 2 | 6 | 8 | _ | 4 | _ | _ | _ | 1 |
+---+---+---+---+---+---+---+---+---+
| 8 | 1 | _ | 2 | _ | 5 | 4 | _ | _ |
+---+---+---+---+---+---+---+---+---+
| 5 | _ | _ | _ | 7 | 4 | 1 | 2 | 9 |
+---+---+---+---+---+---+---+---+---+
| 7 | _ | 4 | 6 | 1 | _ | _ | _ | 8 |
+---+---+---+---+---+---+---+---+---+
| 6 | 4 | 5 | _ | 9 | 8 | _ | _ | 2 |
+---+---+---+---+---+---+---+---+---+
| 9 | 7 | 3 | 5 | _ | _ | _ | _ | 6 |
+---+---+---+---+---+---+---+---+---+
| _ | 8 | _ | _ | _ | 7 | 9 | 3 | 5 |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| _ | 6 | 7 | _ | _ | _ | 2 | _ | 4 |
+---+---+---+---+---+---+---+---+---+
| 9 | 5 | 4 | 2 | _ | 1 | _ | 3 | _ |
+---+---+---+---+---+---+---+---+---+
| _ | _ | 2 | 7 | _ | 4 | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+
| 3 | 2 | _ | _ | _ | _ | _ | _ | 6 |
+---+---+---+---+---+---+---+---+---+
| _ | 4 | _ | 1 | 7 | 3 | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+
| 7 | 9 | _ | 6 | _ | _ | _ | _ | 5 |
+---+---+---+---+---+---+---+---+---+
| 4 | _ | 9 | 3 | 2 | 8 | 5 | 6 | 1 |
+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | 4 | _ | 7 | 9 | 2 | 3 |
+---+---+---+---+---+---+---+---+---+
| 2 | 1 | 3 | _ | _ | _ | _ | 8 | _ |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | 3 | _ | _ | _ | _ | 1 |
+---+---+---+---+---+---+---+---+---+
| 5 | _ | 1 | _ | 2 | _ | 6 | 4 | 3 |
+---+---+---+---+---+---+---+---+---+
| 8 | _ | _ | _ | _ | _ | _ | 2 | _ |
+---+---+---+---+---+---+---+---+---+
| _ | _ | 6 | 2 | 4 | 3 | _ | _ | 9 |
+---+---+---+---+---+---+---+---+---+
| 2 | 1 | _ | _ | 8 | 7 | _ | _ | 4 |
+---+---+---+---+---+---+---+---+---+
| _ | 4 | _ | _ | 1 | _ | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+
| 6 | 3 | _ | _ | 5 | _ | 4 | _ | 8 |
+---+---+---+---+---+---+---+---+---+
| _ | 2 | _ | _ | 7 | _ | _ | _ | 6 |
+---+---+---+---+---+---+---+---+---+
| _ | _ | 4 | 8 | _ | 6 | _ | 9 | _ |
+---+---+---+---+---+---+---+---+---+

+---+---+---+---+---+---+---+---+---+
| _ | 9 | _ | _ | 4 | 5 | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+
| _ | _ | 7 | _ | _ | 9 | _ | 5 | _ |
+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | 7 | 1 | _ | 9 | _ | 2 |
+---+---+---+---+---+---+---+---+---+
| _ | 2 | _ | _ | _ | _ | _ | _ | 7 |
+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | _ | 9 | 3 | 4 | 2 | _ |
+---+---+---+---+---+---+---+---+---+
| 9 | _ | _ | _ | 7 | _ | _ | _ | 5 |
+---+---+---+---+---+---+---+---+---+
| 4 | 7 | 9 | _ | _ | _ | 2 | 6 | _ |
+---+---+---+---+---+---+---+---+---+
| _ | _ | _ | 9 | _ | _ | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+
| 6 | 1 | _ | _ | _ | _ | _ | _ | _ |
+---+---+---+---+---+---+---+---+---+