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. :)
the fly, the train, the second train, and their Zeno's paradox
Getting the absolute index from a matrix
Duplicate each element of a vector.
Sum the entries of each column of a matrix which satisfy a logical condition.
Assert yourself! Hack the assert function to pass this test.
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