Elektrine lite

← Feed

@KeyJ@mastodon.gamedev.place

Post #2104118

2026-03-31 11:32 UTC

@simontatham My attempt at a 32-bit formatter: def fmt(x): x &= 0xFFFFFFFF r = [str(x)] if x >= 16: r.append(hex(x)) if x >= 1 << 31: x -= 1 << 32 r.append(str(x)) if x <= -16: r.append(hex(x)) return min(r, key=lambda x: (len(set(x.replace("0x","x"))), len(x.strip("-")))) for x in (0, 17, 257, 4097, 9999994, 100002, 0x7FFFFD, 0x55555, -294967296, -1, -10, -100, -0x555, 1<<29): print(fmt(x)) Lots of weird heuristics though, still passes neither 12345678 nor 0xDEADBEEF.

Replies (0)

No replies.