Skip to main content
1 of 3

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 the triad. (I will add more explanation later)

Example

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

Input can be the chord name or can be divided into 3 variables: Scale (A-G), Accidental (#, b, ), Type (major, minor)

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?