16
0
The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of seven notes: the eighth duplicates the first at double its frequency so that it is called a higher octave of the same note.
The seven musical notes are:
C, D, E, F, G, A, B, C (repeated for example purposes)
A major scale is a diatonic scale. Take the previous succession of notes as a major scale (Actually, It is the scale C Major). The sequence of intervals between the notes of a major scale is:
whole, whole, half, whole, whole, whole, half
where "whole" stands for a whole tone (a red u-shaped curve in the figure), and "half" stands for a semitone (a red broken line in the figure).
In this case, from C to D exist a whole tone, from D to E exist a whole tone, from E to F exist half tone, etc...
We have 2 components that affects the tone distance between notes. These are the Sharp symbol (♯) and the flat symbol (♭).
The Sharp symbol (♯) adds half tone to the note. Example. From C to D we mentioned that exists a whole tone, if we use C♯ instead C then from C♯ to D exists half tone.
The Flat symbol (♭) do the opposite of the Sharp symbol, it subtract half tone from the note. Example: From D to E we mentioned that exists a whole tone, if we use Db instead D then from Db to E exists a tone and a half.
By default, from Note to Note exist a whole tone except for E to F
and B to C
in where just half tone exists.
Note in some cases using enharmonic pitches can create an equivalent to a Major Scale. An example of this is C#, D#, E#, F#, G#, A#, B#, C#
where E#
and B#
are enharmonic but the scale follows the sequence of a Major Scale.
Challenge
Given a scale, output a truthy value if it is a Major Scale or equivalent, otherwise output a falsey value.
Rules
- Standard I/O method allowed
- Standard code-golf rules apply
- You don't need to take in consideration the 8th note. Assume the input will only consist of 7 notes
- Assume double flat (♭♭), double sharp (♯♯) or natural sign (♮) don't exist
Test cases
C, D, E, F, G, A, B => true
C#, D#, E#, F#, G#, A#, B# => true
Db, Eb, F, Gb, Ab, Bb, C => true
D, E, Gb, G, A, Cb, C# => true
Eb, E#, G, G#, Bb, B#, D => true
-----------------------------------------------
C, D#, E, F, G, A, B => false
Db, Eb, F, Gb, Ab, B, C => false
G#, E, F, A, B, D#, C => false
C#, C#, E#, F#, G#, A#, B# => false
Eb, E#, Gb, G#, Bb, B#, D => false
@Abigail Basically yes. They have the same tone although they are different notes. – Luis felipe De jesus Munoz – 2018-11-08T14:15:03.597
and conversely,
Fb = E
andB# = C
. – Skidsdev – 2018-11-08T14:24:23.5831and Cx (or C##) = D – SaggingRufus – 2018-11-08T18:32:17.003
@SaggingRufus but in this challenge we are not using double sharp – Luis felipe De jesus Munoz – 2018-11-08T18:46:46.177
I'm going to have to downvote this because I don't accept scales that don't have exactly one of each letter in order. No
B#, D, Fb, E#, G, A Cb
thank you very much... – Neil – 2018-11-08T18:53:09.743@Neil A A#/Bb B B#/Cb C C#/Db D D#/Eb E E#/Fb F F#/Gb G G#/Ab those are the only possible notes in that order repeating. – SaggingRufus – 2018-11-08T19:00:19.383
@Neil Ok, you are free to do whatever you want – Luis felipe De jesus Munoz – 2018-11-08T19:09:57.300
1Btw, Pentatonic scales do not have one of each letter :v – Luis felipe De jesus Munoz – 2018-11-08T19:48:26.407
Fair enough, but they do have unique letters in order at least. – Neil – 2018-11-08T21:00:54.710
1
@Neil Chromatic scales do not have unique letters and I'm sure there is a type of scale that doesnt follow an ascending order
– Luis felipe De jesus Munoz – 2018-11-08T21:38:36.973Sure, but those are hardly major scales any more. – Neil – 2018-11-08T23:52:57.970
1I'm going to have to upvote this because @Neil downvoted it thank you very much – David Conrad – 2018-11-09T18:03:11.330