def mystery(x):
# Accepts a str (or ASCII-only bytes/bytearray) and returns a boolean.
if isinstance(x, (bytes, bytearray)):
b = bytes(x)
elif isinstance(x, str):
# Reject anything that isn't plain ASCII to prevent UTF-8 multi-byte tricks.
try:
b = x.encode("utf-8")
except Exception:
return False
if any(ch >= 0x80 for ch in b):
return False
else:
return False
n = 12
if len(b) != n:
return False
# Small obfuscations for constants.
rot = (1 << 1) + 1 # 3
seed = int("a7", 16) # 0xA7
step = int("49", 16) # 73
mul = 0x1D # 29
add = 0x3D # 61
def rotl(v, r):
v &= 0xFF
return ((v << r) & 0xFF) | (v >> (8 - r))
# Expected output (12 bytes) packed into an integer to avoid a visible list literal.
expect = (0x99F38E09DC54C18E22D8EFBC).to_bytes(n, "big")
out = bytearray(n)
for i in range(n):
k = (seed + step * i) & 0xFF
m = (mul * i + add) & 0xFF
t = (((b[i] + k) & 0xFF) ^ m) & 0xFF
out[i] = rotl(t, rot)
# Extra (mostly redundant) “noise” checks.
if (out[0] ^ out[-1]) == 0:
return False
if (sum(out) & 0xF) != (sum(expect) & 0xF):
return False
return bytes(out) == expect
def mystery(x):
if not isinstance(x, str):
return False
n = (0b111) # Length requirement
if len(x) != n:
return False
# Check all characters are digits
for ch in x:
if not ('0' <= ch <= '9'):
return False
# Convert to int list
vals = [ord(c) - ord('0') for c in x]
# Obfuscated target sum
target_sum = (0x30 - 0x03)
if sum(vals) != target_sum:
return False
# Check center position
mid = n >> 1
if vals[mid] != (0x12 >> 1):
return False
# Check symmetric properties with XOR obfuscation
a = 0x0F ^ 0x05
b = 0x0F ^ 0x03
c = 0x0F ^ 0x01
if vals[0] + vals[-1] != a:
return False
if vals[1] + vals[-2] != b:
return False
if vals[2] + vals[-3] != c:
return False
return True
def mystery(x):
# Accept either a str or bytes-like. Everything else rejected.
if isinstance(x, str):
try:
b = x.encode("utf-8")
except Exception:
return False
elif isinstance(x, (bytes, bytearray, memoryview)):
b = bytes(x)
else:
return False
# Enforce strictly printable ASCII to avoid Unicode tricks.
if any(c < 0x20 or c > 0x7E for c in b):
return False
n = (0x1F ^ 0x0F) # 16
if len(b) != n:
return False
def rol8(v, r):
v &= 0xFF
r &= 7
return ((v << r) & 0xFF) | (v >> (8 - r))
# "Hidden" expected 16 bytes stored as an integer masked with 0xA5..A5.
mask_int = int("a5" * n, 16)
hidden = int("f920a85b6474e08956c6b023e3c015d3", 16)
expect = (hidden ^ mask_int).to_bytes(n, "big")
out = bytearray(n)
# Fixed permutation, but not written as a literal list.
# perm[i] = (5*i + 1) mod 16
for i in range(n):
p = (5 * i + 1) & (n - 1) # since n is 16
v = b[p]
# Per-position "bias" and "key" (simple-looking, but annoying to track by eye).
a = (0xA7 + 73 * i) & 0xFF
d = (0x3D + 29 * i) & 0xFF
k = (a ^ d) & 0xFF
m = (((0x5A ^ (11 * i)) + (i << 2)) & 0xFF)
r = ((3 * i + 1) % 7) + 1 # 1..7
t = (v + m) & 0xFF
t ^= k
out[i] = rol8(t, r)
# Extra consistency check to add noise (but doesn't change the solution set).
if ((sum(out) ^ 0x2D) & 0x7F) != ((sum(expect) ^ 0x2D) & 0x7F):
return False
return bytes(out) == expect
def mystery(x):
if not isinstance(x, str):
return False
try:
data = x.encode('ascii')
except:
return False
# Only printable ASCII
if any(b < 0x20 or b > 0x7E for b in data):
return False
# Length requirement (obfuscated)
req_len = (0b1101) # 13
if len(data) != req_len:
return False
def transform_byte(byte_val, position):
# Position-dependent key generation
key1 = (0x9D + position * 29) & 0xFF
key2 = (0x47 - position * 19) & 0xFF
# XOR with first key
temp = (byte_val ^ key1) & 0xFF
# Bit rotation (left for odd positions, right for even)
shift_amount = (position % 6) + 1
if position & 1:
temp = ((temp << shift_amount) | (temp >> (8 - shift_amount))) & 0xFF
else:
temp = ((temp >> shift_amount) | (temp << (8 - shift_amount))) & 0xFF
# Add second key and position factor
temp = (temp + key2 + (position << 2)) & 0xFF
return temp
# Apply transformation to each byte
output = bytes([transform_byte(data[i], i) for i in range(req_len)])
# Expected output (obfuscated as individual bytes to avoid obvious hex string)
parts = [0xE7, 0x5C, 0xA3, 0x1F, 0xD8, 0x94, 0x2B, 0xC6, 0x71, 0x0E, 0xF5, 0x8A, 0x39]
expected = bytes(parts)
# Additional noise check
if (sum(output) & 0x3F) != (sum(expected) & 0x3F):
return False
return output == expected
def mystery(x):
# Accept either a non-negative int or a digit string.
if isinstance(x, bool):
return False
if isinstance(x, int):
if x < 0:
return False
s = str(x)
elif isinstance(x, str):
s = x
else:
return False
# Length + digit-only
n = (1 << 3) + 3 # 11
if len(s) != n:
return False
o0 = ord('0')
ds = []
for ch in s:
v = ord(ch) - o0
if v < 0 or v > 9:
return False
ds.append(v)
# A little "noise" check (still constraining, but not obviously helpful)
if sum(ds) != ((0x66) ^ (0x55)): # 0x66 ^ 0x55 = 0x33 = 51
return False
# Check 1: weighted cubic sum mod 101
mod1 = 101
acc1 = 0
for i, d in enumerate(ds):
coeff = pow(i + 3, 3, mod1) # (i+3)^3 mod 101
acc1 = (acc1 + d * coeff) % mod1
if acc1 != (0x25 ^ 0x04): # 33
return False
# Check 2: shifted geometric sum mod 103
mod2 = 103
acc2 = 0
p = 1
for i, d in enumerate(ds):
# p == 7^i (mod 103), updated each iteration
acc2 = (acc2 + (d + 1) * p) % mod2
p = (p * 7) % mod2
if acc2 != (0x5E - 0x35): # 41
return False
# Check 3: adjacent products mod 97
mod3 = 97
acc3 = 0
for a, b in zip(ds, ds[1:]):
acc3 = (acc3 + a * b) % mod3
if acc3 != (0x2F ^ 0x03): # 44
return False
# Check 4: product of (digit+1) mod 97
prod = 1
for d in ds:
prod = (prod * (d + 1)) % mod3
if prod != (0x1A ^ 0x0D): # 23
return False
# Check 5: base-11 rolling hash mod 127
h = 0
for d in ds:
h = (h * 11 + d) % 127
if h != (0x27 - 0x15): # 18
return False
# Check 6: parity bitmask of digits (odd/even), packed into an int
pm = 0
for i, d in enumerate(ds):
pm |= (d & 1) << i
if pm != (0x55 ^ 0x13): # 70
return False
# Check 7: a Luhn-like checksum, but with a nonstandard target residue
total = 0
for idx, d in enumerate(reversed(ds)):
if idx & 1:
t = d * 2
total += t - 9 if t > 9 else t
else:
total += d
if (total % 10) != ((12) - (7)): # 5
return False
# Check 8: decimal remainder mod 10007 without ever calling int(s)
r = 0
for ch in s:
r = (r * 10 + (ord(ch) - o0)) % 10007
if r != (0xF00 - 0xD8): # 3624
return False
return True
def mystery(x):
# Accept string or int
if isinstance(x, bool):
return False
if isinstance(x, int):
if x < 0:
return False
s = str(x)
elif isinstance(x, str):
s = x
else:
return False
# Length check (obfuscated)
req_len = (0b1111) - 2 # 13
if len(s) != req_len:
return False
# Must be all digits
for ch in s:
if not ('0' <= ch <= '9'):
return False
digits = [int(ch) for ch in s]
# Check 1: Sum constraint (obfuscated)
target_sum = (0xDE >> 2) # 55
if sum(digits) != target_sum:
return False
# Check 2: Weighted sum mod prime
mod1 = (0x65 | 0x18) + 2 # 127
weighted = 0
for i, d in enumerate(digits):
coeff = pow(i + 2, 2, mod1) # (i+2)^2 mod 127
weighted = (weighted + d * coeff) % mod1
if weighted != (0x4B ^ 0x12): # 89
return False
# Check 3: Product of (digit+1) mod different prime
mod2 = 109
prod = 1
for d in digits:
prod = (prod * (d + 1)) % mod2
if prod != ((0x33 << 1) - 0x1A): # 76
return False
# Check 4: Alternating sum
alt_sum = sum(digits[i] if i % 2 == 0 else -digits[i] for i in range(req_len))
if alt_sum != (0x17 - 0x10): # 7
return False
# Check 5: Polynomial hash mod 1021
mod3 = 1021
poly_hash = 0
for d in digits:
poly_hash = (poly_hash * 11 + d) % mod3
if poly_hash != (0x2A0 - 0x12): # 658
return False
# Check 6: Adjacent products sum
adj_prod_sum = sum(digits[i] * digits[i+1] for i in range(req_len - 1))
if adj_prod_sum != (0xF8 | 0x07): # 255
return False
# Check 7: Digit position parity mask
parity_mask = 0
for i, d in enumerate(digits):
if d % 2 == 1:
parity_mask |= (1 << i)
if parity_mask != (0x1AAA >> 1): # 3413
return False
# Check 8: Cumulative XOR chain
xor_chain = 0
for i, d in enumerate(digits):
xor_chain ^= (d << (i % 4))
if xor_chain != (0x7C ^ 0x3B): # 71
return False
return True
def mystery(x):
# Accept strictly an ASCII string.
if not isinstance(x, str):
return False
try:
b = x.encode("ascii")
except Exception:
return False
n = 16
if len(b) != n:
return False
if any(c < 0x20 or c > 0x7E for c in b):
return False
# Small decoy constraints (must be satisfied too).
sx = 0
for c in b:
sx ^= c
if sx != 0x78:
return False
if (sum(b) % 97) != 8:
return False
def rol8(v, r):
v &= 0xFF
r &= 7
return ((v << r) & 0xFF) | (v >> (8 - r))
# Byte-mixer (bijective), applied to both the input-derived block and the hidden block.
def scramble(block16: bytes) -> bytes:
s = bytearray(block16)
for r in range(5):
# non-linear-ish, but reversible: xor + rotate + add (all per-byte)
for i in range(n):
k = ((0x9D + 41 * r + 17 * i) ^ (0xC3 - 13 * i + 7 * r)) & 0xFF
v = s[i] ^ k
v = rol8(v, ((3 * i + r) % 7) + 1) # 1..7
v = (v + (0x37 + (i + 1) * (r + 3))) & 0xFF
s[i] = v
# permutation (also bijective)
t = s[:]
step = (5 + 2 * r) & 0xF # always odd -> invertible mod 16
off = (1 + 3 * r) & 0xF
for i in range(n):
s[i] = t[(step * i + off) & 0xF]
return bytes(s)
# Build a 16-byte block from x with a hidden permutation and a position-dependent mask.
v = bytearray(n)
for i in range(n):
p = (7 * i + 3) & 0xF
mask = (0x33 + 17 * i) & 0xFF
v[i] = b[p] ^ mask
out = scramble(bytes(v))
# Hidden 16-byte reference, stored as an int XORed with 0xA5..A5 (to avoid a visible bytes literal).
mask_int = int("a5" * n, 16)
blob = int("fdb5a9fba840645d2a5e0b3b1484b6e1", 16)
ref = (blob ^ mask_int).to_bytes(n, "big")
target = scramble(ref)
# Redundant “noise” check.
if (sum(out) ^ 0xC7) & 0x3F != (sum(target) ^ 0xC7) & 0x3F:
return False
return out == target
def mystery(x):
if not isinstance(x, str):
return False
try:
data = x.encode("ascii")
except:
return False
# Length check (obfuscated)
n = (0b10000) # 16
if len(data) != n:
return False
# Only printable ASCII
if any(b < 0x20 or b > 0x7E for b in data):
return False
def ror8(v, r):
"""Rotate right 8-bit value"""
v &= 0xFF
r &= 7
return ((v >> r) | (v << (8 - r))) & 0xFF
def rol8(v, r):
"""Rotate left 8-bit value"""
v &= 0xFF
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
# Transform each byte
result = bytearray(n)
for i in range(n):
# Read from permuted position: (13*i + 5) mod 16
pos = (13 * i + 5) & 0xF
val = data[pos]
# First key (increases with position)
k1 = (0x7B + i * 19) & 0xFF
val ^= k1
# Rotation (alternates based on position)
if i & 1:
val = rol8(val, ((i >> 1) & 3) + 2)
else:
val = ror8(val, ((i >> 1) & 3) + 2)
# Second key (decreases with position)
k2 = (0x3F - i * 5) & 0xFF
val = (val + k2) & 0xFF
# XOR with position-dependent mask
val ^= ((i * 7 + 11) & 0xFF)
result[i] = val
# Expected output (obfuscated as integer XORed with mask)
mask = int("5a" * n, 16)
hidden = int("b04e9c3a286fd1b5e7a549fc8d2e10a4", 16)
expected = (hidden ^ mask).to_bytes(n, "big")
# Noise check
if (sum(result) ^ 0x9D) & 0x7F != (sum(expected) ^ 0x9D) & 0x7F:
return False
return result == expected
def mystery(x):
# Accept str (ASCII) or bytes-like.
if isinstance(x, str):
try:
b = x.encode("ascii")
except Exception:
return False
elif isinstance(x, (bytes, bytearray, memoryview)):
b = bytes(x)
else:
return False
n = 24
if len(b) != n:
return False
if any(c < 0x20 or c > 0x7E for c in b):
return False
# Deterministic S-box via xorshift-based Fisher-Yates shuffle.
def _sbox():
arr = list(range(256))
s = 0x9E3779B9 # fixed seed
for i in range(255, 0, -1):
s ^= (s << 13) & 0xFFFFFFFF
s ^= (s >> 17) & 0xFFFFFFFF
s ^= (s << 5) & 0xFFFFFFFF
j = s % (i + 1)
arr[i], arr[j] = arr[j], arr[i]
return bytes(arr)
S = _sbox()
def transform(block: bytes) -> bytes:
st = bytearray(block)
for r in range(7):
# key/xor + sbox layer
for i in range(n):
k = ((0x3D * (r + 1)) + (0x17 * (i + 1)) + (11 * r * i)) & 0xFF
t = st[i] ^ k
t = (t + ((29 * r + 7 * i) & 0xFF)) & 0xFF
st[i] = S[t]
# invertible 2-byte mixing (pairwise)
for i in range(0, n, 2):
a = st[i]
b2 = st[i + 1]
a ^= b2
b2 = (b2 + a) & 0xFF
st[i] = a
st[i + 1] = b2
# permutation (step adjusted to be coprime with 24)
t = st[:]
step = (5 + 4 * r) % n
if step % 2 == 0:
step |= 1
if step % 3 == 0:
step ^= 2 # pushes 9->11, 21->23, etc.
off = (7 * r + 3) % n
for i in range(n):
st[i] = t[(step * i + off) % n]
return bytes(st)
# Hidden reference input (24 bytes) = blob ^ mask, with a position-dependent mask.
blob = int("3b4db36cf51d2f6825b1ac33cacac4abb73e286b85f317a6", 16).to_bytes(n, "big")
mask = bytes(((17 * i * i + 23 * i + 0x55) & 0xFF) for i in range(n))
secret = bytes(bb ^ mm for bb, mm in zip(blob, mask))
# Decoy constraints (derived from the hidden reference, but not directly helpful).
if (sum(b) % 251) != (sum(secret) % 251):
return False
if ((b[0] ^ b[-1] ^ b[7] ^ b[13]) & 0xFF) != ((secret[0] ^ secret[-1] ^ secret[7] ^ secret[13]) & 0xFF):
return False
h = 1
for c in b:
h = (h * 257 + c) % 65521
hs = 1
for c in secret:
hs = (hs * 257 + c) % 65521
if h != hs:
return False
# Main check: compare a strong, invertible transform of the input to the transform of the hidden reference.
return transform(b) == transform(secret)
def mystery(x):
if not isinstance(x, str):
return False
try:
data = x.encode("ascii")
except:
return False
# Length requirement (obfuscated)
n = (0x12 - 0x04) # 14
if len(data) != n:
return False
# Only printable ASCII
if any(b < 0x20 or b > 0x7E for b in data):
return False
def mix_byte(val, pos):
"""Position-dependent byte transformation"""
# Three-stage transformation
k1 = (0xB3 - pos * 11) & 0xFF
val = (val + k1) & 0xFF
k2 = (0x47 + pos * 19) & 0xFF
val ^= k2
# Rotation amount depends on position
r = ((pos * 3) % 7) + 1
val = ((val << r) | (val >> (8 - r))) & 0xFF
return val
# Apply transformation
result = bytes([mix_byte(data[i], i) for i in range(n)])
# Expected output - obfuscated with nested XOR and arithmetic
parts = []
base = [0x1A, 0xF3, 0x7E, 0x42, 0xD9, 0x8B, 0x56, 0xC1, 0x2F, 0xA4, 0x67, 0xE5, 0x93, 0x18]
for i, b in enumerate(base):
parts.append(((b ^ 0x5A) + ((i * 7) & 0x1F)) & 0xFF)
expected = bytes(parts)
# Checksum constraints
if sum(result) % 251 != sum(expected) % 251:
return False
xor_check = 0
for b in result:
xor_check ^= b
xor_expected = 0
for b in expected:
xor_expected ^= b
if xor_check != xor_expected:
return False
# Position-specific checks (add noise)
if (result[0] + result[-1]) % 17 != (expected[0] + expected[-1]) % 17:
return False
return result == expected