After a day of drinking and watching the world cup, you sit down to play friendly game of boggle. Tempers rise as you are accused of wasting everyone's time with nonsense words that aren't even on the board! You may be seeing double, but surely you're thinking straight enough to write a program that will verify that your words are on the board.
Write a program, script, or function that takes a boggle board and a word as input, and returns True if the word is on the board and False if the word isn't.
The input will be in the form of six
\n delimited lines. The first five lines will comprise the 5x5 boggle board and will each contain five capital letters. The sixth line will contain the word-in-question, also in all capital letters.
AJNES TNFTR LSAIL UDNEX EQGMM DAFTER
The output can be anything that unambiguously signifies True or False in your programming language of choice and adheres to standard conventions of zero, null, and empty signifying False.
Sample output for above input:
- The input may be read from stdin, and answer output to stdout.
- The input may be a single string argument to a function, and answer be the return value of that function.
- A word is 'on the board' if you can construct the word via a path of consecutive, adjacent, non-repeating tiles on the board.
- A tile is considered adjacent to the eight tiles that surround it (diagonal paths are allowed). Tiles on the edge of the board are adjacent to only five tiles. Tiles in the corner are adjacent to only three.
- Consecutive letters in the word must be adjacent, the
ith letter in the word must be adjacent to the
- A letter may appear in a word more than once, but you cannot use the same square on the boggle board more than once per word.
- The online boggle site wordsplay.net may be useful if you have never played boggle before, but want to get a feel for these rules.
Unlike regular boggle:
- You do NOT have to worry about the word being a valid English word.
- There will be NO
- The word-in-question may be of any length > 0
On the board of
AJNES TNFTR LSAIL UDNEX EQGMM
These words should return True: FATE, DATING, STANDS, LIFTS.
These words should return False: SADDEN, SULTANS, EXIST, SUEDE, QUEST
This is a code-golf challenge, so shortest code wins!