The next issue of the Carnival of Mathematics, rounding up blog posts from the month of January 2024, is now online at CavMaths.

The Carnival rounds up maths blog posts from all over the internet, including some from our own Aperiodical. See our Carnival of Mathematics page for more information.

The next issue of the Carnival of Mathematics, rounding up blog posts from the month of December 2023, is now online at George Shakan’s Data Science and Math Blog.

The Carnival rounds up maths blog posts from all over the internet, including some from our own Aperiodical. See our Carnival of Mathematics page for more information.

This post is both a video and text. The content is largely the same in both versions, so you can pick one to look at.

I’d like to show you a puzzle, or game for one person, that Ed Kirkby came up with. Ed showed this to me at the Big MathsJam gathering last year.

I was walking around MathsJam and people were doing all sorts of stuff and Ed was quietly sat at a table with some cards in front of them, and a couple of people were gathered around with thoughtful faces, so I thought “oh that looks interesting” and I walked over and Ed explained the rules of this game to me.

And like most things at MathsJam, I didn’t immediately know the solution but it really got to me, so I went away and tried to find a solution myself. It was really fun and it was one of those pure experiences of mathematical discovery that you really remember.

I kept grabbing other people and saying, “have you seen Ed’s puzzle? Come over here. Ed, explain this puzzle to this person!” I did that for the duration of the weekend, and for a little while after I got back home.

I’ll show you what the puzzle is.

Take two sets of cards numbered 1 to 4, and lay them out in two rows. The game is to get them the other way round, so each row goes 4, 3, 2, 1.

The things you are allowed to do are to swap two cards that are adjacent numbers and in adjacent columns.

So you can swap the four and three here:

You can also swap to the other row.

You can’t swap the four and the two here because they’re not adjacent numbers.

It’s a permutations puzzle. And with a bit of thinking, a lot of just making random moves, eventually I worked out how to do it for four cards (or two lots of four cards, to be precise).

It took me a few more goes to be sure that I’d found the shortest solution — the fewest moves — but then five really stumped me.

When I tried six cards, I wasn’t sure it was possible at all: there was a point where I kept getting stuck.

So I was really unsure, and Ed was unsure as well – they didn’t know if there was a solution for every number of cards. They’d written some code that very slowly churned out solutions for small $n$, but didn’t have a general solution.

So I did my usual problem solving technique which was, if I couldn’t do it with four cards, do it with three cards, and very briefly with two cards. Then after a while I sort of started seeing a pattern.

I came away from Big MathsJam not knowing how to solve this puzzle.

I kept playing with it when I should have been working, and eventually I think I’ve sort of got the vibe of how it works and I’m pretty sure now I can solve it for any number of cards. I haven’t written down a really rigorous algorithm for doing it but I’ve got a general idea.

Interactive version

Something that often happened when I was playing with cards was that I’d forget which way I was going, because when you don’t have a strategy you’re sort of making lots of moves to see where they’ll go, and then maybe you want to backtrack a bit, and you go like wait wait — which end did the aces start at? You’re continually picking up cards and moving them, and if you’re as clumsy as I am they scatter all over the place and you end up unsure if you’re in a valid state.

Big MathsJam happens in November, and by the time I’d got this online version working it was getting close to Christmas and I thought, “we need something that’s not playing cards to be the pieces – why shouldn’t it be baubles? They’re circles, they’re easy to draw.”

So I spent some time drawing a bauble image and making it look Christmassy. I didn’t quite get it ready for last Christmas, so I spent some more time improving the interface and I made it fully keyboard accessible.

And then I made a note to write a post about it in December 2023. And here we are!

I think this is a nice Christmas puzzle: I think the set-up and the rules are easy to remember, and it only needs a pack of cards, which you’ll probably have lying around.

So over Christmas, if there’s a quiet moment, if you get some playing cards in your Christmas cracker or just some pieces that you can put in an easy to identify order, try showing this to someone.

So there you go, that’s the Double Back puzzle, invented by Ed Kirkby, online version made by me.

Since it’s the time of year when you might be looking for mathematical gifts to buy for your friends, colleagues and loves ones, I thought I’d share some recommendations and suggestions for places to find gifts online.

The next issue of the Carnival of Mathematics, rounding up blog posts from the month of November 2023, is now online at John D Cook’s blog.

The Carnival rounds up maths blog posts from all over the internet, including some from our own Aperiodical. See our Carnival of Mathematics page for more information.

In the last Finite Group livestream, Katie told us about emirps. If a number p is prime, and reversing its digits is also prime, the reversal is an emirp (‘prime’ backwards, geddit?).

For example, 13, 3541 and 9999713 are prime. Reversing their digits we get the primes 31, 1453 and 3179999, so these are all emirps. It doesn’t work for all primes – for example, 19 is prime, but 91 is \(7 \times 13 \).

In the livestream chat the concept of primemirp emerged. This would be a concatenation of a prime with its emirp. There’s a niggle here: just like in the word ‘primemirp’ the ‘e’ is both the end of ‘prime’ and the start of ’emirp’, so too in the number the middle digit is end of the prime and the start of its emirp.

Why? Say the digits of a prime number are \( a_1 a_2 \dots a_n \), and its reversal \( a_n \dots a_2 a_1 \) is also a prime. Then the straight concatenation would be \( a_1 a_2 \dots a_n a_n \dots a_2 a_1 \). Each number \(a_i\) is in an even numbered place and an odd numbered place. Now, since

\[ 10^k \pmod{11} = \begin{cases} 10, & \text{if } k \text{ is even;}\\ 1, & \text{otherwise,} \end{cases} \]

it follows that each \(a_i \) contributes a multiple of eleven to the concatenation. A mismatched central digit breaks this pattern, allowing for the possibility of a prime.

I wrote some code to search for primemirps by finding primes, reversing them and checking whether they were emirps, then concatenating them and checking the concatenation. I found a few! Then I did what is perfectly natural to do when a sequence of integers appears in front of you – I put it into the OEIS search box.

Imagine my surprise to learn that the concept exists and is already included in the OEIS! It was added by Patrick De Geest in February 2000, based on an idea from G. L. Honaker, Jr. But there was no program code to find these primes and only the first 32 examples were given. I edited the entry to include a Python program to search for primemirps and added entries up to the 8,668th, which I believe is all primemirps where the underlying prime is less than ten million. My edits to the entry just went live at A054218: Palindromic primes of the form ‘primemirp’.

At this year’s MathsJam UK Gathering, I had the pleasure of running one of the Saturday Night Tables – a chance to invite attendees at the Gathering to drop by and play with something. Together with fellow Manchester MathsJam regular Andrew Taylor, I ran a table of Mathematical Drawing Hacks – ways to make drawing complex mathematical objects and shapes easier.