Backstory [which is not true]
A piano is set up like this:
However, on my piano, all of the black keys are broken!
I still want to be able to play some chords on my broken piano though.
In music, a chord is a group of notes that are played together. To allow for input of chords, I will first define what a semitone is.
What is a semitone?
A semitone is the smallest distance in Western music. If you look at the top part of the piano, you see that you can usually move from a black key to a white key, or vice versa; however, between B
and C
and E
and F
there is no black key.
What is a chord?
For the purposes of this challenge, we define a chord as a bunch of notes with a certain number of semitones between them. For example, let's take a took at a 4-3-3
chord starting on C
(for music people, this is a V7 chord in F major). We start at C
. We count up 4 semitones: C#
, D
, D#
, E
. The next note is E
, and we count 3 semitones up after that: F
, F#
, G
. The next note is G
, and we count 3 semitones up after that: G#
, A
, Bb
. So, we get C-E-G-Bb
. Yay! But wait... Bb
is a black key and those are broken... However, if we start from G
, we get G-B-D-F
! Yay!
Input
Input is given as a list of integers in any reasonable format. This represents the chord as described above.
Output
Output should be a list of notes on which I can start to only need to use white keys. This can also just be a string of all of the up to 7 notes because all of the keynames will be one character. You must be able to handle having an empty output as well.
Test Cases
input -> output // comments
4 3 -> C F G // this is a major triad
3 4 -> D E A // this is a minor triad
4 3 3 -> G // this is the major-minor seventh chord
3 3 3 -> [empty output] // this is the diminished-diminished seventh chord. All of them use black keys
4 4 -> [empty output] // this is an augmented triad
3 3 -> B // this is a diminished triad
1 -> B E // this is just a minor second
11 -> C F // this is just a major seventh
Other specs
- Standard Loopholes forbidden
- You may assume that the input has at least one integer
- You may assume that all of the integers are non-negative and less than 12 (because the piano repeats every 12 notes)
- Output may be in any order
Winning Criteria
The shortest valid submission as of April 15th will be accepted.