def mystery(x):
if type(x) != int or x <= 1 or x > 100000:
return False
for i in range(2, int(x**0.5) + 1):
if x % i == 0:
break
else:
return False
def g(a, b):
while b: a, b = b, a % b
return a
c = sum(1 for a in range(2, 100) if g(a, x) == 1 and pow(a, x-1, x) != 1)
return c == 0 and sum(int(d) for d in str(x)) == 19
import hashlib, base64, zlib, re
def mystery(x):
# Accept only strings (numbers are rejected).
if not isinstance(x, str):
return False
# Normalize in a slightly non-obvious way.
s = x.strip().replace("\r\n", "\n")
# Structural constraints: looks like a "token"
if not re.fullmatch(r"[A-Za-z0-9_-]{22,60}", s):
return False
if s[0].islower() or s[-1].islower():
return False
# Decode as URL-safe base64 without '=' padding.
try:
raw = base64.urlsafe_b64decode(s + "=" * ((4 - len(s) % 4) % 4))
except Exception:
return False
# Must be zlib-compressed data; decompressed payload must be small.
try:
msg = zlib.decompress(raw)
except Exception:
return False
if not (8 <= len(msg) <= 64):
return False
# Payload must be printable ASCII and contain exactly one colon.
try:
t = msg.decode("ascii")
except Exception:
return False
if any(ord(c) < 32 or ord(c) > 126 for c in t):
return False
if t.count(":") != 1:
return False
# Split into two pieces with their own constraints.
left, right = t.split(":")
if not (left.isalpha() and left.isupper() and 3 <= len(left) <= 8):
return False
if not (right.isdigit() and 6 <= len(right) <= 10):
return False
if sum(map(int, right)) % 7 != 0:
return False
# Final check: a double-hash condition that depends on both layers.
h = hashlib.sha256(msg).digest()
hh = hashlib.sha256(h + s.encode("ascii")).hexdigest()
return (hh.startswith("0000") and hh.endswith("c0de"))
def mystery(x):
if not isinstance(x, str) or not (5 <= len(x) <= 20):
return False
if not x.islower() or not x.isalpha():
return False
v = [ord(c) - 96 for c in x]
m = len(x) // 2
if sum(v[:m]) != sum(v[m:]):
return False
t = sum(v)
r = int(t ** 0.5)
return r * r == t and len(set(x)) == len(x) and x[0] >= 'q'
import re, base64, hashlib, zlib, struct
def mystery(x):
if not isinstance(x, str):
return False
# Strict-ish "token" shape (hard to eyeball), but still human-typeable.
s = x.strip()
if not (24 <= len(s) <= 64):
return False
if not re.fullmatch(r"[A-Za-z0-9_-]+", s):
return False
if s[0] in "aeiouAEIOU" or s[-1] in "aeiouAEIOU":
return False
# URL-safe base64 decode without padding.
try:
raw = base64.urlsafe_b64decode(s + "=" * ((4 - len(s) % 4) % 4))
except Exception:
return False
# Must be zlib data that expands to a small ASCII payload.
try:
msg = zlib.decompress(raw)
except Exception:
return False
if not (12 <= len(msg) <= 80):
return False
try:
t = msg.decode("ascii")
except Exception:
return False
if any(ord(c) < 32 or ord(c) > 126 for c in t):
return False
# Hidden "format" constraint.
# Example of acceptable payload: TAG{ABCDE-12345}#99
m = re.fullmatch(r"([A-Z]{3})\{([A-Z]{5})-([0-9]{5})\}#([0-9]{2})", t)
if not m:
return False
tag, letters, digits, k2 = m.groups()
# A couple of numeric invariants tying sections together.
ds = sum(int(d) for d in digits)
if ds % 7 != 0:
return False
if int(k2) != (ds * 3 + sum(ord(c) for c in letters)) % 100:
return False
# Final binding between outer token and inner payload: a mixed hash check.
h1 = hashlib.sha256(msg).digest()
h2 = hashlib.sha256((s + "|" + t).encode("utf-8")).digest()
folded = bytes(a ^ b for a, b in zip(h1, h2))
# Condition: folded digest interpreted as 4 little-endian uint32s has a fixed XOR.
a, b, c, d = struct.unpack("<4I", folded[:16])
return ((a ^ b ^ c ^ d) & 0xFFFFFFFF) == 0x1A2B3C4D
def mystery(x):
if type(x) != int or x <= 1000 or x > 10**6:
return False
r = int(x**0.5)
if r * r != x:
return False
t = 8 * x + 1
s = int(t ** 0.5)
if s * s != t:
return False
d = sum(int(c) for c in str(x))
return d % 9 == 0 and '0' not in str(x)
import hashlib, base64, zlib, re
def mystery(x):
if not isinstance(x, str):
return False
s = x.strip()
# Outer "token" shape: URL-safe base64 characters only.
if not re.fullmatch(r"[A-Za-z0-9_-]{20,120}", s):
return False
if len(set(s)) < 10:
return False
# Decode as URL-safe base64 without '=' padding.
try:
raw = base64.urlsafe_b64decode(s + "=" * ((4 - len(s) % 4) % 4))
except Exception:
return False
# Must be zlib-compressed data; decompressed payload must be small and ASCII.
try:
msg = zlib.decompress(raw)
except Exception:
return False
if not (5 <= len(msg) <= 50):
return False
try:
t = msg.decode("ascii")
except Exception:
return False
if any(ord(c) < 32 or ord(c) > 126 for c in t):
return False
# Hidden-ish internal format: PREFIX{hex}
m = re.fullmatch(r"([A-Z]{2})\{([0-9a-f]{16})\}", t)
if not m:
return False
prefix, hx = m.group(1), m.group(2)
# Some invariant checks to prevent "obvious" construction.
if prefix != "OK":
return False
if int(hx, 16) % 97 != 0:
return False
if sum(int(c, 16) for c in hx) % 31 != 0:
return False
# Final binding: SHA-256 of (raw || msg) must have a fixed pattern.
h = hashlib.sha256(raw + b"|" + msg).hexdigest()
return h.startswith("0000") and h.endswith("b00b")
def mystery(x):
if type(x) != int or x <= 10000 or x >= 1000000:
return False
r = int(x ** 0.5)
if r * r != x:
return False
s = str(r)
if s != s[::-1]:
return False
t = str(x)
if len(set(t)) != len(t):
return False
return sum(int(d) for d in t) == 27
import re, base64, zlib, hashlib, struct
def mystery(x):
if not isinstance(x, str):
return False
s = x.strip()
# Outer constraint: URL-safe base64 alphabet only, length not obviously tied to payload.
if not re.fullmatch(r"[A-Za-z0-9_-]{30,90}", s):
return False
if len(set(s)) < 12:
return False
# Base64-url decode (no padding provided by caller).
try:
raw = base64.urlsafe_b64decode(s + "=" * ((4 - len(s) % 4) % 4))
except Exception:
return False
# Must be zlib stream.
try:
msg = zlib.decompress(raw)
except Exception:
return False
# Payload: strict ASCII and strict format.
if not (18 <= len(msg) <= 80):
return False
try:
t = msg.decode("ascii")
except Exception:
return False
if any(ord(c) < 32 or ord(c) > 126 for c in t):
return False
# Format: CTF{<10 uppercase letters>-<8 digits>-<4 lowercase hex>}
m = re.fullmatch(r"CTF\{([A-Z]{10})-([0-9]{8})-([0-9a-f]{4})\}", t)
if not m:
return False
letters, digits, hx = m.groups()
# Numeric invariants to make construction non-obvious but not impossible.
ds = sum(int(c) for c in digits)
if ds % 13 != 0:
return False
# A weak coupling between the 10 letters and the digit string.
# (Hard to invert by inspection; easy to check once you can generate candidates.)
if (sum(ord(c) for c in letters) + int(digits)) % 997 != 123:
return False
# A tiny non-linear check involving the 4 hex chars.
a = int(hx, 16)
if ((a * a + 17) ^ (a << 1)) & 0xFFFF != 0xBEEF:
return False
# Final binding between outer token and inner payload:
# take SHA256(msg), then BLAKE2s keyed by first 16 bytes of raw, and check a 32-bit word.
h = hashlib.sha256(msg).digest()
key = raw[:16].ljust(16, b"\x00")
b = hashlib.blake2s(h, key=key, digest_size=16).digest()
w0, w1, w2, w3 = struct.unpack("<4I", b)
return ((w0 + w2) ^ (w1 + w3)) & 0xFFFFFFFF == 0xC0FFEE42
def mystery(x):
if type(x) != int or x < 1000 or x > 100000:
return False
c = []
m = int(x**(1/3)) + 2
for a in range(1, m):
for b in range(a, m):
if a*a*a + b*b*b == x:
c.append((a, b))
if len(c) < 2:
return False
d = sum(int(k) for k in str(x))
for j in range(2, int(d**0.5) + 1):
if d % j == 0:
return False
s = str(x)
return d > 1 and '8' in s and len(s) == 5 and int(s[0]) & 1
import re, base64, zlib, hashlib, struct
def mystery(x):
if not isinstance(x, str):
return False
s = x.strip()
# Outer token: URL-safe base64 alphabet, fixed-ish size, and mixed chars.
if not re.fullmatch(r"[A-Za-z0-9_-]{40,60}", s):
return False
if len(set(s)) < 15:
return False
if s[0] in "aeiouAEIOU" or s[-1] in "aeiouAEIOU":
return False
# Decode base64url (no padding supplied by caller).
try:
raw = base64.urlsafe_b64decode(s + "=" * ((4 - len(s) % 4) % 4))
except Exception:
return False
# Must be a zlib stream that inflates to a short ASCII payload.
try:
msg = zlib.decompress(raw)
except Exception:
return False
if not (16 <= len(msg) <= 64):
return False
try:
t = msg.decode("ascii")
except Exception:
return False
if any(ord(c) < 32 or ord(c) > 126 for c in t):
return False
# Payload format: KEY{<8 hex>}|<6 digits>
m = re.fullmatch(r"KEY\{([0-9a-f]{8})\}\|([0-9]{6})", t)
if not m:
return False
hx, digits = m.group(1), m.group(2)
a = int(hx, 16)
ds = sum(int(c) for c in digits)
# Numeric constraints (non-obvious but checkable).
if (a ^ int(digits)) & 0xFFFF != 0xB00B:
return False
if ds % 9 != 0:
return False
if (a + ds * 1337) % 65521 != 4242:
return False
# Outer/inner binding with hashes and a 32-bit condition.
h1 = hashlib.sha256(msg).digest()
h2 = hashlib.blake2s(raw, digest_size=32).digest()
folded = bytes(u ^ v for u, v in zip(h1, h2))
w0, w1, w2, w3 = struct.unpack("<4I", folded[:16])
return ((w0 + w2) ^ (w1 + w3)) & 0xFFFFFFFF == 0xDEADC0DE