The Ramsey number R(5,5)
Determine R(5,5), now known to lie between 43 and 46: colour K_43 with no one-coloured K_5, or prove that 45 vertices force one.

| 1 | """R(3,3) = 6, the smallest case of the question: K5 coloured as a pentagon and a pentagram has no one-coloured |
| 2 | triangle, and every 2-colouring of K6 has one (checked here over all 2^15 colourings).""" |
| 3 | import itertools |
| 4 | import math |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import kit |
| 8 | |
| 9 | |
| 10 | def colour(i, j): # 0: the pentagon (neighbours on the circle), 1: the pentagram |
| 11 | return 0 if (j - i) % 5 in (1, 4) else 1 |
| 12 | |
| 13 | |
| 14 | def one_coloured_triangle(n, c): |
| 15 | return any(c[a, b] == c[a, d] == c[b, d] for a, b, d in itertools.combinations(range(n), 3)) |
| 16 | |
| 17 | |
| 18 | pairs5 = list(itertools.combinations(range(5), 2)) |
| 19 | assert not one_coloured_triangle(5, {(i, j): colour(i, j) for i, j in pairs5}) |
| 20 | pairs6 = list(itertools.combinations(range(6), 2)) |
| 21 | assert all(one_coloured_triangle(6, dict(zip(pairs6, bits))) for bits in itertools.product((0, 1), repeat=15)) |
| 22 | |
| 23 | cx, cy, r = kit.W / 2, 128, 112 |
| 24 | 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)] |
| 25 | star = [kit.line(*v[i], *v[j], 'sand-s', 4) for i, j in pairs5 if colour(i, j)] |
| 26 | ring = [kit.line(*v[i], *v[j], 'f-s', 4) for i, j in pairs5 if not colour(i, j)] |
| 27 | dots = [kit.dot(x, y, 9) for x, y in v] |
| 28 | kit.write(__file__, 'mathematics', ''.join(star + ring + dots), label='R(3,3) = 6 · no one-coloured triangle in K5') |