robinhouston on Nostr: For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as ...
For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.
I find it rather amazing that this is possible!
This is the program he sent with the seed:
with open("seed.txt", encoding="ascii") as handle:
seed = int(handle.read().strip(), 0)
r = random.Random(seed)
pending = ""
while True:
character = chr(r.randrange(128))
if pending + character == "\x1e\x1f":
break
print(pending, end="")
pending = character
print()
Published at
2026-09-28 09:15:44 UTCEvent JSON
{
"id": "d1ec077e7c1583a10e47095a7c78ef5912d6407a956dd1f2534df802293491e3",
"pubkey": "74b1555a7487541cd9f7a21244387054343f6083f7d5bf867da28a1b2525f485",
"created_at": 1790586944,
"kind": 1,
"tags": [
[
"proxy",
"https://mathstodon.xyz/users/robinhouston/statuses/117347906022550797",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub"
]
],
"content": "For my birthday, my brother-in-law gave me a 4992-digit hex number that, when used as a seed for Python’s random number generator, makes it so that printing a sequence of “random” ASCII characters actually prints a birthday greeting.\n\nI find it rather amazing that this is possible!\n\nThis is the program he sent with the seed:\n\nwith open(\"seed.txt\", encoding=\"ascii\") as handle:\n seed = int(handle.read().strip(), 0)\nr = random.Random(seed)\npending = \"\"\nwhile True:\n character = chr(r.randrange(128))\n if pending + character == \"\\x1e\\x1f\":\n break\n print(pending, end=\"\")\n pending = character\nprint()",
"sig": "5243bbb467e1200440a7ca26fa1cd13c9bf6bb5c5bd40ef3d6fd4ee842a8b9e07021dcb5577074a87bc8a72fd18e156b44db4573ec35f366caff754f3c384093"
}