def mystery(x):
if not isinstance(x, int) or x <= 0:
return False
f = lambda n: n > 1 and all(n % i for i in range(2, int(n**0.5) + 1))
g = lambda n: next(i for i in range(n + 1, n + 100) if f(i))
h = lambda n: sum(int(d) for d in str(n))
for p in range(2, int(x**0.5) + 1):
if x % p == 0:
q = x // p
if f(p) and f(q) and g(p) == q and h(x) == h(p) + h(q) - 1 and h(p) * h(q) == 80:
return True
return False
def mystery(x):
if not isinstance(x, str):
return False
parts = x.split('_')
if len(parts) != 2:
return False
s1, s2 = parts
if not s1 or not s2:
return False
try:
n1 = int(s1)
n2 = int(s2)
except ValueError:
return False
if n1 <= 0 or n2 <= 0:
return False
def _is_palindrome(val):
return str(val) == str(val)[::-1]
def _is_perfect_square(val):
if val < 0: return False
sqrt_val = int(val**0.5)
return sqrt_val * sqrt_val == val
def _is_perfect_square_palindrome(val):
return _is_perfect_square(val) and _is_palindrome(val)
# A highly composite number has more divisors than any smaller positive integer.
# This list contains the first few highly composite numbers, up to 720.
_highly_composite_numbers_small = [1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720]
def _is_highly_composite(val):
return val in _highly_composite_numbers_small
def _is_alternating_binary(val):
if val < 0: return False
if val == 0: return True # "0" is considered alternating
binary_str = bin(val)[2:]
for i in range(len(binary_str) - 1):
if binary_str[i] == binary_str[i+1]:
return False
return True
# Condition 1: n1 must be a positive perfect square that is also a palindrome.
cond1 = _is_perfect_square_palindrome(n1)
# Condition 2: n2 must be a positive highly composite number from a specific small set.
cond2 = _is_highly_composite(n2)
# Condition 3: The result of n1 XOR n2 must have a binary representation
# where bits strictly alternate (e.g., 10101, 1010, 010101).
cond3 = _is_alternating_binary(n1 ^ n2)
return cond1 and cond2 and cond3
def mystery(x):
if not isinstance(x, int) or x < 100 or x > 9999:
return False
def f(n, r):
d = []
while n:
d.append(n % r)
n //= r
return d[::-1] if d else [0]
def g(s):
return s == s[::-1]
def h(n):
return int(n ** 0.5) ** 2 == n
a, b, c = f(x, 7), f(x, 5), f(x, 3)
p = 1
for d in c:
p *= max(d, 1)
s = sum(int(i) for i in str(x))
return g(a) and len(b) == sum(a) and p == s and h(x)
import math
def mystery(x):
# Condition 1: x must be an integer greater than 100
if not isinstance(x, int) or x <= 100:
return False
s_x = str(x)
# Condition 2: The string representation of x must be a palindrome
if s_x != s_x[::-1]:
return False
# Helper functions (nested for obscurity and self-containment)
def _is_prime(num):
if num < 2:
return False
for i in range(2, int(math.sqrt(num)) + 1):
if num % i == 0:
return False
return True
def _sum_digits(n_val):
return sum(int(d) for d in str(n_val))
def _product_digits(n_val):
prod = 1
for d in str(n_val):
prod *= int(d)
return prod
def _is_perfect_square(num):
if num < 0: return False
if num == 0: return True # 0 is 0^2
sqrt_val = int(num**0.5)
return sqrt_val * sqrt_val == num
def _has_duplicate_digits(n_val):
s_n = str(n_val)
return len(s_n) != len(set(s_n))
# Condition 3: The sum of x's digits must be a prime number
sum_of_digits = _sum_digits(x)
if not _is_prime(sum_of_digits):
return False
# Condition 4: The product of x's digits must be a perfect square
product_of_digits = _product_digits(x)
if not _is_perfect_square(product_of_digits):
return False
# Condition 5: x must contain at least two identical digits
if not _has_duplicate_digits(x):
return False
return True
def mystery(x):
if not isinstance(x, int) or x < 100000:
return False
s = str(x)
def f(n):
if n < 2: return False
for i in range(2, int(n**0.5)+1):
if n % i == 0: return False
return True
p = 1
for d in s:
if d == '0': return False
p *= int(d)
t = sum(int(d) for d in s)
r = x % t
q = int(r ** 0.5)
return f(len(s)) and p == t * t and q * q == r
import math
def mystery(x):
# Condition 0: x must be a positive integer
if not isinstance(x, int) or x <= 0:
return False
s_x = str(x)
len_x = len(s_x)
# Helper functions
def _is_prime(num):
if num < 2: return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0: return False
return True
def _sum_digits(n):
return sum(int(d) for d in str(n))
def _is_perfect_square(n):
if n < 0: return False
sqrt_n = int(n**0.5)
return sqrt_n * sqrt_n == n
# Condition 1: The sum of digits of x must be a perfect square.
sum_d = _sum_digits(x)
if not _is_perfect_square(sum_d):
return False
# Condition 2: The number of digits in x must be a prime number.
if not _is_prime(len_x):
return False
# Condition 3: The last digit of x must be a prime number.
last_digit = int(s_x[-1])
if not _is_prime(last_digit):
return False
# Condition 4: x must be a "Powerful Number" (a positive integer n such that for every prime factor p of n, p^2 also divides n).
def _get_prime_factors(n):
factors = set()
d = 2
temp = n
while d * d <= temp:
if temp % d == 0:
factors.add(d)
while temp % d == 0:
temp //= d
d += 1
if temp > 1:
factors.add(temp)
return factors
def _is_powerful_number(n):
if n == 1: return True # 1 is powerful by convention
factors = _get_prime_factors(n)
for p in factors:
if n % (p * p) != 0:
return False
return True
if not _is_powerful_number(x):
return False
# Condition 5: The number formed by the first two digits of x, when reversed, must be a prime number.
# (If x has less than 2 digits, this fails).
if len_x < 2:
return False
first_two_digits_str = s_x[:2]
reversed_first_two_digits_str = first_two_digits_str[::-1]
# Check if the reversed string can be converted to an int and is prime.
# This implies the reversed string should not start with '0', unless it's a single digit.
try:
reversed_first_two_digits_num = int(reversed_first_two_digits_str)
except ValueError: # This should not happen if len_x >= 2 and first_two_digits_str is valid
return False
if not _is_prime(reversed_first_two_digits_num):
return False
return True
def mystery(x):
if not isinstance(x, int) or x <= 0:
return False
s = str(x)
n = len(s)
if n < 4:
return False
f = lambda a: a > 1 and all(a % i for i in range(2, int(a**0.5)+1))
g = lambda a: sum(int(c) for c in str(a))
h = lambda a: int(str(a)[::-1])
def k(a):
p = 1
for c in str(a):
if int(c) & 1:
p *= int(c)
return p
w = x + h(x)
return f(g(x)) and f(n - 1) and str(w) == str(w)[::-1] and k(x) == g(x)
import math
def mystery(x):
# Condition 0: x must be a positive integer
if not isinstance(x, int) or x <= 0:
return False
s_x = str(x)
len_x = len(s_x)
# Helper functions
def _is_prime(num):
"""Checks if a number is prime."""
if num < 2: return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0: return False
return True
def _is_happy(n):
"""
Checks if a number is a 'Happy Number'.
A number is happy if, starting with it, repeatedly replacing it with the sum of the squares of its digits
eventually reaches 1. Numbers that are not happy eventually loop in a cycle that does not include 1.
"""
seen = set()
current = n
while current != 1 and current not in seen:
seen.add(current)
current = sum(int(digit)**2 for digit in str(current))
return current == 1
def _is_narcissistic(n):
"""
Checks if a number is a 'Narcissistic Number'.
An n-digit number that is the sum of the nth powers of its digits.
(e.g., 153 = 1^3 + 5^3 + 3^3).
"""
s_n = str(n)
num_digits = len(s_n)
if num_digits == 0: return False
calculated_sum = 0
for digit in s_n:
calculated_sum += int(digit)**num_digits
return calculated_sum == n
def _get_distinct_prime_factors_count(n):
"""Counts the number of distinct prime factors of n."""
if n == 1: return 0
count = 0
d = 2
temp = n
while d * d <= temp:
if temp % d == 0:
count += 1
while temp % d == 0:
temp //= d
d += 1
if temp > 1: # Remaining temp is a prime factor
count += 1
return count
def _has_odd_parity_binary(n):
"""Checks if the binary representation of a positive number has an odd number of '1' bits."""
if n < 0: return False # Parity is typically defined for non-negative integers
return bin(n).count('1') % 2 == 1
# Condition 1: The number of digits of x must be an odd prime number.
# (e.g., 3, 5, 7, 11, ...)
if not _is_prime(len_x) or len_x == 2: # 2 is prime, but even. We need odd primes.
return False
first_digit = int(s_x[0])
# Ensure the first digit is not zero (standard for integer representation, and relevant for C4)
if first_digit == 0:
return False
sum_digits_x = sum(int(d) for d in s_x)
# Condition 3: The sum of the digits of x must be a Narcissistic Number.
# Note: For typical integer lengths (e.g., 3, 5, 7 digits), the sum of digits will be small.
# This implies that the sum of digits itself must be a 1-digit narcissistic number (i.e., 1-9).
if not _is_narcissistic(sum_digits_x):
return False
# Condition 2: x must be a Happy Number.
if not _is_happy(x):
return False
# Condition 4: The number of distinct prime factors of x must be equal to the first digit of x.
if _get_distinct_prime_factors_count(x) != first_digit:
return False
# Condition 5: The result of (x XOR (sum_of_digits_x * first_digit)) must have
# an odd number of '1' bits in its binary representation (odd parity).
bitwise_operand = sum_digits_x * first_digit
if not _has_odd_parity_binary(x ^ bitwise_operand):
return False
return True
def mystery(x):
if not isinstance(x, int) or x < 10000 or x > 99999:
return False
s = str(x)
f = lambda a: a > 1 and all(a % i for i in range(2, int(a**0.5)+1))
g = sum(int(c) for c in s)
h = int(s[0]) * int(s[4]) + int(s[1]) * int(s[3])
k = int(s[2])
return f(g) and h == k * k and s == s[::-1] and f(len(s))
import math
class MysterySolver:
_FIBONACCI_SET = {0, 1, 2, 3, 5, 8, 13, 21, 34} # Max sum of 3 digits (9+9+9=27) is small enough
def _is_perfect_square(self, n):
"""Checks if a number is a perfect square."""
if n < 0: return False
sqrt_n = int(n**0.5)
return sqrt_n * sqrt_n == n
def mystery(self, x):
# Condition 0: x must be a 5-digit integer
if not isinstance(x, int) or not (10000 <= x <= 99999):
return False
s_x = str(x)
# Condition 1: x must not contain any prime digits (2, 3, 5, 7).
# This implies digits can only be {0, 1, 4, 6, 8, 9}.
# Also, the first digit (s_x[0]) cannot be '0' as x is a 5-digit number.
allowed_digits = {'0', '1', '4', '6', '8', '9'}
for digit_char in s_x:
if digit_char not in allowed_digits:
return False
d_list = [int(d) for d in s_x]
# Condition 2: The sum of digits at prime positions (1-based) must be a Fibonacci number.
# For a 5-digit number, prime positions are 2, 3, 5. Digits are d_list[1], d_list[2], d_list[4].
prime_pos_sum = d_list[1] + d_list[2] + d_list[4]
if prime_pos_sum not in self._FIBONACCI_SET:
return False
# Condition 3: The sum of the squares of the digits of x must be a perfect square.
sum_squares_digits = sum(d**2 for d in d_list)
if not self._is_perfect_square(sum_squares_digits):
return False
return True
# To use the mystery function:
# solver = MysterySolver()
# solver.mystery(x)