Enumeration of Hidato puzzles Gyora Benedek solutions.

30
Enumeration of Hidato puzzles Gyora Benedek solution s

Transcript of Enumeration of Hidato puzzles Gyora Benedek solutions.

Page 1: Enumeration of Hidato puzzles Gyora Benedek solutions.

Enumeration of Hidato puzzles

Gyora Benedek

solutions

Page 2: Enumeration of Hidato puzzles Gyora Benedek solutions.

Hidato solution = Hamiltonian path on a grid

2(c) Copyright, Gyora Benedek 2014

How many are th

ere?

Page 3: Enumeration of Hidato puzzles Gyora Benedek solutions.

Let’s try something easier:2 by n grids

3(c) Copyright, Gyora Benedek 2014

Page 4: Enumeration of Hidato puzzles Gyora Benedek solutions.

Enumerating 2 by n LR Hamiltonian paths

• LR paths: start at BL and end TR

2 by 6• H(2,6) = ?• H(2,n) = ?

4(c) Copyright, Gyora Benedek 2014

Page 5: Enumeration of Hidato puzzles Gyora Benedek solutions.

Enumerating 2 by n LR Hamiltonian paths

• Note that for any 2 by n path we can exchange any two values in the same column and get a new path

5(c) Copyright, Gyora Benedek 2014

Page 6: Enumeration of Hidato puzzles Gyora Benedek solutions.

Enumerating 2 by n LR Hamiltonian paths

• Note that for any 2 by n path we can exchange any two values in the same column and get a new path – both have the same neighbors

6(c) Copyright, Gyora Benedek 2014

Page 7: Enumeration of Hidato puzzles Gyora Benedek solutions.

Ordered LR 2 by n path

Def. Ordered LR 2 by n path:A 2 by n path where 1 is in the left col., 2n is in

the right col. and in every column the number below is smaller than the number above.

7(c) Copyright, Gyora Benedek 2014

Page 8: Enumeration of Hidato puzzles Gyora Benedek solutions.

How many ordered LR 2 by n paths?

Def. K(n) = #(ordered LR 2 by n paths)

8(c) Copyright, Gyora Benedek 2014

Page 9: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 1

9

K(1) = 1

(c) Copyright, Gyora Benedek 2014

Page 10: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 2

10

K(2) = 2

(c) Copyright, Gyora Benedek 2014

Page 11: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 6

11

K(6) =?

(c) Copyright, Gyora Benedek 2014

Page 12: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 6

12

K(6) =?

(c) Copyright, Gyora Benedek 2014

Page 13: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 6

13

K(6) =K(5)+?

(c) Copyright, Gyora Benedek 2014

Page 14: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 6

14

K(6) =K(5)+?

(c) Copyright, Gyora Benedek 2014

Page 15: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 6

15

K(6) =K(5)+?

(c) Copyright, Gyora Benedek 2014

Page 16: Enumeration of Hidato puzzles Gyora Benedek solutions.

2 by 6

16

K(6) =K(5)+K(4)

(c) Copyright, Gyora Benedek 2014

Page 17: Enumeration of Hidato puzzles Gyora Benedek solutions.

How many ordered LR 2 by n paths

K(1) = 1K(2) = 2K(n) = K(n-1) + K(n-2)

17(c) Copyright, Gyora Benedek 2014

Page 18: Enumeration of Hidato puzzles Gyora Benedek solutions.

How many ordered LR 2 by n paths?

K(1) = 1K(2) = 2K(n) = K(n-1) + K(n-2)

Fibonacci numbers shifted – as any biologist would recognizeF(1) = 1; F(2) = 1; F(3) = 2; F(n)=F(n-1)+F(n-2)

K(n) = F(n+1)

Interesting to note that this is also the number of ways for 2 by 1 dominoes to cover a 2 by n board.

18(c) Copyright, Gyora Benedek 2014

Page 19: Enumeration of Hidato puzzles Gyora Benedek solutions.

Enumerating 2 by n LR Hamiltonian paths

Reminder LR: start at BL and end at TR

19

)1(2),2( 2 nFnH n

(c) Copyright, Gyora Benedek 2014

Page 20: Enumeration of Hidato puzzles Gyora Benedek solutions.

Divide and conquer

(c) Copyright, Gyora Benedek 2014 20

Page 21: Enumeration of Hidato puzzles Gyora Benedek solutions.

Lower bound by brute force

• 5x5 {?,?} => {A,B}: 83,781,512• 5x4 {C,D} => {E,F}: 202,374• 4x4 {G,H} => {I,J}: 9,868• 4x5 {K,L} => {?,?}: 1,306,425• Symmetries: 16• Total: 3,497,329,213,274,509,542,835,200

(c) Copyright, Gyora Benedek 2014 21

Page 22: Enumeration of Hidato puzzles Gyora Benedek solutions.

Big numbers

• Rubik’s 3×3×3 cube ≈ 4.3 × 10^19• Sudoku 9×9 ≈ 6.6 × 10^21• Hidato King 9×9 >> 3.49×10^24

× 500

• Still, the lower bound is extremely pessimistic. Can we do better?

(c) Copyright, Gyora Benedek 2014 22

Page 23: Enumeration of Hidato puzzles Gyora Benedek solutions.

Project proposal: Enumerate all Hamiltonian paths in a 9×9 grid

with diagonals

(c) Copyright, Gyora Benedek 2014 23

A Walk in the shadows

Page 24: Enumeration of Hidato puzzles Gyora Benedek solutions.

Shadows

2,000,000 774 544(c) Copyright, Gyora Benedek 2014 24

Page 25: Enumeration of Hidato puzzles Gyora Benedek solutions.

Shadows

(c) Copyright, Gyora Benedek 2014 25

Page 26: Enumeration of Hidato puzzles Gyora Benedek solutions.

Shadows

• 2,000,000*774*544 = 842,112,000,000 paths(c) Copyright, Gyora Benedek 2014 26

Page 27: Enumeration of Hidato puzzles Gyora Benedek solutions.

Feasibility

• #shadows – Comb(27,81) ≈ 2.3 × 10^21– Trim non-connected, with holes (? 10^9 ?)– Entry, exit points– If too large try 4 shadows of 20 + 1– Or smaller boards (8×8 even 7×7)

(c) Copyright, Gyora Benedek 2014 27

Page 28: Enumeration of Hidato puzzles Gyora Benedek solutions.

Challenges

• Efficient algorithms and code• Efficient representation of the shadows

– Shadow: 81bit, entry: 7bit, exit: 7bit, counter: 32?

• Efficient search: hash of the shadow• Parallel/Distributed processing

– Cloud

• Efficient disk access (SSD?) and memory use• Testing: we have data up to 5×5

(c) Copyright, Gyora Benedek 2014 28

Page 29: Enumeration of Hidato puzzles Gyora Benedek solutions.

Summary

• Numbers are men’s friends – get to know them!– Help the young know them

• Hidato is great for your brain – play and enjoy• Enumeration of Hidato solutions is hard

– Will you pick up the challenge and walk in the shadows?

(c) Copyright, Gyora Benedek 2014 29

Page 30: Enumeration of Hidato puzzles Gyora Benedek solutions.

Thank You!

Questions?

Ideas?

Visit hidato.com

(c) Copyright, Gyora Benedek 2014 30