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": "f2f692d6aa2e9cf7bcac80f4c43cee57638bf7581420e2ac554140001b7260f1",
"pubkey": "8b43e134ed66eccdb6ceb8acbeb01a61b39ad84bb6e0db19723e9cb1de69ee4b",
"created_at": 1790586944,
"kind": 1,
"tags": [
[
"proxy",
"https://mathstodon.xyz/@robinhouston/117347906022550797",
"web"
],
[
"proxy",
"https://mathstodon.xyz/users/robinhouston/statuses/117347906022550797",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://mathstodon.xyz/users/robinhouston/statuses/117347906022550797",
"pink.momostr"
],
[
"-"
]
],
"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": "be35b655f9aabdcb7422fa2d7ec7ef6ae3337034fc84d8f3cd285598aefd90e56d388c4f50d5f9218d14077badb34c5683778199458e494769c49949b33f47b2"
}