def mystery(x):
if not isinstance(x, int) or x <= 0:
return False
n, r = x, 0
while n > 0:
r = r * 10 + n % 10
n //= 10
return x * r == 39483 and x < r
def mystery(x):
# Accept strings or numbers; normalize to a string
s = x if isinstance(x, str) else str(x)
# A lot of noisy helpers and red herrings
def _ints(t):
# return list of small integers derived from characters
return [ord(c) for c in t]
def _weird_mix(lst):
# Mix values with shifts and modular arithmetic — mostly cancels out in the end
acc = 0
for i, v in enumerate(lst):
acc ^= ((v << (i % 5)) & 0xFFFFFFFF) ^ (v >> (i % 3))
return acc
def _fibonacci(n):
# small fibonacci, deliberately inefficient
a, b = 0, 1
for _ in range(n):
a, b = b, a + b
return a
def _fib_sum(lst):
# a distracting sum based on digits; engineered to be neutral later
ssum = 0
for v in lst:
ssum += _fibonacci((v % 7) + 1)
return ssum
def _primeish_transform(n):
# another distracting transform that preserves parity information only
if n % 2 == 0:
return (n // 2) << 1
return ((n * 3) + 1) ^ 0xA
# Core values
ints = _ints(s)
length = len(s)
# Several layers of combination; many cancel out algebraically
sum_ints = sum(ints)
mix = _weird_mix(ints)
fibs = _fib_sum(ints)
transformed = _primeish_transform(sum_ints & 0xFFFF)
# Compose a final value with multiple terms; arrange so most terms cancel or are neutral
# (mix ^ transformed) is designed to be a multiple of 0x1000 for typical ASCII strings,
# then we mask it out. fibs and mix are added and then subtracted again.
noisy = ((mix ^ transformed) & ~0xFFF) + fibs - fibs + (mix & 0xFFF) - (mix & 0xFFF)
final = sum_ints * length + noisy
# The true condition: final must equal this target.
TARGET = 999
return final == TARGET
def mystery(x):
if not isinstance(x, int) or x < 10**7 or x >= 10**8:
return False
# Decompose the 8-digit number into four 2-digit components
a, b, c, d = x % 100, (x//100) % 100, (x//10000) % 100, (x//1000000) % 100
# Primary constraint: polynomial combination mod prime
h = (a * b * c + d * (b + c)) % 99991
# Secondary constraint: position-weighted digit sum
s = sum((i+1) * int(ch) for i, ch in enumerate(str(x)))
return h == 26669 and s == 114
def mystery(x):
# Accept strings or numbers; normalize to a string
s = x if isinstance(x, str) else str(x)
# A bunch of noisy helpers and red herrings
def _rotl(val, r, bits=32):
r %= bits
return ((val << r) & ((1 << bits) - 1)) | (val >> (bits - r))
def _rotr(val, r, bits=32):
r %= bits
return (val >> r) | ((val << (bits - r)) & ((1 << bits) - 1))
def _noisy_mix(lst):
acc = 0xABCDEF
for i, v in enumerate(lst):
acc ^= ((_rotl(v ^ (i * 131), (i * 7) & 31) + _rotr(v | (i * 73), (i * 13) & 31)))
acc = (acc + (v * (i + 1))) & 0xFFFFFFFFFFFFFFFF
return acc
def _prime_like(n):
if n <= 1:
return 2
k = 2
while k * k <= n:
if n % k == 0:
return k
k += 1
return n
def _weird_fold(lst):
out = 0
for v in lst:
out = (((out << 5) - out) + (v ^ 0x55)) & 0xFFFFFFFF
return out
# Core normalization to integer-like list (ordinals)
ints = [ord(c) for c in s]
L = len(s)
# Several distracting intermediate values
mix1 = _noisy_mix(ints)
mix2 = _weird_fold(ints)
small = sum(ints) & 0xFFFF
p = _prime_like(small + 37)
# Construct several terms that largely cancel or are neutral
term_a = (mix1 ^ mix2) & ~0xFFFF # high bits masked away
term_b = (mix1 & 0xFFFF) - (mix1 & 0xFFFF) # cancels to zero
term_c = (mix2 % (p or 1)) - (mix2 % (p or 1)) # cancels to zero
term_d = ((small << 3) - (small << 3)) # cancels to zero
# The true core value (carefully hidden among noise):
# sum_adj is sum(ord(c) - 30) for each character
sum_adj = sum(v - 30 for v in ints)
# Compose final value with lots of noise that cancels
final = (sum_adj * L) + term_a + term_b + term_c + term_d
# Final check against a target
TARGET = 202
return final == TARGET
def mystery(x):
if not isinstance(x, int) or x < 100000 or x >= 1000000:
return False
s = str(x)
d = [int(c) for c in s]
# Constraint 1: position-weighted sum (1-indexed positions)
w = sum(d[i] * (i + 1) for i in range(6))
# Constraint 2: alternating sign sum
a = d[0] - d[1] + d[2] - d[3] + d[4] - d[5]
# Constraint 3: product of even-indexed digits
p = d[0] * d[2] * d[4]
return w == 114 and a == -18 and p == 6
def mystery(x):
# Accept several input types; normalize to bytes
if isinstance(x, bytes):
b = x
elif isinstance(x, str):
b = x.encode("utf-8")
elif isinstance(x, int):
b = str(x).encode("utf-8")
else:
return False
import hashlib
# Compute a real cryptographic fingerprint (the true core)
h = hashlib.sha256(b).digest()
H = int.from_bytes(h, "big") # the 256-bit integer hash
# A bunch of noisy helpers / red herrings to obscure the real check
def _rotl(n, r, bits=256):
r %= bits
mask = (1 << bits) - 1
return ((n << r) & mask) | (n >> (bits - r))
def _rotr(n, r, bits=256):
r %= bits
mask = (1 << bits) - 1
return (n >> r) | ((n << (bits - r)) & mask)
def _weird_fold(n):
# mix the 256-bit integer into another 256-bit value
acc = 0xC0FFEE
for i in range(32):
byte = (n >> (i * 8)) & 0xFF
acc = ((acc << 7) ^ (acc >> 3) ^ (byte * 0x9E)) & ((1 << 256) - 1)
return acc
def _mask_shuffle(n):
# create a mask-like value that depends on n but will cancel out later
m = 0
for i in range(0, 256, 16):
piece = (n >> i) & 0xFFFF
m ^= (piece << ((i * 3) % 256))
return m & ((1 << 256) - 1)
# Compute noisy intermediates (deliberately arranged to cancel)
a = _rotl(H ^ 0xA5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5A5, 13)
b = _rotr(H | 0x1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF, 29)
c = _weird_fold(H)
d = _mask_shuffle(H)
# Combine them in a way that looks complex but cancels out
noisy = ((a ^ b) & ((1 << 256) - 1)) ^ ((c ^ d) & ((1 << 256) - 1))
cancel = noisy ^ noisy # definitely zero
# The final value is just the original hash plus the canceled noise
final = (H + cancel) & ((1 << 256) - 1)
# TARGET is the SHA-256 of the canonical test string "hello"
TARGET = int(
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", 16
)
return final == TARGET
def mystery(x):
if not isinstance(x, int) or x < 10**7 or x >= 10**8:
return False
s = str(x)
d = [int(c) for c in s]
n = len(d)
# Prime sieve for generating weight sequence
def primes_from(lo, hi):
sieve = [True] * (hi + 1)
sieve[0] = sieve[1] = False
for i in range(2, int(hi**0.5) + 1):
if sieve[i]:
for j in range(i*i, hi + 1, i):
sieve[j] = False
return [p for p in range(lo, hi + 1) if sieve[p]]
P = primes_from(30, 70)[:n]
# Constraint 1: weighted sum with consecutive primes
c1 = sum(d[i] * P[i] for i in range(n))
# Constraint 2: symmetric/reflected digit product sum
c2 = sum(d[i] * d[n-1-i] for i in range(n//2))
# Constraint 3: XOR chain of adjacent digit products
c3 = 0
for i in range(n//2):
c3 ^= d[2*i] * d[2*i+1]
return c1 == 2026 and c2 == 88 and c3 == 22
def mystery(x):
# Accept strings or numbers; normalize to bytes
if isinstance(x, bytes):
b = x
elif isinstance(x, str):
b = x.encode("utf-8")
elif isinstance(x, int):
b = str(x).encode("utf-8")
else:
return False
import hashlib
from functools import reduce
import operator
# Compute SHA-1 of the input (the true core)
h = hashlib.sha1(b).digest() # 20 bytes
H = int.from_bytes(h, "big") # 160-bit integer
# Several noisy helper functions / red herrings
def _rotl(n, r, bits=160):
r %= bits
mask = (1 << bits) - 1
return ((n << r) & mask) | (n >> (bits - r))
def _rotr(n, r, bits=160):
r %= bits
mask = (1 << bits) - 1
return (n >> r) | ((n << (bits - r)) & mask)
def _fold_bytes(bts):
# a fold that mixes bytes but will be canceled later
acc = 0xDEADBEEF
for i, byte in enumerate(bts):
acc = ((acc << 5) - acc) ^ (byte + (i * 37))
acc &= 0xFFFFFFFFFFFFFFFF
return acc
def _poly_noise(n):
# produce some pseudorandom-looking value from n
x = n
x = (x ^ 0x123456789ABCDEF) * 0x1000003D
x ^= (x >> 23) ^ (x << 17)
return x & ((1 << 160) - 1)
# Create multiple intermediates that look meaningful
a = _rotl(H ^ 0xA5A5A5A5A5A5A5A5A5A, 13)
bval = _rotr(H | 0x1234567890ABCDEF1234, 29)
c = _fold_bytes(b)
d = _poly_noise(H)
# Compose a noisy combination that will be canceled out
noisy1 = (a ^ bval) & ((1 << 160) - 1)
noisy2 = ((c << 7) ^ (d >> 11)) & ((1 << 160) - 1)
combined_noisy = (noisy1 ^ noisy2) & ((1 << 160) - 1)
# Another layer: a product of small summaries (will be zeroed later)
s = sum(b) # small
prod = reduce(operator.mul, [(v % 7 + 1) for v in b], 1)
small_mask = (s * prod) & 0xFFFF
# Arrange cancellation: mask out the lower bits and then re-add them back to zero effect
high_part = (combined_noisy & ~0xFFFF) # keeps high bits of noise
low_part = combined_noisy & 0xFFFF
cancel = high_part ^ high_part # definitely zero
cancel2 = (low_part - low_part) # zero
# The final value reduces to the original hash integer H (noise cancels)
final = (H + cancel + cancel2 + small_mask - small_mask) & ((1 << 160) - 1)
# TARGET is the SHA-1 of the ASCII string "test"
TARGET = int("a94a8fe5ccb19ba61c4c0873d391e987982fbbd3", 16)
return final == TARGET
def mystery(x):
if not isinstance(x, int) or x < 10**5 or x >= 10**6:
return False
s = str(x)
d = [int(c) for c in s]
# Constraint 1: sum of digits equals product of first and last digit
if sum(d) != d[0] * d[5]:
return False
# Constraint 2: middle digits form two 2-digit numbers whose product is 2701
if (d[1] * 10 + d[2]) * (d[3] * 10 + d[4]) != 2701:
return False
# Constraint 3: x is divisible by 7
if x % 7 != 0:
return False
# Constraint 4: XOR of even-indexed digits is 0
return (d[0] ^ d[2] ^ d[4]) == 0
def mystery(x):
# Accept strings or numbers; normalize to a string
if isinstance(x, bytes):
s = x.decode("utf-8", errors="ignore")
elif isinstance(x, str):
s = x
elif isinstance(x, int):
s = str(x)
else:
return False
# A collection of noisy helpers and red herrings
def _rotl(v, r, bits=32):
r %= bits
mask = (1 << bits) - 1
return ((v << r) & mask) | (v >> (bits - r))
def _rotr(v, r, bits=32):
r %= bits
mask = (1 << bits) - 1
return (v >> r) | ((v << (bits - r)) & mask)
def _weird_sum(chars):
# produce a value that depends on chars but will be neutralized later
acc = 0x13579BDF
for i, c in enumerate(chars):
v = ord(c) * ((i % 5) + 1)
acc = (acc ^ _rotl(v, (i * 3) & 31)) + _rotr(v | 0x55, (i * 7) & 31)
acc &= 0xFFFFFFFF
return acc
def _fold(chars):
# another noisy fold that mostly scrambles low bits
out = 0x2468ACE0
for i, c in enumerate(chars):
out = ((out * 1664525) + (ord(c) ^ (i * 97))) & 0xFFFFFFFF
return out
def _small_poly(n):
# small polynomial to mix a little, but will be canceled
return (n * 123457) ^ 0x9E3779B1
chars = list(s)
L = len(s)
# Several intermediate noisy values
noisy1 = _weird_sum(chars)
noisy2 = _fold(chars)
small = sum(ord(c) for c in s) & 0xFFFF
# Mix them in convoluted ways designed to cancel out
part_a = (noisy1 ^ noisy2) & ~0xFFFF # keep high bits only
part_b = (noisy1 & 0xFFFF) - (noisy1 & 0xFFFF) # will be zero
part_c = (_small_poly(small) % 0x10000) - (_small_poly(small) % 0x10000) # zero
# The true core: simple and intentionally hidden among noise
core = sum(ord(c) for c in s)
# Compose final with a lot of canceling terms
final = (core * L) + part_a + part_b + part_c
# TARGET chosen so that a known sample satisfies the condition
TARGET = 882
return final == TARGET