Sum of Two Intervals
A k-th interval plus an m-th interval is a (k+m-1)th interval. An interval with p semitones plus one with q semitones is one with (p+q) semitones. Given two intervals, get their sum. Relations between interval and semitones is listed below.
Interval | Double Diminished |
Diminished | Minor | Perfect | Major | Augmented | Double Augmented |
---|---|---|---|---|---|---|---|
unison (1st) |
-2* | -1* | - | 0 | - | 1 | 2 |
2nd | -1* | 0 | 1 | - | 2 | 3 | 4 |
3rd | 1 | 2 | 3 | - | 4 | 5 | 6 |
4th | 3 | 4 | - | 5 | - | 6 | 7 |
5th | 5 | 6 | - | 7 | - | 8 | 9 |
6th | 6 | 7 | 8 | - | 9 | 10 | 11 |
7th | 8 | 9 | 10 | - | 11 | 12 | 13 |
octave (8th) |
10 | 11 | - | 12 | - | 13 | 14 |
* Negative distance doesn't exist but it can be added 12 until non-negative
For larger interval, k-th interval has 12 more semitones than the same type of (k-7)-th interval. Triple Augmented is 1 more semitone than Double Augmented, Triple Diminished is 1 less semitone than Double Diminished, etc.
IO format
- The interval would likely get inputted as one argument
- You can take Double Diminished/Diminished/Minor/Perfect/Major/Augmented/Double Augmented as -2/-1/a/b/c/1/2, where
a
,b
,c
are different, zero or non-integer - You can take Double Diminished/Diminished/Minor/Perfect/Major/Augmented/Double Augmented as -3/-2/-1/0/1/2/3
- Same applies to output
Test cases
Minor 2nd + Major 3rd = Perfect 4th
Major 2nd + Major 2nd = Major 3rd
Major 3rd + Major 3rd = Augmented 5th
Augmented 2nd + Augmented 3rd = Triple Augmented 4th
Double Diminished 6th + Double Diminished 7th = 5 Times Diminished 12th
Augmented 1st + Minor 2nd = Major 2nd