Boggle is a board game where the players have to find English words on a 4-by-4 board of random alphabets. Words can be constructed by selecting sequentially adjacent cells on the board. ("adjacent" means horizontally, vertically or diagonally adjacent.) Also, same cell can't be used more than once in a word.
The following is an example board:
I L A W B N G E I U A O A S R L
On this board,
WEARS are valid words, but
RUSSIA are not:
SURGE: There's no adjacent pair on the board having
Scannot be used twice.
Modified Boggle is a modified version of Boggle, with the following rules:
- The board size is
ncan be any positive integer.
- Each cell can contain any one byte between 0 and 255 inclusive.
- A cell can be used more than once, but not twice in a row.
Using the example board above, in addition to
LANGUAGE becomes a valid string (since
G is used twice, but not twice in a row) but
RUSSIA is still not (due to
Here is another example using a code fragment. The string
from itertools import*\n can be found on the following board, but not
from itertoosl import* or
from itertools import *:
f i ' ' s r t m l e o o p \n * t r
Note that you need two
o's in order to match the
Write a function or program that, given a Modified Boggle board
B (of any size) and a string
s, determines if
s can be found on
Your code itself should also fit on a Modified Boggle board
b. That is, you must show the board
b in your submission along with your code, so that your function/program outputs true if it is given
b and your code as input.
The score of your submission is the side length of the smallest board
b where you can fit your code. Ties are broken by the usual code-golf rules, i.e. the length of your code in bytes. The submission with the lowest score (for both criteria) wins.
from itertools import*\n has the score of 4 (using the board above) and code length of 23 bytes.
Input and Output
For input, you can take any convenient method for both
s. This includes list of chars and list of charcodes, 2D or flattened or whatever makes sense. Also, you can optionally take the board size as a part of the input.
For output, you can choose one of the following:
- Truthy and falsy values following your language's convention, or
- One predefined value for true and false respectively.
Please specify your input/output method in your submission.