Music Interval Solver
Python 2.7, 155 bytes
s='second unison third fourth sixth fifth seventh octave Diminished Augmented'.split()
def f(n,c):x=0xDE9CB87561430>>[4,8][c>'h']*n;print s[x%2+8],s[x/2%8]
Python 2, 149 bytes
def f(n,c):n*=1+(c>'h');print(n-6)%13%2*"Diminished"or"Augmented",'octave seventh sixth fifth fourth third second unison'.split()[71056674174>>3*n&7]
First, whole steps are converted to half steps.
Then, Diminished
vs Augmented
is printed. These alternate for adjacent n
except that n=5
and n=6
give the same, which is achieved by first putting them across a boundary modulo an odd number.
Finally, the distance is printed, computed via a three-bit lookup table. This is shorter than doing int('6746543230210'[n])
.