Skip to content

Sunday Times Teaser 3266 – Where are the Keys?

by BRG on April 27, 2025

by Colin Vout

Published Sunday April 27 2025 (link)

WUQRVWQRXWTRUQWRVQWTSRQWVRSTWQVRWQURTWXRQVWRTSX

Skaredahora’s venture into atonal music — music with no fixed key — had as its (so-called!) melody a long sequence employing 8 different notes, which he labelled Q to X. Behind his composition were 7 keys each using 4 notes. Every three consecutive melody notes obeyed specific rules: all three had to be different; they had to belong to exactly one of the keys; they had not to repeat in the same order any other three consecutive notes; and the key had to change at every step. His chosen melody was as above.

What were the keys involving X, in alphabetical order individually and collectively (eg, QRTX, SUVX)?

From → Uncategorized

12 Comments Leave one →
  1. BRG permalink

    • Frits permalink

      Another idea would be to derive partial keys when setting up n3s (after setting up bad_keys).
      The following code generates 7 keys of three notes.
      As your version is already very fast this concept doesn’t improve the performance.
      With a longer melody and more notes and keys it might.

      • BRG permalink

        I also tried some approaches that reduced the number of recursive calls but
        none improved the speed. As you suggest, this puzzle’s solution space is too
        small to small to test such ideas.

  2. Frits permalink

  3. Frits permalink

    A more efficient version using Brian’s set up. I do some of the checks after the recursion.

    • Frits permalink

      We can bring down the number of recursion calls to 99 if we add code after line 22 but It slightly increases the run time.

  4. JohnZ permalink

    • Frits permalink

      Very nice.

    • BRG permalink

      Hi John, Its nice to see a different approach!

      I know almost nothing about music so I am unclear how you derived the constraint
      on line 9? Why does a change of key mean that there cannot be four consecutive
      notes?

    • John Z permalink

      Hi Brian,

      I probably know less about music than you!

      Starting from the left the melody’s first four notes are WUQR. This gives two groups of three: WUQ and UQR. If WUQR is a key (QRUW sorted) then both groups of three are in the same key which violates the last rule: “and the key had to change at every step.” Consequently, consecutive groups of four notes cannot form a key.

      Leaving out the ” – fours ” from line 13 gives the same result, just takes longer.

      The trick with my approach is to weed out the candidate keys to a reasonable number so that the final

      doesn’t take too long. Taking the potential keys as the fourwise combinations of all of the eight notes also works but the execution time is very, very long.

  5. BRG permalink

    Thanks John, I now get the connection. The word ‘consecutive’ can add to confusion in
    this teaser since it could mean consecutive by position or consecutive by value (e.g.
    “QRST”). So I have changed the comments in my code to avoid this word.

    It would be nice to add a bit more to your line 9 such as:

  6. JohnZ permalink

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS