Ad
Code
Diff
  • class hello:...
    class world:...
    class A:...
    class a:...
    
    def cursed_world():
        space = chr(ord(a.__name__) - ord(A.__name__))
        return hello.__name__ + space + world.__name__
    • import random
    • import string
    • class hello:...
    • class world:...
    • class A:...
    • class a:...
    • def cursed_world():
    • target = "hello world"
    • letters = [random.choice(string.ascii_lowercase + ' ') for _ in range(11)]
    • generation = 0
    • while True:
    • generation += 1
    • score = sum(letters[i] == target[i] for i in range(11))
    • if score == 11:
    • return "".join(letters)
    • new_letters = letters[:]
    • for i in range(11):
    • if new_letters[i] != target[i]:
    • if random.random() < 0.3:
    • new_letters[i] = random.choice(string.ascii_lowercase + ' ')
    • letters = new_letters
    • space = chr(ord(a.__name__) - ord(A.__name__))
    • return hello.__name__ + space + world.__name__

One can just count how many of each letter and union with the minimum letter value.

Code
Diff
  • def duck_duck(a):
        chars = {i: a.count(i) for i in "duck"}
        return chars | {"ducks": min(chars.values())}
    • def duck_duck(a):
    • return
    • chars = {i: a.count(i) for i in "duck"}
    • return chars | {"ducks": min(chars.values())}