7
2
On a standard 88 key piano, each key has a scientific name.
The first three keys are A0, B♭0, and B0. The keys then proceed through C1, D♭1, D1, E♭1, E1, F1, G♭1, G1, A♭1, A1, B♭1, B1, and start over again at C2. This continues up through B7, and the final key is C8.
Any flat can instead be written as a sharp of the preceding note, e.g. D♭4 can also be written C♯4. If necessary, you can write "D♭4" as "Db4".
Your program should build an ordered sequence (array, list, vector, etc.) containing the key names (as strings, symbols, or some similar data structure) in order.
Program length should be measured in characters, to avoid penalizing people who properly generate ♯ or ♭ rather than # or b. However, Unicode recoding is forbidden.
I'd prefer having scoring by bytes, except in the case of ♯ and ♭ which count as one byte each. – lirtosiast – 2015-06-08T20:35:26.023
Here is a previous question that might be useful, as it involves taking note names as input. – PhiNotPi – 2012-07-28T13:13:33.153
3"Unicode recoding is forbidden." Can you edit the question to explain what that means, please? – Chris Jester-Young – 2012-07-30T17:31:06.597
@Chris: I think it may refer to putting a compressed byte sequence into a Unicode string and just decompressing that. – Joey – 2015-10-11T14:03:47.843