# Enigmatic Code

Programming Enigma Puzzles

## Headscratcher #224: Russian dolls

From New Scientist #3441, 3rd June 2023 [link] [link]

I collect Russian dolls, the type where each doll can be opened to reveal a smaller one inside. I am particularly fond of my simple, single-coloured ones, which come in sets of five (and, unusually, have a hollow smallest doll). I have five lovely sets of them, each a different colour.

Alas, while I was out, my daughter Kira rearranged them so that each large doll now contains one each of the four other colours. She proudly tells me that no blue doll contains a doll that has a yellow doll anywhere within it. There is no doll that contains a pink doll with a red doll anywhere within it. And no yellow doll contains a green doll with a pink doll anywhere within it.

“By the way, have you seen my wedding ring?” I ask her.

“Ah, I put that inside the smallest blue doll” replies Kira.

Which coloured doll should l open first if I want to find the ring as quickly as possible?

## Headscratcher #223: Setting the right tone

From New Scientist #3440, 27th May 2023 [link] [link]

“Not one of your best, is it?”, smirked Michael, peering over Leo’s shoulder at the portrait he was painting. “The colours are so drab. Who is she?”

“The name’s Lisa”, said the model, smiling enigmatically from the other side of the easel.

“I’m trying to mix a glaze to perfect the tone of her face”, sighed Leo. “But I seem to have run out of paint”.

“Yes, about that”, said Michael. “I might have borrowed some for a ceiling. In any case, it looks like you’ve got two brownish dollops there”.

“One of them is equal parts yellow, red and blue. The other is five parts yellow, three parts red and four parts blue. But anyone can see her cheeks require 10 parts yellow, eight parts red and nine parts blue!” said Leo.

Lisa sat and listened quietly, with a knowing look in her eye. Or maybe sad, or bored; it is hard to say. But if Leo is to finish his portrait, in what proportions should the two dollops be mixed to produce the right tone?

This puzzle sees the name of the series switch from Puzzle to Headscratcher. Probably related to the book Headscratchers due to be published in October 2023 [link].

## Puzzle #222: A question of balance

From New Scientist #3439, 20th May 2023 [link] [link]

Being sentimental, Patty likes to use her grandmother’s beam scales when weighing out ingredients to make a birthday cake for her own granddaughter. The only problem is that the scales aren’t accurate as the two arms are of slightly different lengths.

To overcome this, she uses both pans and measures half the required quantity in each. For example, to weigh 2 kilograms of flour, she will put a 1-kilogram weight in the right-hand pan and weigh the flour on the left-hand pan, then place the weight in the left-hand pan and weigh a second batch of flour on the right-hand pan. The combined portions of flour will, she thinks, weigh exactly 2 kilograms.

Is she right or will she have more or less than 2 kilograms?

[puzzle#222]

## Puzzle #221: Logical World Cup

From New Scientist #3438, 13th May 2023 [link] [link]

“Drat”, said Ron the reporter. “Now the Logical World Cup is over, the editor wants to know how many games each team won, drew and lost, but all I have are the points totals”.

“Maybe I can help”, said Martha the mathematician. “Show me what you’ve got”.

Ron passed her the sheet of paper he had been glaring at:

“Hm. I presume it was a round robin with three points for a win and one for a draw?”

“But of course”, said Ron.

“Then I can tell you the other columns” said Martha.

Can you?

[puzzle#221]

## Puzzle #220: Artificial Intelli-Vision song contest

From New Scientist #3437, 6th May 2023 [link] [link]

There was controversy at this year’s Artificial Intelli-Vision song contest, in which each of the competing countries used Al to generate their entries.

Every nation had a judging panel that gave a score to each of the others. The “songwriters” all tried to engineer a higher score for their country by letting an Al generate their ditty as a danceable blend of one other country’s all-time favourite tunes.

This led to a strange outcome. Each judging panel awarded 10 points to the song tailored to its national preferences and the same lower number of points to all of the others. For example, the Transylvania panel gave a perfect 10 to Ruritania’s artificially intelligent effort “Everybody Let’s Dance Last Night Tonight”, while giving only a 7 to all the rest.

The song contest’s board decided to restore artistic integrity to this prestigious event by deducting the inflated 10 from each country’s set of scores. After this, the grand total of all scores was 222, with no two nations tied for any position.

Can you figure out how many countries took part and how many points the winning song scored?

[puzzle#220]

## Puzzle #219: The second red queen

From New Scientist #3436, 29th April 2023 [link] [link]

“You know that debt you owe me?”, says Svengali, rather menacingly. “I am prepared to write it off — but only if you have a bit of luck”.

He takes out a regular pack of playing cards and gives them a thorough shuffle. “Now”, he declares, “I am about to turn over all the cards one at a time, but first I want you to predict the position of the second red queen that I will turn over. If your guess is correct, I will write off your debt”.

My odds aren’t high. There are 52 cards in a pack. Only two of them are red queens the queen of hearts and the queen of diamonds. And only one of those will be the second red queen to be turned over.

“I will give you one bit of advice”, says Svengali, noting my pensiveness. “Don’t choose the top card, because by definition that cannot be the second red queen — though it might be the first”.

Which card position in the range 2 to 52 should I nominate for the second red queen? Or should I just pick a random number?

[puzzle#219]

## Puzzle #218: Playground parity

From New Scientist #3435, 22nd April 2023 [link] [link]

I was eating a sandwich on a park bench when a horde of children from the local school descended on the playground in front of me and divided into two groups.

I couldn’t help overhearing the kids by the swings shout across to the kids near the climbing frame: “If two of you run over here, our group will be double yours!”.

The kids by the climbing frame replied: “But if two of you come over here, the groups will be the same size!”.

The mathematician in me couldn’t resist figuring out how many children there must be in each group for this to be true. But l also discovered something else. If a number of children going one way makes one group double the other, and that same number going the other way makes the two groups the same, the total number of children must always be a multiple of… what?

[puzzle#218]

## Puzzle #217: Vicious circle

From New Scientist #3434, 15th April 2023 [link] [link]

It made sense at the time. The enemy was coming and Neville the Mighty But Not That Bright had created a circular moat in which he placed a fast-swimming, flesh-eating moat monster. He stood at the centre of the island, sword in hand, guarding the only bridge, and ready to fight whoever dared to cross. The plan was foolproof… until the enemy burned down the bridge.

Now, Neville is stranded on an island encircled by a moat with a monster in it. He can just barely run and jump the moat, but the monster swims four times as fast as Neville can run and sense where he is at all times. If Neville tries to jump the moat while the monster is directly beneath him, he will be snatched out of the air like a sausage being caught by a dog.

Is Neville doomed by his own plan? Or is there a chance of escape?

[puzzle#217]

## Puzzle #216: Game of stones

From New Scientist #3433, 8th April 2023 [link] [link]

Let’s play a game, dear reader. I have placed three stones on a number line: one on 0, one on 20 and one on 40. You and I shall take the game in turns; on a turn, a player picks up one of the two outer stones and places it on a whole number between the other two stones. The game continues until the stones occupy three consecutive whole numbers, whereupon no further moves can be made, and the game ends. The player who made the final move is the winner.

As the game is played by my rules, I will let you have the first move. I feel compelled to warn you, however, that only perfect play will result in my defeat. So here is your challenge: to play this game of stones and claim victory over its creator.

[puzzle#216]

## Puzzle #215: Trivia Tuesday

From New Scientist #3432, 1st April 2023 [link] [link]

The team members were assembled for their regular meeting with their eccentric manager.

“Before we get to the main agenda, we’ll observe our weekly ‘Trivia Tuesday’. Today’s trivia titbit is that the month and day are the same number. It is 4 April, which is the fourth day of the fourth month. How about that?”

The rest of the office rolled their eyes. “Seems like the boss forgot until the last second again”, whispered Grace. “I guess he just got lucky with the date”.

Clancy thought for a moment. “Sadly, it isn’t the only time this year when he’ll be able to use the same kind of ‘trivia’ for Trivia Tuesday”.

Without looking at a calendar, can you work out how many more Trivia Tuesdays after 4 April will fall on the nth day of the nth month?

[puzzle#215]

## Puzzle #214: Seven up!

From New Scientist #3431, 25th March 2023 [link] [link]

My burglar alarm won’t stop beeping. I need to enter the four-digit code, but I just can’t remember what it is.

I do remember that I chose a number that is divisible by 7. I also know that I chose a number in the thousands. I recall that the numbers formed by the first three digits and the last three are divisible by 7 as well. I also deliberately chose four different digits. Finally, I know that if I add all the digits, their sum isn’t divisible by 7, but if I add the digits of that sum, the result is divisible by 7.

Can you help me work out what my code is to stop the incessant beeping?

[puzzle#214]

## Puzzle #213: Cross sward

From New Scientist #3430, 18th March 2023 [link] [link]

Older age does bring some benefits. My daughters Kate and Laura have offered to help me by taking on the maintenance of my garden, which is rectangular with a small, rectangular vegetable plot in one corner. The remainder is lawn.

To make it fair for them, I have agreed that my last job in the garden will be to partition it into two with a straight fence, with each daughter getting the same area.

Kate suggested that we forget about the vegetable plot, and only divide the lawn. She sketched a line on the diagram that would give them each exactly half the lawn (with no awkward pinch point to get the mower through). Laura, meanwhile, drew a fence that would divide the lawn and the vegetable patch into halves. To make their lines, neither daughter needed to measure anything, they just needed a straight edge.

Can you draw the lines on which Kate and Laura propose to build fences?

[puzzle#213]

## Puzzle #212: Sound off

From New Scientist #3429, 11th March 2023 [link] [link]

“Why isn’t the sound working?”, Mum muttered as she hit the mute key on the remote control.

“You’ve probably got the wrong remote, Mum”, Sam said. “Remember, it’s the long, thin one for the television, the wide one for the set-top box and the little one for the speakers. Which one did you mute?”

“I can’t remember”, said Mum, as she got her thinking cap on to try to fix things.

To get sound, all three remotes have to be unmuted. Mum came up with the most efficient system for cycling through the possible combinations of muting and unmuting, and got to work.

What is the maximum number of presses needed if she wanted to be sure of getting the sound back?

[puzzle#212]

## Puzzle #211: Cross purposes

From New Scientist #3428, 4th March 2023 [link] [link]

Debbie and Hoi are playing a game where they take turns to cross out numbers written on a piece of paper.

Each player must cross out a divisor or a multiple of the number most recently crossed out. The first player who is unable to cross out a number loses.

Hoi goes first and crosses out 11. Debbie smiles, knowing she can now win in three moves. What number does she cross out?

[puzzle#211]

## Puzzle #210: Action station

From New Scientist #3427, 25th February 2023 [link] [link]

I have a train to catch! I was planning to drive or cycle to the station, but, to my dismay, I realise that my car has a flat battery and my bike has a puncture.

I look at the clock and realise that, based on past experience, if I were to set out right now and walk to the station, I would miss my train by 10 minutes. However, if I were to run at my top speed, I would be 15 minutes early. It is freezing outside and I don’t fancy waiting on the platform for any longer than I have to.

It is too late to do any more calculations as I need to leave right now. I decide to run for half the distance and walk the rest of the way. But where are my running shoes? After a frantic search, I find them.

I leave the house 2 minutes later. Do I make it in time to catch the train?

[puzzle#210]

## Puzzle #209: Postman’s knock

From New Scientist #3426, 18th February 2023 [link] [link]

There was a knock at Professor Numero’s door. It was a postal worker.

“Excuse me disturbing you, but can you help? This letter has a cryptic address. I can’t make head or tail of it:”

To the Resident,
The house with a number whose digits when multiplied together give five times what they sum to, Long Road.

The professor pondered. “Well, you’ve come to the right road. And, luckily, there’s only one house number in the road with this mathematical property — the one at the end, where Colonel Crypto lives”.

As you would expect, the houses in Long Road are numbered consecutively from 1 upwards, with no missing numbers.

How many houses are there in the road?

[puzzle#209]

## Puzzle #208: Flower power

From New Scientist #3425, 11th February 2023 [link] [link]

Ivor Plant is the head gardener of Lady Bird’s estate. Her large chrysanthemum garden needs to be weeded and pruned, so he assigns his two apprentices, Lupin and Heath, to the rather tedious task. The garden consists of a central 4-metre-sided square (pink) inscribed in a circle, and four outer areas (blue) enclosed in semicircles that are connected to the square’s corners.

“If you give me two of your chocolate biscuits, I will let you pick whichever area you want to weed: the outside or the inside”, says Heath to Lupin. Always eager to get out of extra work whenever possible, Lupin agrees.

If he is looking to weed the smaller of the two areas, should he choose the blue or the pink section?

[puzzle#208]

## Puzzle #207: Total recall

From New Scientist #3424, 4th February 2023 [link] [link]

I recently had the incredible opportunity of talking to an intergalactic traveller about her encounter with four extraterrestrial beings.

“The aliens have purple skin, long, floppy legs and large orange eyes”, she told me. “And they revealed to me the true nature of dark matter”.

I leaned in close with excitement.

“Unfortunately, I don’t remember anything about that. I do remember a great puzzle they told me, though. I asked them their ages, and they said that if you sum up the ages of only three of them, the possible totals are 24, 53, 54 and 61. From this, they told me that I could work out all four of their ages”.

Well, it isn’t exactly the secrets of the universe, but it will have to do. Can you work out the ages of the four aliens?

[puzzle#207]

## Puzzle #206: All square

From New Scientist #3423, 28th January 2023 [link] [link]

“What ho!” boomed Aunt Nicola. I could tell she was about to talk cricket at me. “Have you been following the test match between Pythagorea and Lagrangia?”

“Auntie, you know I prefer Navier-Stokes to Ben Stokes”. “Well”, she said, “you might be interested — there’s maths involved! In their first innings, Lagrangia’s total score was a square number”.

“Innings?” I asked. “It’s the word for a team’s turn to bat. They each have two. In their first, the Pythagoreans also got a square number, but they were more than 300 behind!”

“That sounds insurmountable”. “You might think so”, she said. “Then, when Lagrangia batted again, they added a different square number — less than 50 — so that their lead and overall total were also square numbers”.

“Goodness”. “But the Pythagoreans battled back in their second innings”, she continued, “and the game ended dramatically in a tie”.

I then knew enough to work out the totals of the four innings in order. What were they?

[puzzle#206]

## Puzzle #205: Buried shields

From New Scientist #3422, 21st January 2023 [link] [link]

The burial chamber of Queen Count-M-Up of the Mat e’Matic people has been discovered! Archaeologists know that her people greatly appreciated diversity in life, and they believe she was buried with a set of painted shields that illustrate this by displaying all possible combinations of three colours (gold, silver and blue) in four sections.

Opening the tomb, they quickly find seven complete shields and one broken one. What colour is the missing section? And when they discover the ninth shield, what will it look like?

[puzzle#205]