# Ernie and the Menacing Monopoles

While driving home from a fishing trip Ernie and I saw a road-side sign pointing down a gravel track that announced ‘MYSTERIOUS SOUTH SLOPING TREES’. It was getting well on into the afternoon, and I thought the road might be a bit rough for the hire car, but Ernie insisted that we should investigate. The road was steep, narrow, and winding, but as we drove over a final ridge a fantastic view was revealed, and I had to agree that the side trip had been worth it. A single row of ancient trees stood on a grassy cliff-side field. Each tree was twisted and bent towards the south and lit by an unearthly light from the low-hanging sun. Ernie went to take a closer look, while I sat by the car and made a watercolour sketch of the scene. “The wind must get pretty strong here”, I said as I disassembled my easel upon Ernie’s return. He gave a non-committal grunt in reply, as he packed what appeared to be a large hypodermic syringe back into his suitcase.

On my next visit to Ernie’s place he passed me a rubbery cube about 10 cm on a side. The six sides had been marked with black pips like a traditional right-handed die. “Its a bit big to be practical for a game of Ludo” I joked, but Ernie just placed a second identical die on the table and suggested that I should try and push the two die together. To my surprise, as I pushed the 1-pip side of my die towards the identical face of the other one, it slid away as if repelled by some sort of magical hand. But I wasn’t going to let Ernie’s parlour trick confuse me – obviously the die were magnetized. So I rotated my die 180 degrees (to make a NS pair) and approached with the 6-pip side. To my surprise, the dice repelled each other even more strongly. I repeated my experiment, but found that the two dice always repelled each other regardless of their relative orientation.

“So what is the trick?”, I asked. “No trick”, Ernie replied. “Remember the trees? The sap sample I took confirmed my suspicions – the trees are not bent by the wind, but are attracted to the south magnetic pole. I confirmed that when I was able to isolate magnetic monopoles from the sap. And now I can synthesize them”, and he held a small bottle half full of a pale green liquid that he had labelled ‘Magnetic Monopolar Paint – (North)‘.

Ernie explained how he had coated each face of each cube with his new paint, and they repelled each other because they had north poles on every surface. “I wanted to experiment with the thickness of the paint”, he continued, "so each x-pip side has x coats of paint". I tried pushing the pair of dice together a bit more firmly and discovered that it was easy to push the two 1-pip faces together, but as the number of pips on each side increased it got harder and harder. When I tried with two 4-pip sides, I couldn’t force them into contact no matter how hard I tried. Ernie explained that he was going to mail them, plus 25 more identical cubes, to the International Magnetics Conference, where he would demonstrate his discovery. Time was short and he wanted to concentrate on writing his talk, so "could I deal with the packing?". There were just a few rules I would have to follow while packing – “to avoid problems with excess pressure”.

1. There were exactly 27 identical dice.
2. I should pack them into a 3x3x3 block.
3. Each pair of coincident faces inside the block would add an outward pressure on the block's surface proportional to the multiple of the paint thickness on each of the two faces. For example: a 3-pip face pressed against a 5-pip face would increase the outward pressure over the entire surface of the block by 3x5=15 units.
4. Each face exposed to the surface of the block would add an inward pressure on the block's surface proportional to the paint thickness on that face. For example: a 4-pip surface face would increase the inward pressure over the entire surface of the block by 4 units.
5. The package should be wrapped in n layers of wrapping film, where n was the total outward pressure minus the total inward pressures.
6. I should arrange the dice so n was as small as possible because wrapping film wasn’t cheap and Ernie “wasn’t made of money!”.

I asked what the “problems with excess pressure” might be, and Ernie responded that if the outward pressure was greater than the number of wrapping film layers then the package would likely burst violently and unpredictably – a bit of a problem as the Post Office was already touchy about sending parcels for Ernie. “What if n is negative, I presume I don’t need any wrapping film in that case?”, I asked. Ernie scribbled on an envelope for a couple of minutes and then told me that if that happened the excess inward pressure might cause the package to collapse in on itself violently and unpredictably. “..either to neutronium, or maybe a tiny black hole...”. But then assured me that that wasn’t going to be an issue with any possible packing “...assuming I have made the correct calculations of course”, he continued.

So here’s my problem: Is there any risk that Ernie has got things wrong and I might inadvertently create a black hole and, if not, how many layers of wrapping film do I need to prepare?

• Woo, Ernie is back! Jun 6, 2022 at 3:51
• How did he paint the second, third, ... coats? Jun 6, 2022 at 4:30
• @Florian I imagine he developed a painting algorithm. Something like begin; for x = 1 to 6 do { rotatetosideup(x); k=x; while k > 0 do { paintsideup; repeat testsideuppaint until sideuppaintdry; decrement(k); } } end; Jun 6, 2022 at 21:16
• @Florian I had a word with Ernie and he tells me: 1) I completely misunderstood your question; 2) but curiously enough, my answer was almost correct; 3) to fully correct my answer I should replace the function paintsideup, with the function paintsideupwithhumungouslypowerfulelectrostaticspraygun(V*(6-k)), where V is a constant equal to 3.14 GV. Jun 6, 2022 at 22:33
• I expect it wouldn't be a problem; you can't push the two 4 sides together by hand (pressure 16) but can push the two 3 sides together (pressure 9); painting the last layer on the 6 side is like pushing a 1 and 5 side together (pressure 5). Jun 7, 2022 at 1:33

My best solution has a score of:

9 layers

My solution is the below array, which has the dice in X/Y/Z order, and each die is given as a list of its X−/X+/Y−/Y+/Z−/Z+ faces:

[
[
[(5, 2, 6, 1, 4, 3), (6, 1, 5, 2, 3, 4), (4, 3, 6, 1, 2, 5)],
[(6, 1, 4, 3, 5, 2), (6, 1, 3, 4, 2, 5), (5, 2, 4, 3, 1, 6)],
[(6, 1, 2, 5, 4, 3), (5, 2, 1, 6, 3, 4), (4, 3, 2, 5, 1, 6)]
],[
[(3, 4, 6, 1, 5, 2), (4, 3, 6, 1, 2, 5), (3, 4, 5, 2, 1, 6)],
[(4, 3, 5, 2, 6, 1), (6, 1, 2, 5, 4, 3), (2, 5, 3, 4, 1, 6)],
[(3, 4, 2, 5, 6, 1), (2, 5, 1, 6, 4, 3), (3, 4, 1, 6, 2, 5)]
],[
[(1, 6, 5, 2, 4, 3), (2, 5, 6, 1, 3, 4), (1, 6, 4, 3, 2, 5)],
[(2, 5, 4, 3, 6, 1), (1, 6, 5, 2, 4, 3), (1, 6, 4, 3, 2, 5)],
[(1, 6, 3, 4, 5, 2), (1, 6, 2, 5, 3, 4), (2, 5, 3, 4, 1, 6)]
]
]

And as a picture, with a manual check of the score:

I got this solution by translating the problem into an integer quadratic program, and then optimizing with Gurobi (code available upon request).

• Does your program return the optimal solution? Jun 7, 2022 at 6:34
• That was the same packing I found (including the single annoying pair of 3-4 faces). I can't prove it is optimal, but when I used 9 wraping layers, Ernie didn't grumble. Jun 7, 2022 at 23:20

At first I was afraid I might inadvertently create a black hole, but some initial figuring gets me to

13 layers of wrapping

as follows:

(black faces can be any valid orientation - many dice have their antipodes facing the same number due to the symmetries of the solution)

Reason I believe this solution is (close to) optimal:

Central die is surrounded by 1's, and face centers get all 1's and 2's from their face neighbours.
Inward force is absolutely maximal, and edge forces on the top and bottom faces can only be reduced by increasing the layer pressure.

• It is a good start, but I just noticed a postit note on the fridge in Ernie's writing. It says "N<13" Jun 6, 2022 at 21:17