"""R(3,3) = 6, the smallest case of the question: K5 coloured as a pentagon and a pentagram has no one-coloured triangle, and every 2-colouring of K6 has one (checked here over all 2^15 colourings).""" import itertools import math from pathlib import Path import kit def colour(i, j): # 0: the pentagon (neighbours on the circle), 1: the pentagram return 0 if (j - i) % 5 in (1, 4) else 1 def one_coloured_triangle(n, c): return any(c[a, b] == c[a, d] == c[b, d] for a, b, d in itertools.combinations(range(n), 3)) pairs5 = list(itertools.combinations(range(5), 2)) assert not one_coloured_triangle(5, {(i, j): colour(i, j) for i, j in pairs5}) pairs6 = list(itertools.combinations(range(6), 2)) assert all(one_coloured_triangle(6, dict(zip(pairs6, bits))) for bits in itertools.product((0, 1), repeat=15)) cx, cy, r = kit.W / 2, 128, 112 v = [(cx + r * math.cos(-math.pi / 2 + 2 * math.pi * k / 5), cy + r * math.sin(-math.pi / 2 + 2 * math.pi * k / 5)) for k in range(5)] star = [kit.line(*v[i], *v[j], 'sand-s', 4) for i, j in pairs5 if colour(i, j)] ring = [kit.line(*v[i], *v[j], 'f-s', 4) for i, j in pairs5 if not colour(i, j)] dots = [kit.dot(x, y, 9) for x, y in v] kit.write(__file__, 'mathematics', ''.join(star + ring + dots), label='R(3,3) = 6 ยท no one-coloured triangle in K5')