$ cat writeup.md…
$ cat writeup.md…
sekai2026
Task: a Python one-line assertion constrains a SEKAI flag to 67 digits of 6/7 and a divisibility test. Solution: parse precedence, reduce the modulus to 2^67-1, and solve the byte subset directly.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
how hard can six seven be assert import('re').match('SEKAI{[67]{67}}$',flag:=input()) and not int.from_bytes(flag.encode())%~(6+~7)**67
English summary: the challenge gives a single Python assertion. The input must match the flag format SEKAI{[67]{67}}, and the big-endian integer representation of the flag must be divisible by the value produced by the final Python expression.
The important part is parsing the Python expression correctly:
int.from_bytes(flag.encode()) % ~(6 + ~7) ** 67
Python exponentiation binds tighter than unary bitwise NOT in this context, so the modulus is:
~((6 + ~7) ** 67)
Now:
~7 = -86 + ~7 = -2(-2) ** 67 = -2^67~(-2^67) = 2^67 - 1So the divisibility condition is:
int.from_bytes(flag.encode(), "big") == 0 mod (2^67 - 1)
The regex fixes the prefix and suffix and leaves exactly 67 variable body bytes, each either ASCII 6 or ASCII 7.
Let:
base = int.from_bytes(b"SEKAI{" + b"6"*67 + b"}", "big") M = 2^67 - 1
Changing a body character from 6 to 7 increases that byte by exactly 1, therefore it adds one power of 256 to the big-endian integer. We need to select positions whose weights sum to -base mod M:
base + sum(selected 256^k) == 0 mod M
Since 256 = 2^8 and gcd(8, 67) = 1, the powers of 256 modulo 2^67 - 1 permute the 67 single-bit weights. That means this subset selection is not a hard subset-sum problem: the target residue directly tells us which positions must be changed to 7.
The following solver starts from the all-6 baseline, computes the required residue, and changes exactly the body positions whose modulo weight appears in that residue.
#!/usr/bin/env python3 import re ...
$ grep --similar