Solve a Word Search!
+4
−0
Challenge
Given a two-dimensional array of characters and a list of words, output the location of the words. Words can go either vertically top to bottom, horizontally left to right, or diagonally top-left to bottom-right.
Output can be given as either the start and endpoint of the array or the start, direction, and length.
It can be assumed that the words all exist in the grid.
Examples
Words: HELLO, WORLD
Crossword:
ADNOW
HELLO
SDFFR
WOSAL
ANDHD
Output: ((1, 0), (1, 4)), ((0, 4), (4,4)
Questions
-
Is it better to just ask for the location of one word? A list of words doesn't seem particularly interesting, since you'd basically just iterate over the list.
-
Does including diagonals make it too complicated?
-
Any other input/output formats that should be allowed?
1 comment thread