18
1
A guitar fretboard diagram looks like this:
0 1 2 3 4 5 6 7 8 9 10 11 12 <- Fret number (0 means it's open)
|-E--F--F#-G--G#-A--A#-B--C--C#-D--D#-E
|-B--C--C#-D--D#-E--F--F#-G--G#-A--A#-B
|-G--G#-A--A#-B--C--C#-D--D#-E--F--F#-G
|-D--D#-E--F--F#-G--G#-A--A#-B--C--C#-D
|-A--A#-B--C--C#-D--D#-E--F--F#-G--G#-A
|-E--F--F#-G--G#-A--A#-B--C--C#-D--D#-E
As you can see, the first string (from the top) open is an E
. The first fret on the first string is an F
. The fourth fret on the third string is a B
. Note that the first note is the zeroth fret, not the first.
This can be written with numbers on the format string, fret
. The strings are numbered from 1 to 6 from top to bottom.
The frets are numbered from 0 to 12 from left to right. The first E
is therefore 1, 0
. Some other examples:
1, 0 --> E
1, 1 --> F
3, 5 --> C
5, 1 --> A#
6, 6 --> A#
Challenge:
Take N
pairs of numbers (s
and f
), and output a delimited note succession.
- The input may be on any suitable format. tuples, 2D-matrix, two separate lists, an interweaved list (string,fret,string,fret...) etc.
- The output tone should be separated, but the delimiter is optional (comma, space, dash...). The output can be in either upper or lower case.
s
(for string) will be in the range[1, 6]
(you may choose to have i 0-indexed)f
(for fret) will be in the range[0, 12]
Test cases and examples:
1 4 5 2 1 3 <- String
4 2 6 3 5 1 <- Fret
G# E D# D A G#
6 2 3 1 4 2 3 2 2 2 6 5 2
0 1 2 3 4 5 6 7 8 9 10 11 12
E C A G F# E C# F# G G# D G# B
3 3 3 3 3 3 3 3 3 3 3 3 3 <- String
0 3 5 0 3 6 5 0 3 5 3 0 0 <- Fret
G A# C G A# C# C G A# C A# G G
// The same test case, but different input and output format:
(3,0)(3,3)(3,5)(3,3)(3,6)(3,5)(3,0)(3,3)(3,5)(3,3)(3,0)(3,0)
G,A#,C,G,A#,C#,C,G,A#,C,A#,G,G
Good luck, and happy golfing!
Not a guitarist (nor even a decent musician, really), but isn't there a significant omission here, if you're expecting output as recognizable tunes? That is, the note duration - whole, half, quarter notes, &c. – jamesqf – 2016-09-27T05:10:30.367
1
@jamesqf Nope, it's perfectly fine as long as you know the song. This is currently the most popular song on ultimate-guitar.com. Have a look at the intro.
– Stewie Griffin – 2016-09-27T06:12:59.297