9
\$\begingroup\$

Given a list of case-insensitive ASCII letter strings ("words"), output whether the entire list can be found on some four-by-four configuration ("board") of letter squares, in which no square can be used more than once in a word, and in which words are formed by moving from any square to any adjacent square including diagonally.

You do not need to worry that the combination of squares that would allow for the list actually appears in a Boggle game. The words need not be actual words in any language. You should assume that if Q appears on the board, it's on a square of its own (unlike in actual Boggle).

Standard loopholes are banned, standard I/O rules apply, and you're golfing.


In the examples below, a slash signifies a newline.

Truthy examples

  • auuuuooiiaaoiee, euiaaiueeuua, ooouuueee, eueueuoaoa — All are on the board auii/euoa/ueoa/euio
  • swiop, byteba, ceropl, qoiz, aeis, lqoep — All are on the board abcb/rety/poiw/lqzs

Falsy examples

  • swiop, byteba, ceropl, qoiz, aeis, lqoep, wybez — There are fifteen distinct letters (abceilopqrstwyz) and a single word has two bs, so that's the sixteenth square. Thus there's only one e. But the e has nine distinct letters (abcioprtz) adjacent to it, which is impossible.
  • hskcbnzvgfa, lajdnzvfhgs, kajfbmxvshd, ldgckvbsanx — There are sixteen distinct letters (abcdfghjklmnsvxz). Of those, s is adjacent to all of abghkv, v is adjacent to all of bfgksxz, b is adjacent to all of cfmnsv, a is adjacent to all of fjklns, and f is adjacent to all of abghjv. But on an actual board only four squares are adjacent to more than five squares apiece.
\$\endgroup\$
  • 6
    \$\begingroup\$ I can understand the challenge clearly and unambiguously. If anyone disagree (and VTC as unclear), consider leaving a comment. \$\endgroup\$ – user202729 Apr 29 '18 at 2:02
  • 1
    \$\begingroup\$ I wonder if it would be better suited for fastest-code or fastest-algorithm. As code-golf, it may lead to brute-force solutions that run forever and never actually return anything. \$\endgroup\$ – Arnauld Apr 29 '18 at 10:30
  • 1
    \$\begingroup\$ You'd need to define what brute-force exactly means. But even so, I'm not sure it's a good idea. A very clever answer may still use brute-force in some way. \$\endgroup\$ – Arnauld Apr 29 '18 at 11:39
  • 4
    \$\begingroup\$ Besides that, I too think that the challenge is clearly defined. So, people that have VTC really should share their thoughts. \$\endgroup\$ – Arnauld Apr 29 '18 at 11:42
  • 3
    \$\begingroup\$ As far as I can see, in general this is a subgraph problem, which is NP complete, so all non-magical answers will need some degree of brute force. \$\endgroup\$ – Phil H May 1 '18 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.