grid holds one lowercase English letter per cell, and dictionary is a list of words. A word counts as found if you can trace it on the board: start at any cell and take each next letter from a cell that shares a side with the previous one (up, down, left or right). Diagonal moves are not allowed, and a single word may not use the same cell twice.
Return every word from dictionary that can be traced on the board. List each found word once, in any order.grid=[['c', 'a', 't'], ['x', 'r', 'o'], ['d', 'o', 'g']], dictionary=['cat', 'car', 'rod', 'dog', 'tar', 'cart'] → ['cat', 'car', 'tar', 'rod', 'dog']
cat runs along the top row, car goes right then down, dog runs along the bottom row, rod goes down from r and then left, and tar goes left from t and then down. cart fails: no t touches the r.
grid=[['a', 'b'], ['b', 'a']], dictionary=['aba', 'abab', 'aa'] → ['aba', 'abab']
aba and abab walk around the square. For aa the two a cells would have to touch, but they sit diagonally.
grid=[['z']], dictionary=['zz'] → []
A cell cannot be reused, so a single z cannot spell zz.
grid[i][j] is a lowercase English letterdictionary are distinctgrid=[['c', 'a', 't'], ['x', 'r', 'o'], ['d', 'o', 'g']], dictionary=['cat', 'car', 'rod', 'dog', 'tar', 'cart']
['cat', 'car', 'tar', 'rod', 'dog']
Run checks the first 3 tests in your browser. Submit checks all 75 tests on the server, hidden ones included.