Puzzling Asked by Bernardo Recamán Santos on December 10, 2020
Each of the cells of a 5 x 5 board contains a different number of gold coins between 1 and 25, as shown below.
A move consists of taking all the coins in two adjacent (either vertically, horizontally, or diagonally) cells and splitting them evenly among those two cells, placing an extra coin in the cell which originally had the most coins in the case that the total number of coins is odd.
a) Is it possible for all the cells to contain the same number of coins (i.e. 13) after a finite number of moves?
b) What are necessary and sufficient conditions for a 5 x 5 board whose 25 cells contain each a different number of gold coins between 1 and 25 to be convertible into a board with the same number of coins in every cell after a finite number of moves?
I figured out part a):
Here is my shuffling through the grid:
Here is the time lapse:
And here is the program I coded with python for the tool in the gif. Simply run this code:
import pygame
# You can change the grid & size to whatever you like
grid = [[7, 24, 12, 8, 11],
[13, 21, 3, 20, 19],
[10, 22, 15, 2, 9],
[23, 1, 6, 16, 17],
[5, 25, 14, 4, 18]]
size = 60
pygame.init()
pygame.font.init()
font = pygame.font.SysFont("Arial", size-10)
wn = pygame.display.set_mode((600, 600))
class Square():
def __init__(self, pos, num):
self.x = pos[0]
self.y = pos[1]
self.num = num
self.color = (255, 255, 255)
self.rect = pygame.Rect(self.x, self.y, size-5, size-5)
def clear(self):
self.color = (255, 255, 255)
def draw(self):
pygame.draw.rect(wn, self.color, self.rect)
text = font.render(str(self.num), True, (0, 0, 0))
if len(str(self.num)) == 1:
wn.blit(text, (self.x+size*.25, self.y*.98))
else:
wn.blit(text, (self.x+size*.055, self.y*.98))
class Box():
def __init__(self, grid, cor):
y1 = cor[0]-1 if cor[0] else 0
y2 = len(grid)+2 if cor[0] > len(grid)+2 else cor[0]+2
x1 = cor[1]-1 if cor[1] else 0
x2 = len(grid[0])+2 if cor[1] > len(grid[0])+2 else cor[1]+2
self.box = [c for r in grid[y1:y2] for c in r[x1:x2] if c != grid[cor[0]][cor[1]]]
def color(self, color):
for square in self.box:
square.color = color
def avg(n1, n2):
n = n1 + n2
if n % 2:
if n1 > n2:
return n // 2 + 1, n // 2
return n // 2, n // 2 + 1
return n // 2, n // 2
squares = [[Square((i*size, j*size), col) for j, col in enumerate(row)] for i, row in enumerate(grid)]
clicked = []
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.MOUSEBUTTONDOWN:
for row in squares:
for square in row:
if square.rect.collidepoint(pygame.mouse.get_pos()):
if not clicked:
clicked.append(square)
square.color = (150, 255, 255)
x, y = clicked[0].x, clicked[0].y
box = Box(squares, (x//size, y//size))
box.color((255, 255, 150))
else:
if square in box.box:
clicked.append(square)
if square == clicked[0]:
box.color((255, 255, 255))
clicked[0].clear()
clicked.clear()
if len(clicked) == 2:
clicked[0].num, clicked[1].num = avg(clicked[0].num, clicked[1].num)
box.color((255, 255, 255))
clicked[0].clear()
clicked.clear()
for row in squares:
for square in row:
square.draw()
pygame.display.update()
For part b), I may or may not know. I'll look deeper into it.
Answered by ention everyone on December 10, 2020
This not a full answer, but maybe someone else can use it for a full proof.
Part (a).
Partial answer for part (b).
Answered by Jaap Scherphuis on December 10, 2020
A starting point for part (b): Let's consider some smaller boards. I'm going to normalize the average coin value to 0, and try to analyze arbitrary starting configurations where the coins sum to 0.
2x2:
1x3:
Thus,
Hopefully we can extend the 1x3 solution to a 1x4 solution, or maybe a 4-cycle. This might be a problem that is more natural to think about for arbitrary graphs than for checkerboard graphs specifically.
Answered by isaacg on December 10, 2020
Conjectured answer to b)
Let us subtract 13 from all numbers for convenience.
A position is strictly unbalanced if there exists a split into two connected pieces such that
Obviously, a strictly unbalanced position is unwinnable.
A position is unbalanced if there exists a split into two connected pieces such that
As an unbalanced position will eventually simplify into a strictly unbalanced one it is also unwinnable.
It is also obvious that every unwinnable position will eventually simplify into a strictly unbalanced one.
What we would like to establish is the following
Conjecture: Every unwinnable position is unbalanced.
or, equivalently,
Variant: If a position is not unbalanced there exists a move such that the resulting position also is not unbalanced.
This feels quite plausible to me but I haven't been able to prove it.
Note that the conjecture is wrong for very small boards such as 4x1: The position -1,5,-5,1 is not unbalanced but each of the three possible moves creates an unbalanced position due to overshooting. If we, however, embed this pattern in a larger space and zero-pad, the problem goes away:
-1 5 -5 1 -1 3 -5 1 -1 3 -3 1
-> -> ->
0 0 0 0 0 2 0 0 0 2 -2 0
-1 3 -3 1 -1 3 -3 1 -1 3 -1 -1
-> -> ->
0 0 0 0 0 0 0 0 0 0 0 0
-1 1 1 -1 -1 1 0 0 0 0 0 0
-> ->
0 0 0 0 0 0 0 0 0 0 0 0
Answered by Paul Panzer on December 10, 2020
I completed it in 32 moves, as shown in the attached image.
Answered by mkinson on December 10, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP