Elvish Muddle Bugs

The Elves help Santa, but sometimes get in a muddle and make mistakes. Can you spot their mistakes, and help make sure all their work is done and so ultimately all the presents are delivered. Oddly, Elves and programmers make similar kinds of mistakes!

All answers are at the end.

Jimmy’s Christmas List

Mork Muddlebug is struggling with Jimmy’s Christmas List. Jimmy has written that he would like:

“A talking teddy and not a normal teddy or a train set or a rat trap game” 

Mork is in a muddle after reading it. Does Jimmy want a train set or not? Does he actually want a  rat trap game or not? What does the list Jimmy has written actually mean? What one thing should Mork put in Santa’s sack for him to be sure he does get something he wants?

Three presents for four people

One of Santa’s Elves Mindy Muddlebug has three presents to deliver to a house that Mikey Muddlebug has told her contains two mothers and two daughters. She knows everyone must get a present so she is looking for the missing present. Should she keep searching or is she in a muddle?

Cutting the crackers

One of Santa’s Elves Mikey Muddlebug has the job making giant novelty crackers each out of a piece of paper that is 1m long. They need 120 crackers and start with a strip of paper 120m long. Mikey Muddlebug sets the cracker machine to make 120 cuts that each take one second to do. Elven expects to be finished in exactly 2 minutes and he will then head off for a snooze: job done. Does he get the snooze he is expecting or is he in a muddle again?

Standing in for Santa

It is Christmas Eve. Santa is ill in bed! Oh, No! How will the presents be delivered? Mindy Muddlebug comes to the rescue and takes the reigns of the sleigh full of all the presents to deliver. Just as Santa does every year, at midnight she heads to the South Pacific to get started. Unlike Santa, she then decides to head East to the United States as she thinks this year, to be fair, they should get their presents first. Will his plan work or is she in a muddle again?

Presents for the block of flats

Elven Muddlebug is still standing in for Santa. He has just finished Liverpool in the North of England when he notices a pile of presents on the floor of the sleigh. He gasps. They were for the children living on the eleventh floor of a block of flats – he missed a whole floor. He turns the reindeer round and heads back. As he approaches the flats he counts up the floors by counting the windows from the bottom: floor 1, floor 2, floor 3, … floor 10, floor 11. Putting the reindeer in to hover mode, he climbs in the fire escape of that floor ready to deliver the presents. Will the children on floor 11 get their presents or is he in a muddle? Should he have just used the lift?

<More Elvish muddles to come>

 

 

 

 

Answers

Jimmy’s Christmas List

It’s not surprising Mork is struggling. The same sentence in English can have several different meanings. Logically

“A talking teddy and not a normal teddy or a train set or a rat trap game”

could mean:

Jimmy wants 
    a talking teddy OR
    a train set OR
    a rat trap game.
Jimmy does not want 
    a normal teddy.

It could also mean :

Jimmy wants
    a talking teddy
He does not want
    a normal teddy OR
    a train set OR
    a rat trap game.

Computer scientists use a precise language of logic to say things like this. They use brackets to show what they mean and also write things on different lines to make it easier still to read (as we did above).  WIth brackets they would either write the list as:

      “(A talking teddy and (not a normal teddy)) or 
       a train set or 
       a rat trap game”

Ii they meant the first meaning or

     “A talking teddy and 
      (not (a normal teddy or a train set or a rat trap game))”

if they meant the second meaning.

With no brackets a computer scientist would take it to mean that brackets were round a NOT first, then round AND and only finally round OR. So without brackets, the strict meaning is the first one. Mork could give him a talking teddy or a train set or a rat trap game. To be safe though the best thing to give him would be a talking teddy (just in case Jimmy isn’t very good at logic) as in either meaning that is something he wants.

Link  to programming: Programmers have to write logical statements like this to tell computers what to do. In programs they use a precise language of logic  including brackets to make it clear what they mean. If they didn’t the computers they program might do the wrong thing. They have to make sure what they wrote is definitely what they meant. It’s usually better to put in brackets to be safe!

Three presents for four people

The three people were a grandmother, a mother and a daughter, the grandmother is a mother to the mother, and the mother is the daughter of the grandmother so the three people do make two mothers and two daughters.

Link  to programming: Programmers have to be able to think very clearly when writing programs, but they also have to know facts and relationships in the real world. It isn’t just about pure logic. If the specification of the program you are given seems inconsistent then you cannot ignore it. Often you have to go back to the cutomer to find out what they really want.

Cutting the crackers

It only takes 119 cuts to split a strip in to 120 pieces (just as in only takes one cut to cut something in to two pieces) You get the last piece without an extra cut. If Mikey makes 120 cuts then he will have made a mistake. He won’t get that snooze. He will end up with pieces that are too short and have to start all over again.

Link  to programming: Programmers make similar thinking mistakes to this and it leads to bugs in programs. It is important that you can think clearly and avoid making this kind of muddle.  They often loose track of how many times they need to do something, and do one too few or one too many.

Here is an actual example for those with some coding experience. When coding Bubblesort to sort an array, you run a loop down the array comparing pairs of items and swapping them if they are in the wrong order. It is a mistake to run the loop right to the end of the array, though. You stop one short of the end. Why? Because each comparison you do is of the current entry and the next entry, and there is no next entry at the end! You stop one place earlier.

Bubblesort does lots of passes like this gradually swapping everything in to the right place. You can make a similar thinking mistake to the above when working out how many passes of the array you need too. Each pass slots a single value into the right place (as you take the biggest value found so far with you as you scan down the array on each pass, drop it at it’s correct position). That means on every pass you put one thing in the correct position. So how many passes do you need to guarantee sorting 10 things? 9 not 10! Once 9 things are in the right position the 10th must be too as there is no where else for it to go!

Standing in for Santa

If Mindy travels East she will cross the date line and remain on Christmas Eve. Everyone in America will get their presents a day too early! The reason Santa ALWAYS starts in the East and goes West is because that is where the sun rises. That is why Japan is called the “Land of the Rising Sun” for example. From China, where the name comes from, Japan is in the East where the Sun appears to come from. Because the Earth is round and because of the way it rotates, each day starts first in the East. The sun rises later the further west you go. Santa goes to the Pacific Ocean and countries like New Zealand first is to keep ahead of the sun rising and Christmas Day starting. As long as he goes fast enough he can deliver everything before the sun rises (as the Earth rotates) in each country and everyone wakes up. North America has to be last as their day starts last. As Christmas Day starts in the Eastern countries it is still Christmas Eve in the countries to the West.

Link  to programming: Programmers constantly get into a muddle with time! The most famous problem was the “Year 2000” problem, where lots of programmers had stored years in programs as only two digits, so 1978 was stored as 78. That meant that as 1999 turned to 2000 it jumped back from 99 to 00. That meant the computer would treat the new year as coming before the old year, leading to all sorts of potential problems.

Presents for the block of flats

Elven has ended up on the wrong floor. In the UK floors start at Ground (G) then floor 1, 2, 3 … so by counting the bottom set of windows as 1 he has miscounted. The floor he counted as 11 is actually floor 10 according to its address (and the lift). He needs to go up one more floor to get to the one addressed as 11. Floor “11” is actually the 12th set of windows.

Link  to programming: This is possibly one of the most common mistakes programmers make, counting from 1 instead of 0. In many programming languages, arrays, for example are indexed from 0 so the first cell in the array is cell 0, the next one is cell 1 and so on. If a programmer forgets this, and they often do, then they can end up with a program that accesses the wrong position. Possibly worse miscounting positions in arrays and buffers can lead to the program accessing a position that is not in the array at all, but off the end, so overwriting something else that it shouldn’t. Many security flaws result in that kind of problem where programs overwrite other parts of memory.