## Teaser 3132: Bilateral symmetry

**From The Sunday Times, 2nd October 2022** [link] [link]

My son, at a loose end after A-levels, asked me for a mental challenge. As we’d been discussing palindromes, I suggested he try to find an arrangement of the digits 1 to 9 with the multiplication symbol “×” to give a palindrome as the answer, and he came up with:

29678 × 1453 = 43122134.

I said: “Now try to find the smallest such palindromic product starting in 4, where the last digit of the smallest number is still 3”. He found that smallest product, and, interestingly, if he added the two smaller numbers instead of multiplying them, then added 100, he also got a palindrome.

What is the smallest product?

[teaser3132]

## Jim Randell 4:55 pm

on30 September 2022 Permalink |Using the [[

`SubstitutedExpression()`

]] solver from theenigma.pylibrary.This Python program runs in 98ms.

Run:[ @replit ]Solution:The smallest product is 40699604.Ignoring the final palindromic addition check, there are 3 candidate palindromic products that meet the criteria (in decreasing order)

The final one gives the answer to the puzzle, and is also the only one where the sum of the multiplicands and 100 is also palindromic.

There are also two further palindromic products where the

largerof the multiplicands ends in the digit 3:LikeLike

## Frits 10:22 am

on1 October 2022 Permalink |@Jim,

I expected “for i in irange(5, n – 1):” ( where the last digit of the smallest number is still 3)

LikeLike

## Jim Randell 12:10 pm

on1 October 2022 Permalink |Good point!

Fixed now.

LikeLike

## GeoffR 10:10 am

on3 October 2022 Permalink |The only way I could find a MiniZinc solution was to assume that one of the multipliers was two digits long, so this is not a rigorous solution. Although I coded requirements for the second palindrome, as stated in the teaser, I found it was not strictly necessary to find the smallest palindromic product.

LikeLike

## NigelR 11:28 am

on3 October 2022 Permalink |Shorter but not quicker! The palin lambda proves I was listening last week, though!!

LikeLike

## NigelR 11:36 am

on3 October 2022 Permalink |Given that the number ending in ‘3’ is the smaller of the two numbers, I could have made line 7

‘for i in range(5,8)’, which shaves a bit of time off.

LikeLike

## Frits 3:19 pm

on3 October 2022 Permalink |Easier: palin = lambda num: (s := str(num)) == s[::-1]

The “for x .. for y ..” can be replaced by “for y in perm(digs, i):”

LikeLike

## NigelR 12:31 pm

on4 October 2022 Permalink |Thanks Frits . Much neater – and I now know how to assign a variable within an expression. Onwards and upwards!

LikeLike

## Frits 10:57 pm

on3 October 2022 Permalink |I spent some time in making a generic version of GeoffR’s Minizinc program.

As the numFirst and numAsOf functions do not work with “var int” parameters I had to call them several times.

Using the fact that the first digit of the largest number must be a 1 (as p1 + p2 plus 100 is palindromic and has to end in 1) didn’t help to bring the run time under one second.

LikeLike

## GeoffR 9:24 am

on4 October 2022 Permalink |@Frits:

An excellent full programming solution in MiniZinc, with some new functions.

LikeLike

## GeoffR 8:50 am

on20 October 2022 Permalink |LikeLike