CProject3
Transpose
The conventional western musical scale is based on 12 tones:
A A# B C C# D D# E F F# G G#
The sequence repeats indefinitely - the next note higher than G# is also called A.
Each step from one note to another in this sequence is called a half-step. The # symbol is called a ``sharp" and actually means ``raised a half step". Hence ``A#" is ``A raised a half-step". There is a similar symbol ``flat" meaning ``lowered a half-step" that we will render as ``b" in this problem, though it is normally written as $ \flat$ .
Given that meaning for # and b, it is possible for notes to actually be referred to by more than one name. A# and Bb refer to the same note. B# means the same as C. Fb means the same as E.
A common task for musical arrangers is to transpose a work of music - to raise or lower the entire work by some number of half-steps in order to fit better into the range of a particular singer or musical instrument. A proper transposition will preserve the number of half-steps between any two successive notes in the work.
Input
Input consists of one or more input sets.
An input set consists of a line containing a sequence of 0 or more notes with sharp and flat marks, each note separated fro mthe others by one or more blanks. This is followed by a line containing a single integer indicating the number of half-steps to transpose the piece (positive numbers indicating the notes should be transposed up, negative indicating it should be transposed down).
The end of input is signaled by a line consisting of the string ``***".
Output
For each input set, you should print one line containing the sequence of transposed notes, each represented as in the list of 12 given at the start of this problem. Notes should be printed with a single blank space separating them.
Sample Input
C# E Db G# 1 D E# D A -1 ***
Sample Output
D F D A C# E C# G#
Logistics
Origin of Problem
3919 - First Composed, Then Transposed
ACM-ICPC Live Archive: North America - Mid Atlantic - 2007/2008
Submission Guidelines
- Use the ACM-ICPC Live Archive - Submit-o-matic 6.0. Please forward the ACM results.
- Also please submit your program using the turnin script at http://rosemary.umw.edu/~raz/turnin/turnin.php If (and only if) you have a problem with turnin, email me your program.
Grading
- A: your code runs in 0.004 CPU time or less (or is the fastest in the class)
- B: your code runs on the Submit-o-matic 6.0 server, runs in 0.010 CPU time or less and is clean and well organized.
- C+: your code runs on the Submit-o-matic 6.0 server or less and is clean and well organized.
- C-: your code runs and produces results locally but does not run on Submit-o-matic 6.0 server.
- D: You code does not produce correct results.
- F: Your code does not compile or link.
Comments
Egypt
Program produces some correct results. It does not terminate when I try
./a.out < music.txt
where music.txt contains the example from this writeup.
Harpertown
program does not produce correct results when I input zero notes.
Kentsfield
Your program does not terminate when I try
./a.out < music.txt
Troy
Your code does not produce correct results for example an input of D F# A -2 produces C E G#
Windsor
Your program fails on D F# A -2. It returns
C E Error!
Yorkfield
Your code does not produce correct results. For example, I have an input file music.txt:
D F# A 12 D F# A -2 -2 C E G 0
I execute
./a.out < ../music.txt D F# A C E G C E G This letter � is not a valid noteThis was not valid input
