DEV Community

Discussion on: Anagrams Checker - Three JavaScript Solutions

Collapse
 
_bigblind profile image
Frederik 👨‍💻➡️🌐 Creemers

Here's an O(∞) solution inspired by bogosort. If it halts, a and b are anagrams.

def anagrams(a, b):
    while True:
        b = str(random.shuffle(b))
        if a == b:
            return True
Enter fullscreen mode Exit fullscreen mode