Enigmatic Code

Programming Enigma Puzzles

Enigma 141: Singing in the train

From New Scientist #1285, 24th December 1981 [link]

A Christmas puzzle

As part of an advance promotion campaign, British Rail persuaded Santa Claus to drive one of its special trains home from London after Christmas. On a calm evening the train had passed the Station Inn in a small village and was approaching the Church when Santa began to hum an appropriate carol. The publican heard the first two notes as E and thought the carol was “God Rest Ye Merry, Gentlemen” while the vicar heard the first three notes as B and identified it as “Angels from the Realms of Glory”.

What note did Santa hum, what was the speed of the train, what was the carol, what day was it and from which station had the train left London?

(The key for all three carols is G major (using a diatonic scale), as given in the “Penguin Book of Christmas Carols”, though it should be possible to obtain the answers without the music. The speed of sound in air at 0°C is 741 mph.)

This was not a prize puzzle. The solution was published in the same issue.

This completes the archive of puzzles from 1981. There are now 541 puzzles on the site, with a continuous archive from the start of Enigma in 1979 up to 1981 and also from (almost the start of) 2006 up to 2013. I shall continue adding puzzles to fill in the gaps.



One response to “Enigma 141: Singing in the train

  1. Jim Randell 2 November 2013 at 8:36 am

    Here’s some code that deals with the Doppler Effect equations to determine the answers to the first couple of questions. It runs in 42ms.

    # for a stationary observer the observed frequency of an object moving
    # away at speed v is: f = (c / (c + v)) f0
    # so the ratio of the frequencies heard by the vicar (f2) and the
    # publican (f1) is:
    # R = f2 / f1 = (c / (c - v)) / (c / (c + v)) = (c + v) / (c - v)
    # solving for v:
    # v = ((R - 1) / (R + 1)) c
    from fractions import Fraction as F
    from enigma import irange, printf
    # multipliers for frequencies in Ptolemy's Intense Diatonic Scale
    notes = (F(1, 1), F(9, 8), F(5, 4), F(4, 3), F(3, 2), F(5, 3), F(15, 8))
    # return note multiplier for different octaves (n = 0 (key note) to 6)
    def notem(n, octave=0):
      return notes[n] * pow(F(2, 1), octave)
    # return note/octave for a given multipler (<note>, <octave>, '=' or '+')
    def note(m):
      assert m > 0
      octave = 0
      while m < 1:
        m *= 2
        octave -= 1
      while not(m < 2):
        m /= 2
        octave += 1
      # find the interval that m is in
      for i in irange(len(notes) - 1, 0, -1):
        m0 = notes[i]
        if m > m0: return (i, octave, '+')
        elif m == m0: return (i, octave, '=')
    # the notes in G major are: G, A, B, C, D, E, F#
    key = ('G', 'A', 'B', 'C', 'D', 'E', 'F#')
    # so compute R, the ratio of a lower E to a higher B
    f1 = notem(key.index('E'), -1)
    f2 = notem(key.index('B'), 0)
    R = F(f2, f1)
    # and hence the velocity of the train
    c = 741 # mph
    v = F(R - 1, R + 1) * c
    # and the original frequency
    f = F(c + v, c) * f1
    # and note
    n = note(f)
    printf("v={v} mph, n={n} [f={f} f1={f1} f2={f2} R={R}]", v=float(v), n='/'.join((key[n[0]], str(n[1]), n[2])))

    Solution: Santa was humming a perfect G. The speed of the train was 148.2 mph.

    My code assumes that the notes heard by the publican and the vicar differ by 7 semitones (giving a speed of 148.2 mph). If they differed by 19 semitones the speed of the train would be 370.5 mph, which we can presume was impossible (even for Santa – who would be humming a perfect B) on a British Rail train in 1981 (high speed trains generally don’t go faster than 200mph).

    The remainder of the solution is less amenable to solving by computer, so here is the published solution:

    1. The difference between the frequency of the notes, f_s, sung by Santa and the notes heard by the publican, f_p, and the vicar, f_v, is due to the doppler effect. For a speed of sound c and if the speed of the train is v, then:

    f_p / f_s = c / (c + v)
    f_v / f_s = c / (c - v)


    f_v / f_p = (c + v) / (c - v)

    2. The scale of G major is:

    G A B C D E F♯ G A B C …

    The ratio of the frequencies to the key-note on a diatonic scale is:

    1 9/8 5/4 4/3 3/2 5/3 15/8 2 9/4 5/2 8/3


    f_v (B) / f_p (E) = (5/2) / (5/3) = 1.5 = (c + v) / (c - v)

    therefore v = 0.2c = 148 mph [sic].

    3. f_p / f_s = c / (c - v) = 5/4

    therefore f_s \equiv G, the note hummed by Santa.

    4. The only popular carol that starts on three identical notes is Good King Wencelas.

    5. Since the carol is appropriate, and it is after Christmas the day is St. Stephen’s day, i.e. Boxing Day.

    6. The only train that British Rail has that could travel at 148 mph is the Advanced Passenger Train. This is electric and the only electrified line going north (Santa going home) starts at Euston station.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: