Skip to content

Where's Waldo Problem

Given a 1-million element array where each element is a random character in a-z, identify the starting index of every sequence of characters that spells ‘waldo’. Include sequences where at least 4 of the 5 characters match (e.g. ‘waldo’, 'wafdo', and ‘xaldo’ but not ‘wadlo’).

import numpy as np
import string

generator = np.random.default_rng(123)
chars = generator.choice(list(string.ascii_lowercase), size=10**6, replace=True)

# ['a' 'r' 'p' 'b' 'x' 'f' 'g' 'e' 'i' 'e']

Try with Google Colab