Battleships solver (explanation of puzzle). Solving in fdq. By Peter van der Zee, © qfox.nl, September 2017.

Given a 10x10 grid, fit some ships of certain sizes and make sure they don't touch each other, not even diagonally. Numbers to the side indicate how many boat pieces occur in that row or column.

Cell value legend: 0=water, 1=horizontal mid section, 2=vertical mid-section, 8=1 or 2, 3=top of vertical boat, 4=right of horizontal boat, 5=bottom of vertical boat, 6=left of vertical boat, 7=1x1 boat. Press load buttons for examples:)

(Trying to load library)










Required boat counts:

-
- ◀ ▶
- ◀ ◼ ▶
- ◀ ◼ ◼ ▶

Input dsl:

Output:

Import:
Export:

Note: Solving won't work in Edge and Safari until they support TextEncoder (or when the standards committee grace us with a simpler method of converting string to Uint8Array, whichever comes first).

Firefox ... sometimes works. It seems to handle Uint8Array slightly different from v8 which might cause binary desyncs :'( ymmv