def mystery(x):
# x must be a string formatted as "a,b,c,d" containing four integers
if not isinstance(x, str):
return False
try:
parts = list(map(int, x.split(',')))
except ValueError:
return False
if len(parts) != 4:
return False
a, b, c, d = parts
# Constraint 1: Positive integers
if a <= 0 or b <= 0 or c <= 0 or d <= 0:
return False
# Constraint 2: Linear combination
if a + b + c + d != 3200:
return False
# Constraint 3: Geometric relation
if a**2 + b**2 + c**2 != d**2:
return False
# Constraint 4: Product constraint
if a * b * c * d != 187200000000:
return False
return True
import math
from collections import Counter
def mystery(x):
# Helper functions are nested to encapsulate logic within the mystery function.
def _is_prime(k):
if k < 2:
return False
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
return False
return True
def _sum_digits(k):
return sum(int(digit) for digit in str(k))
def _reverse_int(k):
return int(str(k)[::-1])
if not isinstance(x, str):
return False
# The input string must be formatted as "NUMBER:TEXT"
parts = x.split(':')
if len(parts) != 2:
return False
num_str, text_part = parts
# The first part must be a positive integer
try:
n = int(num_str)
except ValueError:
return False
if n <= 0:
return False
# Condition 1: n must be a prime number.
if not _is_prime(n):
return False
# Condition 2: n must be a Sophie Germain prime (i.e., 2n+1 must also be prime).
if not _is_prime(2 * n + 1):
return False
# Condition 3: n must be an "emirp" (a prime number whose reverse is also a prime number, and different from n).
reversed_n = _reverse_int(n)
if n == reversed_n or not _is_prime(reversed_n):
return False
# Condition 4: The sum of the digits of n must also be a prime number.
if not _is_prime(_sum_digits(n)):
return False
# Condition 5: The text part must be a palindrome.
if text_part != text_part[::-1]:
return False
# Condition 6: The text part must consist only of lowercase English letters.
if not text_part.islower() or not text_part.isalpha():
return False
# Condition 7: The length of the text part must be equal to (n modulo 10) + (number of digits in n).
expected_len = (n % 10) + len(str(n))
if len(text_part) != expected_len:
return False
# Condition 8: The count of each unique character in the text_part must be a prime number.
char_counts = Counter(text_part)
for count in char_counts.values():
if not _is_prime(count):
return False
return True
def mystery(x):
# Input must be a string
if not isinstance(x, str):
return False
# Length constraint: The key is exactly 8 characters long
if len(x) != 8:
return False
# Character set constraint: Printable ASCII only
if any(ord(c) < 32 or ord(c) > 126 for c in x):
return False
# Prefix constraint: A hint towards the intended solving method?
if not x.startswith("Z3"):
return False
# Convert characters to integer values for mathematical checks
vals = [ord(c) for c in x]
# Constraint 1: Rolling Hash Check
# This implements a standard polynomial rolling hash (similar to Java's String.hashCode)
# but enforced with 32-bit integer overflow wrapping.
h = 0
for v in vals:
h = (h * 31 + v) & 0xFFFFFFFF
if h != 2926186887:
return False
# Constraint 2: Non-linear Product Relation
# Checks a relationship between the 3rd, 4th, 5th, and 6th characters.
if vals[2] * vals[3] - vals[4] * vals[5] != 3038:
return False
# Constraint 3: Bitwise Relation
# Checks a relationship between the last two characters.
if vals[6] ^ vals[7] != 24:
return False
# Constraint 4: Sparse Linear Sum
# Checks a sum of specific characters at even indices (relative to the suffix).
if vals[2] + vals[4] + vals[6] != 250:
return False
return True
import math
def mystery(x):
# Helper function for prime check
def is_prime(k):
if k < 2:
return False
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
return False
return True
# Scrabble letter scores (standard English version)
scrabble_scores = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8,
'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1,
'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
# 1. Basic Type and Format Check
# The input must be a string formatted as "[HEX_VALUE];[WORD1]:[WORD2];[NUMBER_SEQUENCE]"
if not isinstance(x, str):
return False
parts = x.split(';')
if len(parts) != 3:
return False
hex_part, word_parts, num_sequence_part = parts
# 2. Hex Part Constraints
# 2a. Must be a valid hexadecimal string and convert to a positive integer.
try:
n_hex = int(hex_part, 16)
except ValueError:
return False
if n_hex <= 0:
return False
# 2b. n_hex must be a perfect cube.
# We check this by taking the cube root, rounding to the nearest integer, and cubing it back.
cbrt_n = round(n_hex**(1/3))
if cbrt_n**3 != n_hex:
return False
# 2c. The sum of digits of the base-10 representation of n_hex must be a prime number.
sum_digits_n_hex = sum(int(digit) for digit in str(n_hex))
if not is_prime(sum_digits_n_hex):
return False
# 3. Word Parts Constraints
# 3a. Format: WORD1:WORD2.
words = word_parts.split(':')
if len(words) != 2:
return False
word1, word2 = words
# 3b. Both words must be purely alphabetic and lowercase.
if not (word1.isalpha() and word1.islower() and word2.isalpha() and word2.islower()):
return False
# 3c. word1 must be an "isogram" (a word with no repeating letters).
if len(set(word1)) != len(word1):
return False
# 3d. The "Scrabble score" of word1 must be equal to the length of word2.
word1_score = sum(scrabble_scores.get(c, 0) for c in word1)
if word1_score != len(word2):
return False
# 3e. word2 must be a palindrome.
if word2 != word2[::-1]:
return False
# 3f. The sum of ASCII values of word2 must be equal to (n_hex modulo 100).
ascii_sum_word2 = sum(ord(c) for c in word2)
if ascii_sum_word2 != (n_hex % 100):
return False
# 4. Number Sequence Part Constraints
# 4a. Format: comma-separated positive integers.
try:
nums_str = num_sequence_part.split(',')
nums = [int(s.strip()) for s in nums_str]
except ValueError:
return False
# 4b. Must contain exactly 5 numbers.
if len(nums) != 5:
return False
# 4c. All numbers must be positive.
if any(n <= 0 for n in nums):
return False
# 4d. The numbers must follow a specific pattern:
# Each number (except the first two) must be the sum of the previous two plus an index offset.
# nums[i] = nums[i-1] + nums[i-2] + (i-1) for i >= 2.
if not (nums[2] == nums[1] + nums[0] + 1 and
nums[3] == nums[2] + nums[1] + 2 and
nums[4] == nums[3] + nums[2] + 3):
return False
# 4e. The sum of all numbers in the sequence must be divisible by (length of word1 + length of word2).
# And the result of this division must be equal to n_hex.
total_sum_nums = sum(nums)
divisor = len(word1) + len(word2)
if divisor == 0 or total_sum_nums % divisor != 0 or total_sum_nums // divisor != n_hex:
return False
return True
import math
def mystery(x):
# Input must be a string in the format "PART1-PART2-PART3"
if not isinstance(x, str):
return False
# Enforce uppercase to fix the exact string representation
if x != x.upper():
return False
parts = x.split('-')
if len(parts) != 3:
return False
# Parse parts as base-36 integers
try:
a = int(parts[0], 36)
b = int(parts[1], 36)
c = int(parts[2], 36)
except ValueError:
return False
# Helper functions for number properties
def is_prime(n):
if n < 2: return False
if n == 2 or n == 3: return True
if n % 2 == 0 or n % 3 == 0: return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True
def is_triangular(n):
# A number n is triangular if 8n + 1 is a perfect square
if n <= 0: return False
val = 8 * n + 1
r = math.isqrt(val)
return r * r == val
def is_fibonacci(n):
# A number n is Fibonacci if 5n^2 + 4 or 5n^2 - 4 is a perfect square
if n < 0: return False
val1 = 5 * n * n + 4
val2 = 5 * n * n - 4
r1 = math.isqrt(val1)
r2 = math.isqrt(val2)
return (r1 * r1 == val1) or (r2 * r2 == val2)
# Constraint 1: The first number must be within a specific range
if not (1000 <= a <= 2000):
return False
# Constraint 2: The first number must be Prime
if not is_prime(a):
return False
# Constraint 3: The second number must be a positive Triangular number
# and must be divisible by 7
if b <= 0 or not is_triangular(b) or b % 7 != 0:
return False
# Constraint 4: The third number must be a Fibonacci number
if not is_fibonacci(c):
return False
# Constraint 5: The numbers must satisfy the additive relationship A + B = C
if a + b != c:
return False
return True
import math
from collections import Counter
def mystery(x):
# Helper functions are nested to encapsulate logic within the mystery function.
def is_prime(k):
if k < 2:
return False
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
return False
return True
def _reverse_int(k):
return int(str(k)[::-1])
def is_triangular(n):
# A number n is triangular if 8n + 1 is a perfect square
if n <= 0: return False
val = 8 * n + 1
r = math.isqrt(val)
return r * r == val
def is_deficient_number(k):
# A number k is deficient if the sum of its proper divisors is less than k.
# Primes are deficient.
if k <= 0: return False
if k == 1: return True # 1 is deficient
divisors_sum = 1
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
divisors_sum += i
if i * i != k:
divisors_sum += k // i
return divisors_sum < k
def get_distinct_prime_factors_count(k):
if k <= 1: return 0
count = 0
temp_k = k
d = 2
while d * d <= temp_k:
if temp_k % d == 0:
count += 1
while temp_k % d == 0: # Divide out d completely
temp_k //= d
d += 1
if temp_k > 1: # Remaining factor is prime
count += 1
return count
def is_fibonacci(n):
# A number n is Fibonacci if 5n^2 + 4 or 5n^2 - 4 is a perfect square
if n < 0: return False
val1 = 5 * n * n + 4
val2 = 5 * n * n - 4
r1 = math.isqrt(val1)
r2 = math.isqrt(val2)
return (r1 * r1 == val1) or (r2 * r2 == val2)
def is_palindromic_prime(k):
return is_prime(k) and str(k) == str(k)[::-1]
# Scrabble letter scores (standard English version)
scrabble_scores = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8,
'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1,
'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
# 1. Basic Type and Format Check
# The input must be a string formatted as "NUM_A;WORD_B;NUM_C"
if not isinstance(x, str):
return False
parts = x.split(';')
if len(parts) != 3:
return False
num_a_str, word_b_str, num_c_str = parts
# 2. NUM_A Constraints
# 2a. Must be a string representing a positive integer. Convert to A.
try:
A = int(num_a_str)
except ValueError:
return False
if A <= 0:
return False
# 2b. A must be a "Triangular number".
if not is_triangular(A):
return False
# 2c. The reverse of A (as an integer) must be a prime number.
reversed_A = _reverse_int(A)
if not is_prime(reversed_A):
return False
# 2d. A must be a "Deficient Number".
if not is_deficient_number(A):
return False
# Precompute values needed for later constraints
distinct_prime_factors_A = get_distinct_prime_factors_count(A)
# 3. WORD_B Constraints
# 3a. Must contain only lowercase English letters.
if not word_b_str.isalpha() or not word_b_str.islower():
return False
# 3b. Length of WORD_B (L) must be a Fibonacci number.
L = len(word_b_str)
if not is_fibonacci(L):
return False
# 3c. WORD_B must be an "isogram" (no repeating letters).
if len(set(word_b_str)) != L:
return False
# 3d. The "Scrabble score" of WORD_B must be equal to the number of distinct prime factors of A.
scrabble_score_B = sum(scrabble_scores.get(c, 0) for c in word_b_str)
if scrabble_score_B != distinct_prime_factors_A:
return False
# 4. NUM_C Constraints
# 4a. Must be a string representing a positive integer. Convert to C.
try:
C = int(num_c_str)
except ValueError:
return False
if C <= 0:
return False
# 4b. C must be a "Palindromic Prime".
if not is_palindromic_prime(C):
return False
# 4c. C must be equal to A + L + Scrabble_score_B.
if C != A + L + scrabble_score_B:
return False
return True
import math
def mystery(x):
# Standard English Scrabble scores
SCORES = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8,
'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1,
'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
# Alphabetically first letter for each score group (excluding 'z')
# 1:a, 2:d, 3:b, 4:f, 5:k, 8:j, 10:q
OPTIMAL_CHARS = {1: 'a', 2: 'd', 3: 'b', 4: 'f', 5: 'k', 8: 'j', 10: 'q'}
if not isinstance(x, str):
return False
# Input format: NUMBER-STRING-HASH
parts = x.split('-')
if len(parts) != 3:
return False
n_str, s_str, h_str = parts
# --- Part 1: The Number N ---
try:
n = int(n_str)
except ValueError:
return False
# Range constraint
if not (150 < n < 250):
return False
# Prime checks helper
def is_prime(k):
if k < 2: return False
for i in range(2, int(math.isqrt(k)) + 1):
if k % i == 0: return False
return True
# N must be a prime number
if not is_prime(n):
return False
# N must be a Sophie Germain Prime (i.e., 2N + 1 is also prime)
if not is_prime(2 * n + 1):
return False
# Modular constraint
if n % 8 != 7:
return False
# --- Part 2: The String S ---
# Length must equal the sum of the digits of N
if len(s_str) != sum(int(d) for d in str(n)):
return False
# Palindrome check
if s_str != s_str[::-1]:
return False
# Scrabble score check: Score must equal N integer divided by 4
total_score = sum(SCORES.get(c, 0) for c in s_str)
if total_score != n // 4:
return False
# Content constraints
if 'z' not in s_str:
return False
if 'k' not in s_str:
return False
if 'a' in s_str: # 'a' is forbidden
return False
# Structure constraint:
# The first half of the string (up to and including the center)
# must be non-increasing in ASCII value.
mid = len(s_str) // 2
first_half = s_str[:mid+1]
for i in range(len(first_half) - 1):
if first_half[i] < first_half[i+1]:
return False
# Optimality constraint:
# Except for 'z', every character in S must be the alphabetically first character
# that has its specific Scrabble score.
# (e.g. if a character has score 3, it must be 'b', because 'b' comes before 'c','m','p')
for c in s_str:
if c == 'z':
continue
score = SCORES.get(c, 0)
if OPTIMAL_CHARS.get(score) != c:
return False
# --- Part 3: The Hash H ---
# H must be the integer formed by concatenating the ASCII values of the characters of S
expected_h = "".join(str(ord(c)) for c in s_str)
if h_str != expected_h:
return False
return True
import math
import datetime
def mystery(x):
# Helper functions
def is_prime(k):
if k < 2:
return False
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
return False
return True
def sum_digits(k):
return sum(int(digit) for digit in str(k))
def is_perfect_square(k):
if k < 0: return False
if k == 0: return True
s = int(math.isqrt(k))
return s * s == k
def is_perfect_number(k):
if k <= 1: return False
divisors_sum = 1 # Start with 1 as a proper divisor
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
divisors_sum += i
if i * i != k:
divisors_sum += k // i
return divisors_sum == k
def is_harshad_number(k):
if k <= 0: return False
s_digits = sum_digits(k)
return k % s_digits == 0
def is_fibonacci(n):
# A number n is Fibonacci if 5n^2 + 4 or 5n^2 - 4 is a perfect square
if n < 0: return False
val1 = 5 * n * n + 4
val2 = 5 * n * n - 4
return is_perfect_square(val1) or is_perfect_square(val2)
# Scrabble letter scores (standard English version)
scrabble_scores = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8,
'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1,
'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
# Alphabetical position (a=1, b=2, ...)
alpha_positions = {chr(i): i - ord('a') + 1 for i in range(ord('a'), ord('z') + 1)}
# 1. Basic Type and Format Check
# The input must be a string formatted as "NUMBER_PART;WORD_PART;DATE_PART"
if not isinstance(x, str):
return False
parts = x.split(';')
if len(parts) != 3:
return False
num_part_str, word_part_str, date_part_str = parts
# 2. NUMBER_PART (N) Constraints
# 2a. Must be a positive integer.
try:
N = int(num_part_str)
except ValueError:
return False
if N <= 0:
return False
# 2b. N must be a "Perfect number".
if not is_perfect_number(N):
return False
# 2c. N must be a "Harshad number" (divisible by the sum of its digits).
if not is_harshad_number(N):
return False
# 3. WORD_PART (W) Constraints
# 3a. Must contain only lowercase English letters.
if not word_part_str.isalpha() or not word_part_str.islower():
return False
# 3b. Length of W (L) must be equal to N + 2.
L = len(word_part_str)
if L != N + 2:
return False
# 3c. W must be an "isogram" (all unique letters).
if len(set(word_part_str)) != L:
return False
# 3d. W must contain exactly (N // 2) vowels (a, e, i, o, u).
vowels = "aeiou"
vowel_count = sum(1 for char in word_part_str if char in vowels)
if vowel_count != (N // 2):
return False
# 3e. The "Scrabble score" of W must be a Fibonacci number.
scrabble_score_W = sum(scrabble_scores.get(c, 0) for c in word_part_str)
if not is_fibonacci(scrabble_score_W):
return False
# 3f. The sum of numerical positions of letters in W (a=1, b=2...) must be equal to N * 10.
alpha_pos_sum_W = sum(alpha_positions.get(c, 0) for c in word_part_str)
if alpha_pos_sum_W != N * 10:
return False
# 4. DATE_PART (D) Constraints
# 4a. Must be a string formatted as "YYYY-MM-DD".
date_parts = date_part_str.split('-')
if len(date_parts) != 3:
return False
try:
year = int(date_parts[0])
month = int(date_parts[1])
day = int(date_parts[2])
except ValueError:
return False
# 4b. YYYY must be equal to N * 1000 + sum_digits(N) * 100 + (scrabble_score_W // 3).
expected_year = N * 1000 + sum_digits(N) * 100 + (scrabble_score_W // 3)
if year != expected_year:
return False
# 4c. MM must be a prime number.
if not is_prime(month):
return False
# 4d. DD must be a perfect square.
if not is_perfect_square(day):
return False
# 4e. The date "YYYY-MM-DD" must be a valid date.
try:
date_obj = datetime.date(year, month, day)
except ValueError:
return False
# 4f. The day of the week for this date must be a "Tuesday". (Monday is 0, Tuesday is 1, ..., Sunday is 6)
if date_obj.weekday() != 1:
return False
return True
def mystery(x):
# The input must be a string of 9 digits
if not isinstance(x, str) or len(x) != 9 or not x.isdigit():
return False
# The string must be a pandigital number (containing 1-9 exactly once)
if set(x) != set("123456789"):
return False
# Construct a 3x3 matrix from the digits
# Row 0: x[0], x[1], x[2]
# Row 1: x[3], x[4], x[5]
# Row 2: x[6], x[7], x[8]
m = [[int(x[i*3 + j]) for j in range(3)] for i in range(3)]
# Calculate Row Sums
r_sums = [sum(row) for row in m]
# Calculate Column Sums
c_sums = [sum(m[i][j] for i in range(3)) for j in range(3)]
# Constraint 1: Row sums must form an Arithmetic Progression
# (i.e., the difference between consecutive row sums is constant)
if r_sums[1] - r_sums[0] != r_sums[2] - r_sums[1]:
return False
# Constraint 2: Column sums must be a set of consecutive integers
# (e.g., {10, 11, 12}, though the order in the list doesn't matter)
if sorted(c_sums) != list(range(min(c_sums), min(c_sums) + 3)):
return False
# Constraint 3: Specific values for the column sums
# The column sums must be specifically 14, 15, and 16.
if sorted(c_sums) != [14, 15, 16]:
return False
# Constraint 4: The Determinant of the matrix must be 177
det = (m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1]) -
m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0]) +
m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]))
if det != 177:
return False
return True
import math
def mystery(x):
# Helper functions
def is_prime(k):
if k < 2:
return False
for i in range(2, int(math.sqrt(k)) + 1):
if k % i == 0:
return False
return True
def get_num_ones_in_binary(k):
return bin(k).count('1')
# Standard English Scrabble scores
scrabble_scores = {
'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8,
'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1,
'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10
}
def get_scrabble_score(word):
return sum(scrabble_scores.get(c.lower(), 0) for c in word)
def is_vowel(char):
return char.upper() in "AEIOU"
def is_consonant(char):
return char.isalpha() and not is_vowel(char)
def is_perfect_cube(k):
if k <= 0: return False
cbrt = round(k**(1/3))
return cbrt**3 == k
# 1. Basic Type and Format Check
# The input must be a string formatted as "BINARY_NUMBER;SPECIAL_WORD;SEQUENCE_OF_NUMBERS"
if not isinstance(x, str):
return False
parts = x.split(';')
if len(parts) != 3:
return False
num_a_str, word_b_str, num_sequence_str = parts
# 2. BINARY_NUMBER (N) Constraints
# 2a. Must be a string representing a valid binary number and convert to a positive integer.
try:
N = int(num_a_str, 2)
except ValueError:
return False
if N <= 0:
return False
# 2b. N must be a prime number.
if not is_prime(N):
return False
# 2c. N must be a "Sophie Germain prime" (i.e., 2N+1 must also be prime).
if not is_prime(2 * N + 1):
return False
# 2d. The number of '1's in the binary representation of N must itself be a prime number.
if not is_prime(get_num_ones_in_binary(N)):
return False
# 3. SPECIAL_WORD (W) Constraints
# 3a. Must be a string containing only uppercase English letters.
if not word_b_str.isalpha() or not word_b_str.isupper():
return False
# 3b. The length of W (L) must be equal to N + 2.
L = len(word_b_str)
if L != N + 2:
return False
# 3c. W must be an "alphabetic palindrome".
if word_b_str != word_b_str[::-1]:
return False
# 3d. The sum of Scrabble scores for W must be equal to N * 2.
if get_scrabble_score(word_b_str) != N * 2:
return False
# 3e. The first character of W must be a vowel.
if not is_vowel(word_b_str[0]):
return False
# 3f. The second character of W must be a consonant.
if not is_consonant(word_b_str[1]):
return False
# 4. SEQUENCE_OF_NUMBERS (S) Constraints
# 4a. Must be a comma-separated string of exactly 4 positive integers.
try:
nums_str = num_sequence_str.split(',')
nums = [int(s.strip()) for s in nums_str]
except ValueError:
return False
if len(nums) != 4 or any(n <= 0 for n in nums):
return False
s1, s2, s3, s4 = nums
# 4b. The sequence must be a geometric progression with a positive integer common ratio (r).
if s1 == 0: return False # Already checked positive, but guard against division by zero
r_candidate_s2 = s2 / s1
if not (r_candidate_s2 == int(r_candidate_s2)): return False
r = int(r_candidate_s2)
if r <= 0: return False # Common ratio must be positive
if not (s3 == s2 * r and s4 == s3 * r):
return False
# 4c. The sum of all numbers in the sequence must be equal to N * L.
if sum(nums) != N * L:
return False
# 4d. The first number in the sequence (s1) must be a perfect cube.
if not is_perfect_cube(s1):
return False
# 4e. The bitwise XOR sum of all numbers in the sequence must be equal to N + 12.
xor_sum = s1 ^ s2 ^ s3 ^ s4
if xor_sum != N + 12:
return False
return True