Ernie is a renowned polyglot. Why just last week I saw him helping out at a Mathematics conference by acting as a simultaneous translator for seven guests who only spoke Hungarian, Icelandic, Swahili, Tongan, Arabic, Cantonese and Basque respectively. So Imagine my surprise last night when we went to a newly opened French Bistro and Ernie had to ask the waiter to translate the blackboard menu, which consisted of very elementary French such as soupe du jour and porc avec pommes de terre. So after a fine main course I asked why he didn't know any French. "Ahh...", he said, with a look of reminiscence on his face, "it may not be fair, but I still blame the Geek Girl for that". Even for Ernie, that was a somewhat opaque statement so I asked him to explain a little more. And this is what he told me...

It all began on day one of my first Senior School Maths Olympiad. On the team for another school I saw the cutest geek girl you could imagine. I was smitten by the way her braces glinted in the sunlight. But the path to true love is not an easy one - I was younger than any of the other contestants and to my dismay she ignored me totally. At lunch time the older students played a game called 'Slice of Pi'. The rules were simple:

 The caller would shout out "Slice of Pi" followed by one or more pairs 
 of integers *(p1,q1), (p2,q2)...(pn,qn)*. 
 The responder had to reply with a single string of digits consisting of
 the *q1* digits of pi starting at the *p1th* place after teh decimal 
 point, concatenated with the *q2* digits of pi starting at digit
 *p2*,...etc. right out to *qn* digits starting at place *pn*.

"So," I asked, if someone said "Slice of Pi (3,3), (1,1) (7,2) the correct response would be 159165?" Ernie paused for several seconds (longer than I would normally expect for an answer to a simple maths question) and then replied "Correct - and an adjudicator would confirm the answer was right using a paper table of pi from an old maths book". He continued...

One of the boys was almost always the winner. "He has memorized all the digits out to the 200th decimal place", claimed the Geek Girl with a look of adulation on her face. I instantly decided this was my chance to impress her - "Oh that's nothing", I boasted, "I bet I could learn all the way out to the 2000th place by tomorrow morning!" The others laughed in disbelief. "Then we will test you on that tomorrow!" said the team leader.

On my way home in the bus that night I realized what a task I had set myself. Like any sensible engineer I only knew 9 digits of pi and even if I could learn a digit every twenty seconds it would take more than eight hours to memorize the remaining 1991. I also needed to swot up for the next day's Programming Contest and knew that without a good night's sleep my performance would be dismal. But then I found the solution to all my problems in the issue of Popular Science where I found an article on how 'sleep-learning' experiments had been trialed back in the 1950's - as soon as I read the Introduction I was convinced it would work!

By the time I got home I had the plan in place. Luckily, my computer project at my last Junior Olympiad had been text scanning, character recognition, and text to speech translation and I still had the old code. I pulled down my copy of Smith's "The First Million Digits Of Pi", and set my scanner onto it. Then I hacked out a quick routine that would repeatedly loop my text to speech algorithm through the first 2000 digits. My plan was to sleep for 12 hours with the digits playing to my subconscious mind as I slept, via a set of old headphones. The headphones were stereo, so I could play a second soundtrack into my other ear. Once the Pi file was ready I quickly scanned all three Volumes of Knuth's The art of Computer Programming using the same software and set up the Knuth file to play at 10 times normal speed so I could get through most of the series over-night. I got both files ready to run then hacked a 600 second delay in my text to speech program so I could get to sleep before the words began, set my alarm clock for 7:00 am, attached the earphones and fell into a deep sleep. What could possibly go wrong?

Unfortunately, the earphones blocked the sound of the alarm clock so it was 8:30 before I woke up. I had already missed the bus and had to cycle into town so never a chance to check if the sleep-learning had worked. I arrived at the Olympiad and joined the geek girl's team. "Right then", said the team leader, "time for your test Shorty. Let's start with something easy to begin with. Slice of Pi (1,9)". I opened my mouth (after all - I already knew the first 9 decimal places) and blurted out "112345569". I fled from the room in embarrassed. I also fell instantly out of love with the geek girl when I heard her donkey-like bray of laughter pursuing me out the door. It was a year before I was willing to show my face at another Olympiad.

enter image description here

"So the sleep learning didn't work?" I interrupted, "It just confused your mind?". "Not Quite", Ernie replied, and continued...

It took a few hours of investigation to discover what had happened. In my haste the night before I had confused the two files - so in one ear i had been hearing the same short section of Knuth repeated again and again and again all night - and simultaneously a vast number of digits of pi had been fed into my other ear (at 10x normal speed). The sleep learning had worked too well. My mind had absorbed all the digits of pi that I heard, but due to the multiple repetitions a quick-sort algorithm had been driven deep into my unconscious mind. Any time I tried to recollect a sequence of digits of pi (or a group of sequences), my subconscious automatically sorted the digits before relaying them to my conscious mind.

And there was another problem too. That evening I decided to take solace in Proust's 'À la recherche du temps perdu' in which I had been deeply engrossed over the previous few weeks, but was shocked to discover that I couldn't read a word of it. Every atom of the French language had been totally erased! I opened the Pop Sci magazine again and this time read the whole article. There was a short section near the end describing an unfortunate side effect of adding too many new memories in a short time. In some subjects the new memories displaced old memories. In my case all my knowledge of written and spoken French had been deleted!

At that moment I had to stop Ernie - "its a great tale", I said, chuckling with laughter "You almost had me believing you for a minute". "But it's true, Ernie asserted. "Test me if you like, and if it doesn't work like I told you I will buy you a good Whiskey - and to be fair, if it does work then you can shout me a bottle of Brandy."

So I quickly jotted down four numbers on a tissue so I could check them later and asked Ernie for the "Slice of Pi (p1,10), (p2,20), (p3,30), (p4,40)" Ernie paused for a moment and then replied " that would be...


"That's a bit unlikely", I said, "are you sure." "Of course I am!" Ernie replied, "You can check the digits online, if you don't believe me. What's more, if you can work out the minimum number of digits I must have learned to get the answer right, I will buy you a dozen bottles of Whiskey!".

Now I trust Ernie's word implicitly, so have already bought him the brandy, but I would love to get 12 bottles of whiskey in return. I decided to check out the numbers but realized I had left the tissue with the numbers p1, p2, p3, and p4 behind at the restaurant - the only thing I can remember about them was that p1 is less than p2 is less than p3 is less than p4*.

From the information provided can you confirm Ernie's digits could be correct for some p1,p2,p3 and p4, and if so is possible to calculate the minimum possible number of digits he knows?

  • $\begingroup$ I love the Ernie stories! And the puzzles are great, too! +1 $\endgroup$ Dec 2, 2015 at 5:44
  • 2
    $\begingroup$ At least judging from what Wikipedia links to on $\pi$, it's still unknown whether or not $\pi$ is a normal number. I suspect this means that the answer is going to be "yes", given that I'm almost positive that a "no" answer would be enough to solve that open problem. Of course, that doesn't exactly help produce the p1,p2,p3,p4 for the problem here. $\endgroup$ Dec 2, 2015 at 8:22
  • $\begingroup$ The obvious answer is that he learned a hundred digits, and it's precisely those digits. :) I'm working on a more satisfying answer, though, with the help of programming. $\endgroup$ Dec 2, 2015 at 9:26
  • $\begingroup$ Oh shoot, wait, the problem allows for overlap, so it might not even be a full hundred digits. Drat. Anyway, still working. $\endgroup$ Dec 2, 2015 at 9:27
  • $\begingroup$ "The minimum possible number of digits" - Is it safe to assume that Ernie knows all the digits from 1 to p4+39, or can Ernie have gaps in his knowledge of pi (which could lead to a theoretical low of 40 digits total)? $\endgroup$ Dec 3, 2015 at 15:32

1 Answer 1


There are several possible solutions for $(p1, p2, p3, p4)$. Assuming that you with 'possible to calculate the minimum possible number of digits he knows' means a solution with the lowest possible $p4$, we have:

(42, 10) = 9399375105
(48, 20) = 51058209749445923078
(92, 30) = 421170679821480865132823066470
(210,40) = 5665933446128475648233786783165271201909

I've let my search for possible solutions run a little bit longer and if with 'minimum possible number of digits he knows' is ment to find the lowest possible value of $p4-p1$ (continuous range of digits), I soon found a range of only 65 digits: (1399,10), (1399,20), (1413,30) and (1424,40).

The solutions to the problem are actually not particularly rare. For $p4 <= 1000$ there are 1556 solutions and for $p4 <= 2000 $, there are 16376 solutions. That however, I find slightly odd. I would have expected the number of solutions to increase linearly with the number of combinations, which is at least roughly quartic in relation to $p4$ (doubling $p4$ should result in $2^4$ or 16 times as many solutions).

  • $\begingroup$ I'd be interested to know what search method you used. $\endgroup$ Dec 3, 2015 at 6:30
  • $\begingroup$ @2012rcampion Just a brute force search by increasing p4 and letting p3 run from 1 to p4, p2 from 1 to p3 and p1 from 1 to p2. My gut feeling told me that the chance for finding a match was reasonable, but I didn't expect to find one for such a low value of p4. $\endgroup$
    – jarnbjo
    Dec 3, 2015 at 7:54
  • $\begingroup$ I'm quite surprised that a brute force search worked in a reasonable time. Then again, I expected p4 to be on the order of thousands. $\endgroup$ Dec 3, 2015 at 12:23
  • $\begingroup$ @frodoskywalker Starting with p4=4, I had the first match after less than 8 million tries. The brute force search ran only about 3.5 seconds. $\endgroup$
    – jarnbjo
    Dec 3, 2015 at 13:05
  • 5
    $\begingroup$ @jambo Impressively low P4. I realised after posting that I couldn't accept the whiskey from Ernie (at least without sharing it with jambo which has logistical problems). So I asked Ernie what the numbers really were. He told me that I had asked "Slice Of Pi (60,10) (33673,20) (101390,30)(142620,40)", Curiously enough the first pair alone would produce the answer 0123456789, the second pair 00112233445566778899 and so on. Had I asked "Slice of Pi (145870,50) he would have said 00000111112222233333444445555566666777778888899999 and that would be the exact limit of his memory. $\endgroup$
    – Penguino
    Dec 4, 2015 at 2:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.