omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / tasks / ludic-numbers / oracle.py
| 1 | # Independent reference for "Ludic numbers" (Python 3, standard library only). |
| 2 | # expected.txt is this program's stdout; omc never produced it. |
| 3 | lst = list(range(2, 22000)) |
| 4 | lud = [1] |
| 5 | while lst: |
| 6 | lud.append(lst[0]) |
| 7 | del lst[::lst[0]] |
| 8 | s = set(lud) |
| 9 | print("first 25 ludic numbers: " + " ".join(map(str, lud[:25]))) |
| 10 | print(f"ludic numbers <= 1000: {sum(1 for x in lud if x <= 1000)}") |
| 11 | print("2000th to 2005th ludic numbers: " + " ".join(map(str, lud[1999:2005]))) |
| 12 | print("ludic triplets (x, x+2, x+6) below 250: " + |
| 13 | " ".join(f"({x}, {x + 2}, {x + 6})" for x in lud if x + 6 < 250 and x + 2 in s and x + 6 in s)) |