Teaser 3071: Three-cornered problem
From The Sunday Times, 1st August 2021 [link] [link]
I have a set of equal-sized equilateral triangular tiles, white on one face and black on the back. On the white side of each tile I have written a number in each corner. Overall the numbers run from 1 to my age (which is less than thirty). If you picture any such tile then it occurs exactly once in my set (for example, there is just one tile containing the numbers 1, 1 and 2; but there are two tiles containing the numbers 1, 2 and 3).
The number of tiles that contain at least one even number is even.
The number of tiles that contain at least one odd number is odd.
The number of tiles that contain at least one multiple of four is a multiple of four.
How old am I?
[teaser3071]
Jim Randell 10:01 pm on 31 July 2021 Permalink |
This Python program constructs the possible triangular tiles for increasing ages, and keeps count of the number that satisfy the given conditions. It runs in 73ms.
from enigma import (irange, subsets, uniq, printf) # count triangles with ... evens = 0 # ... at least one even number odds = 0 # ... at least one odd number mul4s = 0 # ... at least one multiple of 4 # canonical form (by rotation) def canonical(a, b, c): return min((a, b, c), (b, c, a), (c, a, b)) # consider triangles with largest number n for n in irange(1, 29): # consider rotationally distinct triangles for tri in uniq(canonical(n, a, b) for (a, b) in subsets(irange(1, n), size=2, select="M")): # increase the counts if any(x % 2 == 0 for x in tri): evens += 1 if any(x % 2 == 1 for x in tri): odds += 1 if any(x % 4 == 0 for x in tri): mul4s += 1 # output solution if evens % 2 == 0 and odds % 2 == 1 and mul4s % 4 == 0: printf("n={n} [evens={evens} odds={odds} mul4s={mul4s}]")Solution: Your age is 17.
The total number of triangular tiles for any particular age is given by OEIS A006527 [link]:
There is the possibility of a solution at age = 1. In this case there is only 1 tile in the set — (1, 1, 1). But the setter might be considering that the numbers of tiles in each category is non-zero (also 1 is a little young to be setting such a puzzle). In any case, we are told that there are two (1, 2, 3) tiles, so we know the age must be at least 3.
In general we find solutions to the puzzle at ages of the form (16k + 1).
LikeLike
Frits 1:23 pm on 2 August 2021 Permalink |
Similar.
# consider rotationally distinct triangles containing number n def triangles(n): for x in range(n, 0, -1): for y in range(x, 0, -1): yield [n, x, y] for x in range(n - 2, 0, -1): for y in range(n - 1, x, -1): yield [n, x, y] odds, evens, mul4s = 0, 0, 0 print("age evens odds mlt4s") for age in range(1, 30): for tri in triangles(age): if any(x % 2 == 0 for x in tri): evens += 1 if any(x % 2 for x in tri): odds += 1 if any(x % 4 == 0 for x in tri): mul4s += 1 if mul4s % 4 == 0 and evens % 2 == 0 and odds % 2: print(f"{age:>3} {evens:>5} {odds:>5} {mul4s:>5}")LikeLike