Skip to main content
2 of 3
added 60 characters in body

Counting black and white piano keys

Given a major or minor triad (3 note chord) name, return the amount of black and white piano keys needed to play it. (I will add more explanation later)

Example

Cmaj  = 3 white, 0 black 
Fmin  = 2 white, 1 black
G#maj = 1 white, 2 black
Gbmaj = 0 white, 3 black

Input can be the chord name or can be divided into 2 variables: Root (C, F, G#, Gb) and quality (maj, min). I will extend on music theory if this is accepted as a good challenge

Output must be an array of 2 position where the first one is the number of white keys and the second one the number of black keys


Has this been asked before?