# Enigmatic Code

Programming Enigma Puzzles

## Enigma 1556: Card trick

From New Scientist #2719, 1st August 2009 [link]

Joe gave Penny a rectangular piece of card 12 centimetres by 6 centimetres with the instruction that she had to draw four straight lines out from the centre of the card to an edge, each a whole number of centimetres long, so that, by cutting along two of the lines, a piece of card with an area equal to any multiple of 6 square centimetres (from 1 to 6) can be produced.

What will the total length of the four lines be?

[enigma1556]

### 2 responses to “Enigma 1556: Card trick”

1. Jim Randell 6 March 2012 at 11:41 am

I initially solved this one by drawing it out, doing it programatically is a bit trickier, although it does find another family of answers (which give the solution).

The following Python program runs in 37ms.

```from math import sqrt

# consider the 12 x 6 rectangle centred on the origin
# the TR quadrant is a 6 x 3 rectangle

# there are 4 possible rays from the origin to the long (6) side:
# the lengths are 3 (vertical), 4, 5, 6
# and 1 possible ray to the short (3) side:
# of length 6 (horizontal)

# and the areas between these rays are:
a = [None] * 4
a[0] = 3 * sqrt(7) / 2
a[1] = 6 - a[0]
a[2] = 9 * sqrt(3) / 2 - 6
a[3] = 12 - a[2]

area = (a + a[::-1]) * 2

# the lengths of the rays are:
length = [3, 4, 5, 6, 6, 6, 5, 4] * 2

# is x a multiple of 6?
def multiple6(x):
i = int(x + 0.001)
if x - i > 0.001: return
d, r = divmod(i, 6)
if r > 0: return
return d

b0 = set(range(1, 12))

# assume the first ray is in the first quadrant
for A in range(0, 5):
# the next ray must be an area that's a multiple of 6 from A
for B in range(A+1, 16):
ab = multiple6(sum(area[A:B]))
if ab is None: continue
# and the next ray
for C in range(B+1, 16):
bc = multiple6(sum(area[B:C]))
if bc is None: continue
ac = ab + bc
b1 = set((ab, 12 - ab, bc, 12 - bc, ac, 12 - ac))
if len(b1) not in (5, 6): continue
# and the last ray
for D in range(C+1, 16):
cd = multiple6(sum(area[C:D]))
if cd is None: continue
bd = bc + cd
b2 = b1.union((cd, 12 - cd, ad, 12 - ad, bd, 12 - bd))
if b2 != b0: continue
s = sum(length[x] for x in (A, B, C, D))
print(s, (A, B, C, D))
```

Solution: The total length of the 4 lines is 19 cm.

• Jim Randell 6 March 2012 at 11:52 am

This is the solution I came up with on paper:

Cuts along the following 2 lines partition the rectangle into pieces with the following areas:

AB 6 + 66
BC 12 + 60
AC 18 + 54
CD 24 + 48
BD 36 + 36

Of course there are answers that are rotations/reflections of this that give the same solution.

My program also found a second family of answers. The four lines are the same, but in a different configuration:

Cuts along the following 2 lines partition the rectangle into pieces with the following areas:

AB 6 + 66
CD 12 + 60
AC 18 + 54
BC 24 + 48