Interesting and fun problem! How about a test case with 'Waldo' hiding in an antidiagonal, or in reverse order in a diagonal?
"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.
Bottles of beer
Convert a vector into a number
Create a vector whose elements depend on the previous element
Sums of Distinct Powers
Assert yourself! Hack the assert function to pass this test.
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office