def mystery(x):
if not isinstance(x, int):
return False
if x <= 1:
return False
divisor_sum = sum(i for i in range(1, x) if x % i == 0)
return divisor_sum == x
def mystery(x):
if not isinstance(x, int):
return False
if x <= 0:
return False
s_x = str(x)
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
# Condition 1: Sum of digits is prime
sum_digits = sum(int(digit) for digit in s_x)
if not is_prime(sum_digits):
return False
# Condition 2: Reversed number is prime
# Interpret "reversed number" as the integer value of the reversed digit string.
# E.g., 120 -> 21, 10 -> 1.
reversed_x_str = s_x[::-1]
# Handle cases where reversed string might have leading zeros for multi-digit numbers,
# but the integer conversion naturally handles it (e.g., "01" becomes 1).
reversed_x = int(reversed_x_str)
if not is_prime(reversed_x):
return False
# Condition 3: Product of digits is a perfect square
product_digits = 1
for digit_char in s_x:
digit = int(digit_char)
if digit == 0:
product_digits = 0
break
product_digits *= digit
if product_digits < 0: # Should not happen with positive digits
return False
# Check if product_digits is a perfect square
sqrt_prod = int(product_digits**0.5)
if sqrt_prod * sqrt_prod != product_digits:
return False
return True
def mystery(x):
if not isinstance(x, str):
return False
if len(x) == 0:
return False
# Check if x is a valid Roman numeral that equals its length times 7
roman_values = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
# Validate characters
for char in x.upper():
if char not in roman_values:
return False
# Convert Roman numeral to integer
x_upper = x.upper()
total = 0
for i in range(len(x_upper)):
value = roman_values[x_upper[i]]
if i + 1 < len(x_upper) and roman_values[x_upper[i+1]] > value:
total -= value
else:
total += value
return total == len(x) * 7
def mystery(x):
# Condition 1: x must be a string
if not isinstance(x, str):
return False
# Condition 2: The string x must represent a valid positive number in a specific base (let's call it B)
# and must be composed only of digits valid for that base.
base = 7 # This specific base is a critical part of the puzzle
if not x: # Empty string is not a valid positive number
return False
for char_digit in x:
# Check if character is a valid digit for the chosen base (0 to base-1)
# For base 7, valid digits are '0', '1', '2', '3', '4', '5', '6'.
if not ('0' <= char_digit < str(base)):
return False
try:
# Convert x from base 'base' to its decimal (base 10) integer value
decimal_val = int(x, base)
except ValueError:
# This case should ideally be covered by the char_digit loop, but good for robustness
return False
# Condition 3: The decimal value must be a "Powerful Number"
# A positive integer n is a powerful number if for every prime p dividing n, p^2 also divides n.
# (Equivalently, all prime factors in its prime factorization must have an exponent of at least 2).
# The number 1 is considered a powerful number.
if decimal_val <= 0: # 0 is not powerful. We are looking for positive numbers.
return False
def is_powerful_number(n_val):
if n_val == 1:
return True
temp_n = n_val
d = 2
while d * d <= temp_n:
if temp_n % d == 0:
count = 0
while temp_n % d == 0:
count += 1
temp_n //= d
if count < 2: # If any prime factor has an exponent of 1, it's not powerful
return False
d += 1
# If after dividing by all primes up to sqrt(temp_n), temp_n > 1,
# it means the remaining temp_n is a prime factor raised to the power of 1.
# So, it's not powerful.
if temp_n > 1:
return False
return True
if not is_powerful_number(decimal_val):
return False
# Condition 4: The sum of the digits of the decimal_val (in base 10) must be equal to the original base (7).
sum_decimal_digits = sum(int(digit) for digit in str(decimal_val))
if sum_decimal_digits != base:
return False
return True
def mystery(x):
if not isinstance(x, str):
return False
if len(x) < 2:
return False
# Condition 1: All characters must be uppercase letters
if not x.isupper() or not x.isalpha():
return False
# Condition 2: Characters must be in strictly increasing order
for i in range(len(x) - 1):
if x[i] >= x[i+1]:
return False
# Condition 3: Sum of positions (A=1, B=2, ..., Z=26) must equal length squared
positions = [ord(c) - ord('A') + 1 for c in x]
if sum(positions) != len(x) ** 2:
return False
# Condition 4: Product of positions must be divisible by length
product = 1
for p in positions:
product *= p
if product % len(x) != 0:
return False
return True
import math
def mystery(x):
# Condition 1: x must be a non-empty string consisting only of unique lowercase English letters.
if not isinstance(x, str) or not x:
return False
if not all(c.islower() and c.isalpha() for c in x):
return False
if len(set(x)) != len(x): # Check for unique characters
return False
# Condition 2: Calculate the "seed" number S.
# S is the sum of the positional values of the characters (a=1, b=2, ..., z=26).
S = sum(ord(c) - ord('a') + 1 for c in x)
# Condition 3: The "modifier" number M is the length of the string x.
M = len(x)
# Condition 4: Generate a sequence of M numbers.
# The first number is S. Each subsequent number is the sum of the digits (in base 10) of the previous number.
def sum_digits(n):
return sum(int(digit) for digit in str(n))
seq = [S]
for _ in range(M - 1):
seq.append(sum_digits(seq[-1]))
# Helper functions for numerical checks
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
def is_perfect_square(n):
if n < 0: return False
sqrt_n = int(n**0.5)
return sqrt_n * sqrt_n == n
# Condition 5: The last number in the generated sequence must be a prime number.
if not is_prime(seq[-1]):
return False
# Condition 6: The sum of all numbers in the generated sequence must be a perfect square.
if not is_perfect_square(sum(seq)):
return False
# Condition 7: The product of all numbers in the generated sequence must be divisible by M.
# Note: S is always positive (sum of positive positional values), so all numbers in seq will be positive.
if math.prod(seq) % M != 0:
return False
return True
def mystery(x):
if not isinstance(x, int):
return False
if x <= 10:
return False
# Check if x is a perfect square
sqrt_x = int(x ** 0.5)
if sqrt_x * sqrt_x != x:
return False
# Check if x is triangular (x = n(n+1)/2 for some positive integer n)
# Solving: n^2 + n - 2x = 0, we get n = (-1 + sqrt(1+8x))/2
discriminant = 1 + 8 * x
sqrt_disc = int(discriminant ** 0.5)
if sqrt_disc * sqrt_disc != discriminant:
return False
n = (-1 + sqrt_disc) // 2
if n * (n + 1) // 2 != x:
return False
# Check if digit sum is also triangular
digit_sum = sum(int(d) for d in str(x))
discriminant2 = 1 + 8 * digit_sum
sqrt_disc2 = int(discriminant2 ** 0.5)
if sqrt_disc2 * sqrt_disc2 != discriminant2:
return False
n2 = (-1 + sqrt_disc2) // 2
if n2 * (n2 + 1) // 2 != digit_sum:
return False
# Check if product of digits is divisible by digit sum
digit_product = 1
for d in str(x):
digit_product *= int(d)
if digit_sum == 0 or digit_product % digit_sum != 0:
return False
return True
import math
def mystery(x):
# Ensure x is a positive integer
if not isinstance(x, int) or x <= 0:
return False
# Helper function to convert a number to a string representation in a given base
def to_base_n(n, base):
if n == 0:
return "0"
digits = []
temp_n = n
while temp_n > 0:
digits.append(str(temp_n % base))
temp_n //= base
return "".join(digits[::-1])
# Helper function to check if a string is a palindrome
def is_palindrome(s):
return s == s[::-1]
# Helper function to calculate the product of base-10 digits
def prod_digits_base10(n):
if n == 0: return 0
product = 1
for digit_char in str(n):
product *= int(digit_char)
return product
# Helper function to calculate the sum of digits in a given base
def sum_digits_base_n(n, base):
s_base_n = to_base_n(n, base)
return sum(int(d) for d in s_base_n)
# Helper function to check if a number is a perfect cube
def is_perfect_cube(n):
if n < 0: return False
cbrt_n = round(n**(1/3)) # Using round for floating point precision
return cbrt_n * cbrt_n * cbrt_n == n
# Helper function to check if a number is prime
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
# Helper function to calculate the sum of base-10 digits
def sum_digits_base10(n):
return sum(int(digit) for digit in str(n))
# Condition 1: x must be a palindrome when written in base 5.
base5_str = to_base_n(x, 5)
if not is_palindrome(base5_str):
return False
# Condition 2: The product of the decimal (base 10) digits of x must be a perfect cube.
prod_dec_digits = prod_digits_base10(x)
if not is_perfect_cube(prod_dec_digits):
return False
# Condition 3: The sum of the digits of x when written in base 5 must be a prime number.
sum_base5_digits = sum_digits_base_n(x, 5)
if not is_prime(sum_base5_digits):
return False
# Condition 4: Let y be the number formed by reversing the base 10 digits of x.
# The sum of the decimal digits of (x + y) must be a prime number.
s_x = str(x)
y = int(s_x[::-1]) # y is x with its base 10 digits reversed
sum_digits_of_sum = sum_digits_base10(x + y)
if not is_prime(sum_digits_of_sum):
return False
return True
def mystery(x):
if not isinstance(x, int):
return False
if x <= 100:
return False
# Condition 1: x must be divisible by the sum of its digits (Harshad number)
digit_sum = sum(int(d) for d in str(x))
if x % digit_sum != 0:
return False
# Condition 2: The quotient must also be divisible by its digit sum
quotient = x // digit_sum
quotient_digit_sum = sum(int(d) for d in str(quotient))
if quotient % quotient_digit_sum != 0:
return False
# Condition 3: The second quotient must be prime
second_quotient = quotient // quotient_digit_sum
def is_prime(n):
if n < 2:
return False
for i in range(2, int(n ** 0.5) + 1):
if n % i == 0:
return False
return True
if not is_prime(second_quotient):
return False
return True
import math
def mystery(x):
# Condition 1: x must be a string.
if not isinstance(x, str):
return False
# Condition 2: x must contain only lowercase English letters.
if not x.islower() or not x.isalpha():
return False
# Condition 3: x must be a palindrome.
if x != x[::-1]:
return False
# Helper: Calculate the "numeric value" of x (a=1, b=2, ..., z=26).
# This value must be positive, which is guaranteed if x is non-empty and contains letters.
numeric_value = sum(ord(c) - ord('a') + 1 for c in x)
# Condition 4: The "numeric value" of x must be a perfect square.
if numeric_value <= 0: # Should not happen with valid input
return False
sqrt_val = int(numeric_value**0.5)
if sqrt_val * sqrt_val != numeric_value:
return False
# Condition 5: The length of x must be a prime number.
length_x = len(x)
if length_x < 2: # 0 and 1 are not prime
return False
for i in range(2, int(length_x**0.5) + 1):
if length_x % i == 0:
return False
# Condition 6: The number of distinct prime factors of the "numeric value" of x must be equal to the length of x.
def count_distinct_prime_factors(n):
if n <= 1: # 0 and 1 have no prime factors
return 0
factors = set()
d = 2
temp_n = n
while d * d <= temp_n:
if temp_n % d == 0:
factors.add(d)
while temp_n % d == 0:
temp_n //= d
d += 1
if temp_n > 1: # Remaining temp_n is a prime factor
factors.add(temp_n)
return len(factors)
if count_distinct_prime_factors(numeric_value) != length_x:
return False
return True