Problem 44208. Where's Waldo?
Find the string 'Waldo' in the character matrix given and return the indices of where you found him as a 4x2 matrix where the elements reflect the row, column pairings of each letter in Waldo's name, starting with 'W'. Waldo will be hidden in various ways, e.g. 'odlaW', 'waldo', so be sure to look closely.
Example 1
picture = ['QGxOe' 'dMWdg' 'Waldo']
waldoInd = [3 1 3 2 3 3 3 4 3 5]
Example 2
picture = ['WLvJC' 'oDlaw' 'dMWdg']
waldoInd = [2 5 2 4 2 3 2 2 2 1]
Example 3
picture = ['WFBlS' 'DAlzQ' 'pjLTo' 'xnaDF' 'YgYRO'];
waldoInd = [1 1 2 2 3 3 4 4 5 5]
Solution Stats
Problem Comments
-
7 Comments
Interesting and fun problem! How about a test case with 'Waldo' hiding in an antidiagonal, or in reverse order in a diagonal?
Nice problem!
"Waldo" can be hidden in reverse diagonals as well. The test suite generates a random configuration each time, so it just depends on your luck (or unluck) of where he is actually placed, and in which direction.
But test 4 in the test suite uses the line 'colDir = 1-rowDir', which means that it randomly places "Waldo" either horizontally or vertically, but never along diagonal direction (forward nor reverse), nor along anti-diagonal direction. One way to include those possibilities, would be to set 'colDir = 1', followed later by an extra 'flip(pb)' and/or 'transpose(pb)' randomly. However, still a very nice problem!
@yurenchu I see what you mean! I added another test suite to cover this now. Thanks!
Trivially, the answer should be given in a 5x2 matrix, not a 4x2. :)
I recommend adding to the description that Waldo must have all its letters following the same orientation (horizontal, vertical or diagonal) because there are other ways to find waldo when orientation is not an issue.
Solution Comments
Show commentsProblem Recent Solvers13
Suggested Problems
-
2270 Solvers
-
Project Euler: Problem 7, Nth prime
1427 Solvers
-
159 Solvers
-
212 Solvers
-
Is this a valid Tic Tac Toe State?
118 Solvers
More from this Author2
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!