← Back to challenges

Where's Waldo?

PythonHardarraysfunctional_programming

Instructions

Return the coordinates ([row, col]) of the element that differs from the rest.

Examples

where_is_waldo([
  ["A", "A", "A"],
  ["A", "A", "A"],
  ["A", "B", "A"]
]) ➞ [3, 2]

where_is_waldo([
  ["c", "c", "c", "c"],
  ["c", "c", "c", "d"]
]) ➞ [2, 4]

where_is_waldo([
  ["O", "O", "O", "O"],
  ["O", "O", "O", "O"],
  ["O", "O", "O", "O"],
  ["O", "O", "O", "O"],
  ["P", "O", "O", "O"],
  ["O", "O", "O", "O"]
]) ➞ [5, 1]

Notes

  • The given list will always be a square.
  • Rows and columns are 1-indexed (not zero-indexed).
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.