Copyright | (c) Levent Erkok |
---|---|

License | BSD3 |

Maintainer | erkokl@gmail.com |

Stability | experimental |

Safe Haskell | None |

Language | Haskell2010 |

A solution to the hexagon solver puzzle: http://www5.cadence.com/2018ClubVQuiz_LP.html In case the above URL goes dead, here's an ASCII rendering of the problem.

We're given a board, with 19 hexagon cells. The cells are arranged as follows:

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19

- Each cell has a color, one of
`BLACK`

,`BLUE`

,`GREEN`

, or`RED`

. - At each step, you get to press one of the center buttons. That is, one of 5, 6, 9, 10, 11, 14, or 15.
- Pressing a button that is currently colored
`BLACK`

has no effect. - Otherwise (i.e., if the pressed button is not
`BLACK`

), then colors rotate clockwise around that button. For instance if you press 15 when it is not colored`BLACK`

, then 11 moves to 16, 16 moves to 19, 19 moves to 18, 18 moves to 14, 14 moves to 10, and 10 moves to 11. - Note that by "move," we mean the colors move: We still refer to the buttons with the same number after a move.

You are given an initial board coloring, and a final one. Your goal is to find a minimal sequence of button presses that will turn the original board to the final one.

# Documentation

Colors we're allowed

## Instances

next :: SButton -> Grid -> Grid Source #

Given a button press, and the current grid, compute the next grid. If the button is "unpressable", i.e., if it is not one of the center buttons or it is currently colored black, we return the grid unchanged.

search :: [Color] -> [Color] -> IO () Source #

Iteratively search at increasing depths of button-presses to see if we can transform from the initial board position to a final board position.

A particular example run. We have:

`>>>`

Searching at depth: 0 Searching at depth: 1 Searching at depth: 2 Searching at depth: 3 Searching at depth: 4 Searching at depth: 5 Searching at depth: 6 Found: [10,10,11,9,14,6] Found: [10,10,9,11,14,6] There are no more solutions.`example`