Hide

Problem E
Major or Minor

/problems/majororminor/file/statement/en/img-0001.jpg
C Major and Minor chord shapes

You are a student at a university that combines music and technology. As a part of the curriculum, you are assigned to write a program to recognize basic chord shapes on the piano.

Neighboring keys on a piano (including both black and white keys) correspond to notes that are a semitone apart. The leftmost key on a standard piano keyboard corresponds to a note called $A$. A semitone up from $A$ is note $A\# $. Note $B$ is a (whole) tone above $A$, which is two semitones up from $A$. If we continue to add semitones, we obtain notes $C$, $C\# $, $D$, $D\# $, $E$, $F$, $F\# $, $G$, $G\# $ before the pattern repeats. To distinguish notes with the same name that are separated by a multiple of $12$ semitones (also called an octave) a subscript is used: for instance, $A_1$ is $12$ semitones up from $A_0$.

To represent the piano digitally, we represent each key on the piano by its distance from the lowest note on the piano. Thus the leftmost piano key, $A_0$, corresponds to $0$. $B_0$ corresponds to $2$. $A_1$, the piano key one octave above $A_0$, corresponds to $12$, and so on.

A musical interval measures the number of semitones between any two notes. For instance, a so-called major third interval spans $4$ semitones, a minor third spans $3$ semitones, and a perfect fifth encompasses $7$ semitones.

A (triad) chord contains $3$ notes: a root note, a note that’s up a major or minor third (up $4$ or $3$ semitones, respectively), and a third note that is a perfect fifth (seven semi-tones) from the root note.

Write a program that, given a set of three musical notes, outputs whether these notes are part of a major or minor chord. To determine whether notes are part of a chord, ignore the octave to which they belong: for instance, $(C_0, E_4, G_2)$ would still be considered a $C$ major chord since it contains $C$, $G$, and $E$.

When identifying chords, your program should output the root note and whether the chord is major or minor.

Input

The input is a single line with three integers $a$, $b$, $c$ $(0 \leq a , b , c \leq 87)$ corresponding to three distinct notes on a piano. The notes can appear in any order.

Output

Print the root note and whether the chord is major, minor. If the three notes do not correspond to a chord, output neither.

Sample Input 1 Sample Output 1
0 4 7
A major
Sample Input 2 Sample Output 2
1 5 8
A# major
Sample Input 3 Sample Output 3
0 3 7
A minor
Sample Input 4 Sample Output 4
1 4 8
A# minor
Sample Input 5 Sample Output 5
11 2 6
G# minor
Sample Input 6 Sample Output 6
87 86 83
neither

Please log in to submit a solution to this problem

Log in