Skip to main content
added 1039 characters in body
Source Link

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)

 

ExampleLittle bit of music theory

A piano contains 88 keys: 52 whites and 36 blacks. The keys are divided into octaves which have 7 white keys and 5 black. The notes represented by the white keys go from A to G (although the starting note in an octave is C; notes from left to right are as following: C, D, E, F, G, A, B). The notes represented by the black keys are accidentals of the white keys. An accidental is either a sharp note (#) or a flat note (b). (There is an exception since there is only 5 black keys and 7 white keys, Should I expand on this?) . A sharp note is one semitone higher than the same note (C# is one semitone higher than C). A flat note is one semitone lower (Db is one semitone lower than D). There is one full tone in between notes except for E-F and B-C where there is a semitone instead and one semitone between keys.

I'll keep adding more details if needed

Note: For this challenge, we don't care which octave the triad is played on since it will be the same answer for any octave.

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?

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?

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)

 

Little bit of music theory

A piano contains 88 keys: 52 whites and 36 blacks. The keys are divided into octaves which have 7 white keys and 5 black. The notes represented by the white keys go from A to G (although the starting note in an octave is C; notes from left to right are as following: C, D, E, F, G, A, B). The notes represented by the black keys are accidentals of the white keys. An accidental is either a sharp note (#) or a flat note (b). (There is an exception since there is only 5 black keys and 7 white keys, Should I expand on this?) . A sharp note is one semitone higher than the same note (C# is one semitone higher than C). A flat note is one semitone lower (Db is one semitone lower than D). There is one full tone in between notes except for E-F and B-C where there is a semitone instead and one semitone between keys.

I'll keep adding more details if needed

Note: For this challenge, we don't care which octave the triad is played on since it will be the same answer for any octave.

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?

added 60 characters in body
Source Link

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

Example

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

Input can be the chord name or can be divided into 32 variables: ScaleRoot (A-G)C, Accidental (#F, bG#, Gb), Type and quality (majormaj, minormin). 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?

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?

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?

Source Link

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?