7
For this challenge, you need to print out the fingerings for various brass instruments.
The notes an instrument can play (as well as their fingerings) are listed below:
Cornet Baritone
Trumpet Bugle French Horn Euphonium Tuba
A#0 0
B0
C1 1234
C#1 134
D1 234
D#1 14
E1 24
F1 4
F#1 23
G1 12
G#1 1
A1 2
A#1 0 0
B1 123 1234 24
C2 13 134 4
C#2 23 234 23
D2 12 124 12
D#2 1 14 1
E2 2 24 2
F2 0 4 0
F#2 123 23 23
G2 13 12 12
G#2 23 1 1
A2 12 2 2
A#2 1 0 0
B2 2 24 12
C3 0 4 1
C#3 23 23 2
D3 12 12 0
D#3 1 1 1
E3 123 2 2 2
F3 13 0 0 0
F#3 23 12 23 23
G3 12 1 12 12
G#3 1 2 1 1
A3 2 0 2 2
A#3 0 1 0 0
B3 123 2 12 12
C4 13 0 1 1
C#4 23 23 2 2
D4 12 12 0 0
D#4 1 1 1 1
E4 2 2 2 2
F4 0 0 0 0
F#4 23 2 23 23
G4 12 0 0 12 12
G#4 1 2 1 1
A4 2 0 2 2
A#4 0 1 0 0
B4 12 2 12
C5 1 0 0 1
C#5 2 23 2
D5 0 12 0
D#5 1 1 1
E5 2 0 2 2
F5 0 0 0
F#5 23
G5 12 0
G#5 1
A5 2
A#5 0
Input
- A single string with a name of an instrument. You can assume the name will always be one of the 7 listed above.
- A note, which can be a single string or a string and integer. You can assume the note will match one of the notes listed above.
Output
- The fingering for the note on that instrument. This can either be a list of integers (one for each digit), or a single integer.
- If the instrument cannot play a given note (listed as blank above), return
"Impossible"
Test Cases
Cornet D#3 Impossible
Cornet E3 123
Trumpet G4 12
Trumpet B4 12
Trumpet F#5 23
Bugle F#5 Impossible
Bugle G5 0
Bugle G1 Impossible
French Horn B1 123
French Horn C3 0
French Horn E5 2
French Horn A#5 Impossible
Baritone A#5 Impossible
Baritone A#2 0
Baritone B2 24
Baritone B1 1234
Euphonium F2 4
Tuba A#0 0
Tuba B0 Impossible
Tuba C1 1234
Tuba B1 24
Tuba G#4 1
Tuba B4 Impossible
Notes
- Trumpet and Cornet have the same fingerings, as well as Baritone and Euphonium
- These ranges aren't comprehensive. I've tried to stick to the "standard" notes, but instruments can often go below (pedal notes) or above.
- The notes listed are in concert pitch
- You'll notice that there are a lot of patterns between the fingerings. Finding those patterns is critical to golfing this well.
This is a code-golf, so the shortest answer in your favorite language wins!
This is the kind of weird info you learn on PPCG. The only wind instrument I play is tin whistle, but I understand the brass valves work as follows: valve 2 =-1 semitone, valve 1=-2 semitones, valve 3=-3 semitones, valve 4=-5 semitones. I find it odd that the tuba is different from the euphonium, I would think the fingerings should be the same, just an octave down. I think the blank line should be removed and a 124 inserted at the appropriate place. Am I right? – Level River St – 2016-01-16T21:24:12.997
A little research shows it depends if your tuba is compensating or noncompensating. I am correct for a compensating tuba. http://www.norlanbewley.com/tuba/fingering-tuba-1.htm shows the B is indeed missed for a noncompensating tuba, though he skips a 14 instead of 124 at the D. It seems like basically you're tuning on the fly with the embocouchure. This question has given me more respect for tuba players! I guess we stick with the question as written then.
– Level River St – 2016-01-16T21:49:04.283@steveverrill I was literally in the middle of saying that very thing :) – Nathan Merrill – 2016-01-16T21:52:28.080
3Oh another minor point: Normally the octave changes number between B and C, not between G and A. In reality all your A's and B's should be an octave lower than you have written them. Are you going to correct it, or leave it as it is? (easier to golf as it is.) – Level River St – 2016-01-17T00:07:18.787
@steveverrill welp, my bad. I have no idea how I didn't know that, as I have taken music theory courses. – Nathan Merrill – 2016-01-17T05:09:23.607
You probably need to edit the test cases too. – Level River St – 2016-01-17T05:28:37.633