Boggle
Statement
The Goal
In the classic game of Boggle you must look for words in a grid of 4 by 4 letters.Valid words are formed by starting on any letter, then moving on to any horizontally, vertically or diagonally adjacent letter in the grid. Each cell of the grid may be used only once.
Your program is given a letter grid and a list of candidate words. For each word your program must output whether the word can be found in the grid.
Input
4 lines: the letter grid
1 line: N the number of words to check
N next lines: one word to check
1 line: N the number of words to check
N next lines: one word to check
Output
N lines: true if the word can be formed, false otherwise.
Constraints
1<=N<=20
Example
Input
MPLR
DSDA
HNEO
SHTY
5
ARDENT
SHEAR
DOT
DEAD
YEAR
Output
true
true
true
false
true
Tags
Difficulty
Test cases
Test 1 Test
Input
MPLR
DSDA
HNEO
SHTY
5
ARDENT
SHEAR
DOT
DEAD
YEAR
Output
true
true
true
false
true
Validator 1 Validator
Input
ZCYE
QFQN
UARB
FUGL
5
NEQRAG
FURNE
QRNQ
QBG
LRNE
Output
true
true
false
true
true
Test 2 Test
Input
ETFI
BOKO
LDIR
SMHA
7
GIANT
IDOLS
BOLD
SMIRK
RIM
DOE
SNAIL
Output
false
true
true
true
true
true
false
Validator 2 Validator
Input
FUGJ
CPLP
MEJS
TNIB
7
JEPMT
HJBOU
CPME
TNJSL
SJN
EPF
TOBJM
Output
true
false
true
true
true
true
false
Test 3 Test
Input
SALE
EUBL
ROTO
YAGN
7
ALL
YOUR
BASE
ARE
BELONG
TO
US
Output
true
true
true
true
true
true
true
Validator 3 Validator
Input
UCNG
GWDN
TQVQ
ACIP
7
CNN
AQWT
DCUG
CTG
DGNQPI
VQ
WU
Output
true
true
true
true
true
true
true
Test 4 Test
Input
ODUT
ICGS
HNAL
CEMR
9
CODINGAME
ROCKS
STAR
TSAR
RAMEN
FISH
CODE
CINEMAS
GALA
Output
true
false
false
true
true
false
false
true
false
Validator 4 Validator
Input
RGXW
LFJV
KQDO
FHPU
9
FRGLQJDPH
URFNV
VWDU
WVDU
ILVK
UDPHQ
FRGH
FLQHPDV
JDOD
Output
true
false
false
true
false
true
false
true
false
Solution language
Solution
Stub generator input