def mystery(x):
import re
import struct
# --- Coerce input to a non-negative 64-bit integer n (accepts int/float/str) ---
if isinstance(x, bool):
return False
if isinstance(x, int):
n = x
elif isinstance(x, float):
if not x.is_integer():
return False
n = int(x)
elif isinstance(x, str):
s = x.strip().replace("_", "")
if re.fullmatch(r"[+-]?\d+", s):
n = int(s, 10)
else:
# Decoy path: allow some non-decimal strings, but it won't help unless the congruences match.
try:
n = int(s.lower(), 36)
except Exception:
return False
else:
return False
if n < 0 or n >= (1 << 64):
return False
# --- Build moduli (obfuscated offsets around 10^6) ---
base = 10**6
offs = [
0b11, # 3
0o41, # 33
0x25, # 37
(0xAB ^ 0x8C), # 39
]
mods = [base + o for o in offs]
# --- Recover expected residues (obfuscated little-endian uint32s) ---
key = 0xA5
blob = bytes.fromhex("7e14a8a54bf8a2a55540ada59f75a3a5")
raw = bytes((b ^ key) for b in blob)
residues = [struct.unpack_from("<I", raw, 4 * i)[0] for i in range(4)]
# --- Check congruences (with an extra reversible mask to hinder pattern-spotting) ---
for m, r in zip(mods, residues):
mask = m & 0xFFFF
if ((n % m) ^ mask) != (r ^ mask):
return False
return True
def mystery(x):
# Input validation: must be a 6-character string
if not isinstance(x, str) or len(x) != 6:
return False
# Convert string to ASCII values
vec = [ord(c) for c in x]
# Ensure characters are printable ASCII
if any(c < 32 or c > 126 for c in vec):
return False
# Target values (hexadecimal representation)
targets = [
0x28A,
0x1A52,
0x94E2,
0x22844,
0x622AA,
0xE9986
]
# Verify a specific mathematical relationship
for i in range(6):
z = i + 1
acc = 0
p = 1
for v in vec:
acc += v * p
p *= z
if acc != targets[i]:
return False
return True
def mystery(x):
# Accept str/int/float; normalize to a string without being too helpful.
if isinstance(x, bool):
return False
if isinstance(x, (int,)):
s = str(x)
elif isinstance(x, float):
if not x.is_integer():
return False
s = str(int(x))
elif isinstance(x, str):
s = x
else:
return False
# Must be exactly 12 printable ASCII characters.
if len(s) != 12:
return False
if any(ord(c) < 33 or ord(c) > 126 for c in s):
return False
b = s.encode("latin1")
# A small "checksum" gate (decoy-ish, but real).
chk = (sum(b) * 31337 + 42) % 65521
if chk != 46474:
return False
def rotl8(v, r):
v &= 0xFF
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
# Permute bytes, then apply mixed byte-wise ops.
p = [7, 2, 11, 0, 9, 4, 5, 10, 1, 6, 8, 3]
key = [0xA6, 0x1C, 0xF0, 0x4B, 0x99, 0xD3, 0x27, 0x8E, 0x5A, 0xC1, 0x0D, 0x73]
add = [3, 17, 9, 5, 31, 7, 11, 19, 13, 23, 29, 2]
ror = [1, 3, 2, 5, 7, 4, 6, 1, 2, 3, 5, 7]
out = bytearray(12)
for i in range(12):
v = b[p[i]]
v ^= key[i]
v = (v + add[i]) & 0xFF
v = rotl8(v, ror[i])
out[i] = v
# Target is stored XOR-obfuscated.
blob = bytes.fromhex("9b61c1eb2ed222be77079bbd") # == (target ^ 0xAA)
target = bytes(t ^ 0xAA for t in blob)
return bytes(out) == target
def mystery(x):
# Validate input type and length
if not isinstance(x, str) or len(x) != 7:
return False
# Ensure printable ASCII
if any(ord(c) < 32 or ord(c) > 126 for c in x):
return False
# Initial state vector (IV)
state = 0x55
# The target sequence that the input must generate
targets = [232, 196, 71, 138, 214, 126, 161]
for i, char in enumerate(x):
val = ord(char)
# 1. Non-linear mixing with current state
k = val ^ state
# 2. Position-dependent affine transformation
# (Adds a constant and a position-based offset)
k = (k + 13 + i * 2) & 0xFF
# 3. Bitwise permutation (Circular Shift Left by 3)
k = ((k << 3) | (k >> 5)) & 0xFF
# Verification
if k != targets[i]:
return False
# Chain the state (Cipher Block Chaining style)
state = k
return True
def mystery(x):
import re
# ---- normalize input to a candidate 8-char string s ----
if isinstance(x, bool):
return False
s = None
if isinstance(x, str):
s = x
# Decoy input format: allow "0x" + 16 hex chars, interpreted as 8 raw bytes.
m = re.fullmatch(r"\s*0x([0-9a-fA-F]{16})\s*", s)
if m:
try:
s = bytes.fromhex(m.group(1)).decode("latin1")
except Exception:
return False
elif isinstance(x, (int, float)):
if isinstance(x, float) and not x.is_integer():
return False
n = int(x)
if n < 0:
return False
# Decoy encoding: base-94 (printable ASCII) into exactly 8 characters.
chars = []
for _ in range(8):
n, rem = divmod(n, 94)
chars.append(chr(33 + rem))
if n != 0:
return False
s = "".join(reversed(chars))
else:
return False
# ---- basic constraints ----
if not isinstance(s, str) or len(s) != 8:
return False
if any(not (33 <= ord(c) <= 126) for c in s):
return False
b = s.encode("latin1")
# ---- cheap-looking gates that still eliminate most candidates ----
gate1 = (sum(b) * 257 + ((b[0] ^ b[-1]) * 911)) & 0xFFFF
if gate1 != 0xEB48:
return False
if (b[1] * b[3] + b[5]) % 97 != 13:
return False
# ---- helpers ----
def rotl8(v, r):
v &= 0xFF
r &= 7
return ((v << r) | (v >> (8 - r))) & 0xFF
# ---- recover hidden per-position parameters ----
# c[i] bytes are stored as a masked 64-bit int (little-endian).
M = 0xDEADBEEFCAFEBABE
C_OBF = 0x5FEFBD72E637E7AF
c = list(((C_OBF ^ M) & ((1 << 64) - 1)).to_bytes(8, "little"))
# r[i] are 3-bit packed (masked).
R_OBF = 0x697503
rpack = R_OBF ^ 0x5A5A5A
r = [(rpack >> (3 * i)) & 7 for i in range(8)]
# targets are permuted and XOR-masked.
perm = (3, 0, 6, 1, 7, 5, 2, 4)
blob = bytes.fromhex("f3a68193b24feb49") # permuted (target ^ 0xAA)
targets = [0] * 8
for j, idx in enumerate(perm):
targets[idx] = blob[j] ^ 0xAA
# ---- main check: chained transform ----
state = 0x5D ^ 0xFA # == 0xA7
for i in range(8):
v = b[i]
t = rotl8(((v ^ state) + c[i]) & 0xFF, r[i])
if t != targets[i]:
return False
state = (state + v + 11 * i) & 0xFF
return True
def mystery(x):
# Input validation
if not isinstance(x, str) or len(x) != 8:
return False
# Check printable ASCII
ords = [ord(c) for c in x]
if any(o < 32 or o > 126 for o in ords):
return False
# A simple checksum gate
if sum(ords) != 813:
return False
# ---------------------------------------------------------
# Phase 1: Permutation and Non-linear Masking
# ---------------------------------------------------------
# Unpack permutation indices from a compact integer
# Hex 0x46317025 encodes the permutation [5, 2, 0, 7, 1, 3, 6, 4] in nibbles
p_packed = 1177677861
p = [(p_packed >> (4 * i)) & 0xF for i in range(8)]
# Bitwise masks
masks = [0xAA, 0x55, 0x33, 0xCC, 0x0F, 0xF0, 0xA5, 0x5A]
# ---------------------------------------------------------
# Phase 2: Cumulative Transformation (GF(257))
# ---------------------------------------------------------
MOD = 257
state = 0
y = []
for i in range(8):
# Select permuted character and apply mask
val = ord(x[p[i]]) ^ masks[i]
# Update state with a linear feedback
# state[i] = (state[i-1] * 13 + val) % 257
state = (state * 13 + val) % MOD
y.append(state)
# ---------------------------------------------------------
# Phase 3: Cyclic Mixing
# ---------------------------------------------------------
# Mix the cumulative states to produce final vector z
z = []
for i in range(8):
# Combine current and next (wrapping) state
val = (2 * y[i] + y[(i + 1) % 8]) % MOD
z.append(val)
# ---------------------------------------------------------
# Verification
# ---------------------------------------------------------
targets = [148, 89, 20, 203, 175, 169, 86, 138]
return z == targets
def mystery(x):
import re
# ---------- normalize x into a 10-char candidate string s ----------
if isinstance(x, bool):
return False
s = None
if isinstance(x, bytes):
try:
s = x.decode("latin1")
except Exception:
return False
elif isinstance(x, str):
t = x.strip()
# Decoy format: "0x" + 20 hex chars (10 raw bytes -> latin1 string)
m = re.fullmatch(r"0x([0-9a-fA-F]{20})", t)
if m:
try:
s = bytes.fromhex(m.group(1)).decode("latin1")
except Exception:
return False
else:
s = t
elif isinstance(x, (int, float)):
if isinstance(x, float) and (not x.is_integer()):
return False
n = int(x)
if n < 0:
return False
# Decoy encoding: base-94 into exactly 10 printable ASCII chars.
chars = []
for _ in range(10):
n, rem = divmod(n, 94)
chars.append(chr(33 + rem))
if n != 0:
return False
s = "".join(reversed(chars))
else:
return False
if not isinstance(s, str) or len(s) != 10:
return False
if any(not (33 <= ord(c) <= 126) for c in s):
return False
b = s.encode("latin1")
# ---------- reconstruct hidden reference block (10 bytes) ----------
# secret bytes are stored as: obf = secret ^ (0xA5 repeated 10 times)
obf = 0xEB95D1FA91FAF1D794D3
mask = int.from_bytes(b"\xA5" * 10, "big")
secret = (obf ^ mask).to_bytes(10, "big")
# ---------- cheap gates (derived from the hidden reference; decoy-ish but real) ----------
def gate(bb):
return (
((sum(bb) * 0x045D9F3B) ^ ((bb[0] << 24) | (bb[5] << 16) | (bb[9] << 8) | bb[3]))
& 0xFFFFFFFF
)
if gate(b) != gate(secret):
return False
def gate2(bb):
acc = 0
for i, v in enumerate(bb):
acc ^= ((v + 17 * i) & 0xFF)
acc = ((acc << 1) | (acc >> 7)) & 0xFF
return acc
if gate2(b) != gate2(secret):
return False
# ---------- 6-round Feistel over 10 bytes (bijection) ----------
MASK40 = (1 << 40) - 1
def rol40(v, r):
r %= 40
return ((v << r) & MASK40) | (v >> (40 - r))
# Key schedule (40-bit subkeys), generated deterministically but awkwardly.
seed = 0xC0FFEE1234DEADBEEF9876543210
keys = []
for i in range(6):
seed = (seed * 0x5851F42D4C957F2D + 0x14057B7EF767814F + i) & ((1 << 128) - 1)
keys.append(((seed >> (7 * i + 11)) ^ (seed >> (3 * i + 5))) & MASK40)
def round_f(r_bytes, k40):
v = int.from_bytes(r_bytes, "big") & MASK40
v ^= k40
v = (v + rol40(k40, 9) + 0x12345) & MASK40
v ^= rol40(v, 17)
v = (v * 0x9E3779) & MASK40
v ^= (v >> 13)
v ^= (v << 7) & MASK40
return v.to_bytes(5, "big")
def feistel(block10):
L = block10[:5]
R = block10[5:]
for rk in keys:
t = round_f(R, rk)
L, R = R, bytes((a ^ b) for a, b in zip(L, t))
return L + R
# Since feistel() is a bijection, this comparison is equivalent to b == secret,
# but much harder to eyeball.
return feistel(b) == feistel(secret)
def mystery(x):
# --- Input Normalization ---
s = None
if isinstance(x, str):
s = x
elif isinstance(x, int):
if x < 0: return False
try:
# Convert integer to bytes, then decode to latin1
h = f"{x:x}"
if len(h) % 2: h = "0" + h
s = bytes.fromhex(h).decode("latin1")
except:
return False
if s is None or len(s) != 8:
return False
# Validation: Printable ASCII characters only
if any(ord(c) < 33 or ord(c) > 126 for c in s):
return False
# Convert to vector of integers
v = [ord(c) for c in s]
# --- Transformation over Z_257 ---
# We operate modulo 257 (a prime number), allowing for invertible affine operations.
# However, we inject a bitwise XOR layer to hinder pure algebraic solvers.
MOD = 257
# 1. Additive Position-Dependent Mask
# v[i] = v[i] + 11*(i+1)
for i in range(8):
v[i] = (v[i] + 11 * (i + 1)) % MOD
# 2. Linear Diffusion (Prefix Sum)
# Mixes each byte with the sum of previous bytes
for i in range(1, 8):
v[i] = (v[i] + v[i-1]) % MOD
# 3. Non-Linear Layer (Bitwise XOR)
# This step maps Z_257 -> Integer -> Z_257 in the next step.
# The XOR constants are 0xAA, 0xAB, ...
for i in range(8):
v[i] ^= (0xAA + i)
# 4. Multiplicative Scaling
# Multipliers: 2, 3, 4, 5, 6, 7, 8, 9 (all coprime to 257)
for i in range(8):
v[i] = (v[i] * (i + 2)) % MOD
# 5. Linear Diffusion (Suffix Sum)
# Mixes each byte with the sum of subsequent bytes
for i in range(6, -1, -1):
v[i] = (v[i] + v[i+1]) % MOD
# --- Target Verification ---
targets = [77, 109, 135, 216, 50, 209, 143, 180]
return v == targets
def mystery(x):
import re
import struct
# ---------- normalize input into a 12-char printable ASCII string s ----------
if isinstance(x, bool):
return False
s = None
if isinstance(x, str):
t = x.strip()
# Decoy format: "0x" + 24 hex chars -> 12 raw bytes -> latin1 string
m = re.fullmatch(r"0x([0-9a-fA-F]{24})", t)
if m:
try:
s = bytes.fromhex(m.group(1)).decode("latin1")
except Exception:
return False
else:
s = t
elif isinstance(x, (int, float)):
if isinstance(x, float) and (not x.is_integer()):
return False
n = int(x)
if n < 0:
return False
# Decoy encoding: base-94 into exactly 12 chars (printable ASCII 33..126).
chars = []
for _ in range(12):
n, rem = divmod(n, 94)
chars.append(chr(33 + rem))
if n != 0:
return False
s = "".join(reversed(chars))
else:
return False
if not isinstance(s, str) or len(s) != 12:
return False
if any(not (33 <= ord(c) <= 126) for c in s):
return False
b = s.encode("latin1")
# ---------- reconstruct hidden reference bytes (12 bytes) ----------
# perm packed as 12 nibbles
p_packed = 0x5836A1490B27
p = [(p_packed >> (4 * i)) & 0xF for i in range(12)]
if sorted(p) != list(range(12)):
return False
# blob stores: blob[i] = ((ref[p[i]] + 7*i) ^ (0x5A+i)) & 0xFF
blob = bytes.fromhex("790312d00bcc01f50803c4fc")
ref = bytearray(12)
for i in range(12):
w = blob[i]
w ^= (0x5A + i) & 0xFF
w = (w - (7 * i)) & 0xFF
ref[p[i]] = w
# Ensure the reference itself is within the same printable range (so it's a real "string answer").
if any(not (33 <= v <= 126) for v in ref):
return False
# ---------- "checksum-like" gates derived from ref (targets not directly present) ----------
def gate1(bb):
acc = 0x1234
for i, v in enumerate(bb):
acc = (acc + (((v ^ (17 * i)) & 0xFF) * (i + 3))) & 0xFFFF
acc = ((acc << 3) | (acc >> 13)) & 0xFFFF
return acc
def gate2(bb):
# A small polynomial-ish hash over Z_257 (invertible-ish structure, but used only as a gate)
acc = 1
for i, v in enumerate(bb):
acc = (acc * (3 + i) + (v ^ (0xA7 - 7 * i))) % 257
return acc
if gate1(b) != gate1(ref):
return False
if gate2(b) != gate2(ref):
return False
# ---------- reversible-looking ARX mixer on 96 bits; compare in mixed domain ----------
MASK32 = 0xFFFFFFFF
def rotl32(v, r):
r &= 31
v &= MASK32
return ((v << r) & MASK32) | (v >> (32 - r))
def mix(block12):
a, b_, c = struct.unpack("<III", block12)
seed = 0xC001D00D
for r in range(8):
seed = (seed * 0x045D9F3B + 0x1337 + r) & MASK32
k1 = seed
seed = ((seed ^ (seed >> 16)) * 0x7FEB352D) & MASK32
k2 = seed
seed = (seed + 0x9E3779B9) & MASK32
k3 = (seed ^ ((seed << 13) & MASK32)) & MASK32
r1 = (k1 >> 27) & 31
r2 = (k2 >> 28) & 31
a = (a + rotl32((b_ ^ k1) & MASK32, r1)) & MASK32
b_ = (b_ ^ ((a + k2) & MASK32)) & MASK32
c = (c + (rotl32(a, r2) ^ k3)) & MASK32
# word rotation for diffusion
a, b_, c = b_, c, a
return (a, b_, c)
return mix(b) == mix(bytes(ref))
def mystery(x):
# Input validation: must be an 8-character string
if not isinstance(x, str) or len(x) != 8:
return False
# Convert to mutable list of ASCII values
state = [ord(c) for c in x]
# Ensure printable ASCII
if any(c < 32 or c > 126 for c in state):
return False
# A custom 2-round Substitution-Permutation Network (SPN)
# The state is processed as two independent 4-byte blocks.
for r in range(2):
# 1. Key Addition Layer
# Keys are simple constants derived from the round index and position.
for i in range(8):
k = (r + 1) + (i % 4)
state[i] = (state[i] + k) & 0xFF
# 2. Mixing Layer (Diffusion)
# This mixes the bytes within each 4-byte chunk reversibly.
# We process indices [0,1,2,3] and [4,5,6,7] independently.
for base in [0, 4]:
# Sequential updates create dependencies
state[base + 0] = (state[base + 0] + state[base + 1]) & 0xFF
state[base + 2] = (state[base + 2] + state[base + 3]) & 0xFF
state[base + 1] = (state[base + 1] + state[base + 2]) & 0xFF
state[base + 3] = (state[base + 3] + state[base + 0]) & 0xFF
# 3. Permutation Layer (Block Rotation)
# Cyclically rotate bytes left by 1 position within each 4-byte chunk.
# [A, B, C, D] becomes [B, C, D, A]
state[0:4] = state[1:4] + state[0:1]
state[4:8] = state[5:8] + state[4:5]
# The target state vector
targets = [234, 249, 9, 72, 200, 227, 244, 58]
return state == targets