Teaser 3303: Knights and knaves
From The Sunday Times, 11th January 2026 [link] [link]
On my travels, I came across a group of some knights (always truthful) and some knaves (always lying). At first, I couldn’t tell which were knights and which were knaves. However, six individuals then gave the following statements about their group:
“The number of knights is prime.”
“The number of knights is odd.”
“The number of knaves is square.”
“The number of knaves is even.”
“The total of knights and knaves is an odd number.”
“There are more knaves than knights.”These statements enabled me to deduce the composition of the group.
How many (a) knights and (b) knaves were in the group?
[teaser3303]



Jim Randell 6:47 am on 11 January 2026 Permalink |
The setter has an additional piece of information – i.e. they can observe the total number of people in the group. If it is possible to break this total down in into knights and knaves in only one way that is consistent with the statements made, then the composition of the group can be determined with certainty.
The following Python program runs in 71ms. (Internal runtime is 158µs).
from enigma import (irange, inf, decompose, filter2, is_prime, is_square_p, printf) # consider increasing group sizes (at least 6) for t in irange(6, inf): # collect candidate solutions for this total size sols = list() # decompose into (a) knights and (b) knaves for (a, b) in decompose(t, 2, min_v=1, increasing=0, sep=0): # evaluate the statements ss = filter2(bool, [ # 1. "a is prime" is_prime(a), # 2. "a is odd" (a % 2 == 1), # 3. "b is square" is_square_p(b), # 4. "b is even" (b % 2 == 0), # 5. "a + b is odd" (t % 2 == 1), # 6. "b > a" (b > a), ]) # check minimum group sizes if len(ss.true) > a or len(ss.false) > b: continue # record this candidate sols.append((a, b)) printf("[{t} -> {sols}]") # check for unique solutions if len(sols) == 1: (a, b) = sols[0] printf("a = {a}; b = {b}") breakSolution: (a) There are 5 knights; (b) There are are 2 knaves.
The total size of the group is 7, and the statements made are:
There are 4 true statements, and 2 false statements, so both knaves made a false statement, and 4 of the 5 knights made a true statement.
And this is the only way a group of 7 can be broken down consistent with the statements.
If we allow the program to continue to larger group sizes, we see that the number of candidate breakdowns grows, so it would not be possible to determine the composition of a larger group.
LikeLike