StyleInCode

RSS

 

Wonderland Number

12 February 2025

A solution to the Wonderland Number Kata described at Awesome Katas.

Solution

""" wonderland_number.py """

# usage: python3 wonderland_number.py


def anagram(x, y):
    """ x number anagram of y """
    return sorted(str(x)) == sorted(str(y))


constants = [2, 3, 4, 5, 6]

for i in range(100000, 1000000 // max(constants) + 1):
    if all(anagram(i, k * i) for k in constants):
        print(i)

Categories

Links