I got to wondering yesterday if I could write a program to comb through a given word search and output the answers. It was actually surprisingly easy. Now I wonder just how small we can get.
- Your first input is a string or collection of n lines, each of which is n characters long
- Your second input is a list of words in any format to find in the puzzle
- All words in the search list are guaranteed to be in the puzzle
- Words can be oriented in any of the four cardinal directions, as well as diagonally both forwards and backwards
- Only uppercase A-Z characters will be present in the puzzle
- Your code must find every word in the the search string, and output the coordinate position of the starting letter, where 0,0 is the top left character.
- In the event that you locate more than one instance of the same word, you may handle it however you like. Output it multiple times, or only once, it's up to you
Given the following board:
ABCD EFGH IJKL MNOP
And the following search string:
Your program should output the following, in any order:
ABCD at 0,0 CGKO at 0,2 PONM at 3,3 NJF at 3,1 AFKP at 0,0 CFI at 0,2 LGB at 2,3 MJGD at 3,0
As always, shortest answer wins