Sunday Times Teaser 2862 – Algebria’s Standard
by Stephen Hogg
Published July 30 2017 (link)
The Algebrian rectangular flag is highly symbolic. Each of its sides is an even number of inches long and a diagonal divides it into two triangles, one blue and one green, representing its two founding tribes. The length of the diagonal (in inches) is the number of states in Algebria, and the area of the flag (in square inches) is the twentieth century year in which the country obtained independence.
How many states are there in Algebria, and in which year did the country obtain independence?
2 Comments
Leave one →
-
Brian Gladman permalink12345678910111213141516171819from number_theory import divisor_pairs# The rectangular flag has sides in inches that are even# integers and diagonals in inches that are integers; it# has an area between 1900 and 2000 square inches; hence# the sides 2.a and 2.b (a < b) with the diagonal (2.c)# form a pythagorean triangle# the area is a multiple of 4 between 1900 and 2000for qa in range(1900 // 4, 2000 // 4):# find possible values for a and bfor a, b in divisor_pairs(qa):# that form a pythagorean trianglec2 = (a * a + b * b)c = int(c2 ** 0.5)if c * c == c2:print(f'Algebria has {2 * c} states and became independent in {4 * qa}.')
-
geoffrounce permalink1234567891011121314# assume the flag is less than 10 ft squarefor a in range(2, 120, 2):# ensure that b is greater than afor b in range(a + 2, 120, 2):# the diagonal of the flag (c) must be an integerc = (a * a + b * b) ** 0.5if c == int(c):# the flag area is a 20th century yearif 1900 < a * b <= 2000:print(f'Year = {a * b}, No. States = {int(c)}')