(This is part 1 in a two-part challenge.)
Your task is to solve a Hexasweep puzzle.
A Hexasweep puzzle is set out on a grid of diamonds arranged in hexagonal shapes, of which the board looks like a hexagon, like so:
_____
/\ \
_____/ X\____\_____
/\ \ / XX /\ \
/X \____\/____/X \____\
\ X/ XX /\ \ X/ /
\/____/ \____\/____/
/\ \ / X /\ \
/ \____\/____/ \____\
\ / XX /\ \ / XX /
\/____/ \____\/____/
\ X/ /
\/____/
The above image is composed of 7 hexagons (21 diamonds), and is thus a Hexasweep puzzle of size 2.
If you want to expand it, cover the current Hexasweep puzzle with more hexagons (so that there are 19 hexagons - that will make a Hexasweep puzzle of size 3).
The same goes for the other direction - to make a Hexasweep puzzle of size 1, remove the outermost layer of hexagons (so that there's 1 hexagon).
Each diamond can contain 0, 1 or 2 "bombs", with bombs depicted as X
above. With bombs filled out, this is the final solution.
Numbers are marked on "intersection points", to show how many bombs are on the diamonds which are touching those intersection points - the intersection points of this grid are shown below using O
.
_____
/\ \
_____/ OO___\_____
/\ \ OO /\ \
/ OO___OO___OO OO___\
\ OO OO OO OO /
\/___OO OO___OO____/
/\ OO OO OO \
/ OO___OO___OO OO___\
\ OO OO OO OO /
\/____/ OO___\/____/
\ OO /
\/____/
As you can see, there are two "types" of intersection points - those with 3 diamonds touching it, and those with 6 (the one that are touching the edge of the board aren't counted):
_____
/\ XX\
/X OO___\
\ XOO /
\/____/
/\
_____/X \_____
\ XX \ X/ /
\____OO____/
/ XX OO X \
/____/ \____\
\ X/
\/
The two intersections would be marked with 4
and 8
respectively.
In the original Hexasweep puzzle above, the intersection numbers would be:
3
4 5 4 2
2 1 3
2 4 1 2
1
Which would be condensed to:
3,4,5,4,2,2,1,3,2,4,1,2,1
Given an input in this "condensed form", you must output the original puzzle, in "condensed form" (see above).
The solved image (the first one, with the crosses) - which would be formed from the puzzle - would be read from top to bottom, starting from the left:
2,0,0,2,0,2,1,0,1,0,2,0,1,0,0,2,0,0,0,0,2
That is now the "condensed form" of the puzzle.
If there is more than 1 answer (as in the condensed form above), the output must be N
.
Examples:
0,0,4,3,1,3,4,7,1,4,3,6,1 -> 0,0,0,0,1,0,0,2,0,0,0,2,0,1,0,1,2,0,0,2,2 (size 2 Hexasweep)
6 -> 2,2,2 (size 1 Hexasweep)
0,1,5,3,1,4,4,7,2,5,3,6,1 -> N (multiple solutions)
Specs:
- Any delimiter for the "condensed form" as input are allowed (it doesn't have to be
,
separating the numbers). - You may output a list, or a string with any delimiter.
- Your program must be generalised: it must be able to solve Hexasweep puzzles of any size (at least from size 1 to size 4).
This is code-golf, so lowest amount of bytes wins!