## Teaser 3042: A question of scale

**From The Sunday Times, 10th January 2021** [link]

The modernist music of Skaredahora eschewed traditional scales; instead he built scales up from strict mathematical rules.

The familiar major scale uses 7 notes chosen from the 12 pitches forming an octave. The notes are in (1) or out of (0) the scale in the pattern 101011010101, which then repeats. Six of these notes have another note exactly 7 steps above (maybe in the next repeat).

He wanted a different scale using 6 notes from the 12 pitches, with exactly two notes having another note 1 above, and one having another 5 above. Some notes could be involved in these pairings more than once.

His favourite scale was the one satisfying these rules that came first numerically when written out with 0s & 1s, starting with a 1.

What was Skaredahora’s favourite scale?

[teaser3042]

## Jim Randell 5:14 pm

on8 January 2021 Permalink |By choosing the excluded pitches we ensure that the scales are generated in the required order, so we only need to find the first scale that satisfies the specified condition.

This Python program runs in 45ms.

Run:[ @repl.it ]Solution:Skaredahora’s favourite scale is 100010101110.We can consider this as a binary representation of the number 2222.

There are 12 possible scales starting with 1 that have exactly 2 notes with another note 1 above, and exactly one having another note 5 above.

There are also 12 possible scales starting with 0.

LikeLike

## Jim Randell 11:04 am

on9 January 2021 Permalink |Here is another solution that treats the scales as numbers represented in binary.

We can use the [[

`bit_permutations()`

]] function from theenigma.pylibrary (described here [link]) to generate patterns with 6 bits set in lexicographic order.It runs in 45ms overall, and has an internal runtime of 55µs.

Run:[ @repl.it ]And here is an “unrolled” version that has an internal runtime of only 24µs [ link ].

LikeLike

## Tony Brooke-Taylor 12:54 pm

on9 January 2021 Permalink |I tried the binary approach first and was annoyed that this took more than twice as long as your first solution Jim. Having swapped other bits of my algorithm for yours I think the biggest time difference comes from this: your first approach generates trials with only the 6 notes in; my binary approach generates trials with all 12 positions included, and then I have to use an if statement or similar to test only the 6.

LikeLike

## Brian Gladman 10:24 am

on9 January 2021 Permalink |You get the speed record this week Jim. And you can gain a few percent more by using a set for in place of a tuple. Maybe I am being stupid but it was not immediately obvious to me why lexically sorted zero digit positions produced numerically sorted values.

LikeLike

## Jim Randell 11:02 am

on9 January 2021 Permalink |@Brian: The lowest number will have the largest leftmost grouping of 0’s. And fortunately combinations are generated in lexicographic order, so that gives us what we want.

LikeLike

## Frits 12:22 pm

on9 January 2021 Permalink |As the puzzle is not yet fully clear to me I publish a solution which does the same as Jim’s code.

I tried to use different and probably less efficient code.

LikeLike

## Frits 1:00 pm

on9 January 2021 Permalink |check5 can also be written as:

LikeLike

## Hugh Casement 1:24 pm

on17 January 2021 Permalink |Using Basic (oh horror!) I found the same solution as Jim.

Five other scales can be found by transposing the scale up or down by appropriate numbers of semitones, always with 1 in first position. Each can be reversed to give the other six.

I think the solution corresponds to C E F# G# A A#.

Some of those sharps may be better designated as flats of the note above

(though in an equitempered scale it makes no difference).

Five semitones apart is the interval known as a fourth; that leaves seven semitones, known as a fifth, to the octave note. Those are generally considered the most harmonious intervals, so a person with normal hearing would want as many as possible in the scale. I bet S’s so-called music sounds even worse than the stuff they play in the supermarket so that we don’t linger over our shopping a moment longer than necessary. But then I’ve always said that the only good composer is a dead composer — preferably one who’s been dead for a couple of centuries.

LikeLike