Back
Close

Chord Transpose

Statement

 Goal

Your friend Alice wants to play the piano but finds it difficult to learn chords. So you decided to write a tool that will help her to practice.

Your script should take a notes series notes and transpose it by semitones. It means moving all the notes up (or down for negative semitones) the same number of semitones (keys). A keyboard consists of notes:
C C# D D# E F F# G G# A A# B
and they are cycled, so after a 'B' it's a 'C' again and so on.
Input
Line 1 : A string notes with notes separated by spaces.
Line 2 : An integer semitones showing the number of keys to move.
Output
A single line containing a transposed notes series. Notes are separated by spaces.
Constraints
notes can have from 1 to 3 notes.
-48 <= semitones <= 48
Example
Input
C E
1
Output
C# F

Game modes
Fastest, Shortest

Test cases
Example Test
Input
C E 1
Output
C# F

Example Validator
Input
F G# 1
Output
F# A

One up Test
Input
D 1
Output
D#

One up Validator
Input
F 1
Output
F#

One down Test
Input
G# -1
Output
G

One down Validator
Input
D# -1
Output
D

A third Test
Input
C E 2
Output
D F#

A third Validator
Input
D F# -2
Output
C E

Octave Test
Input
C E G 12
Output
C E G

Octave Validator
Input
A B C 12
Output
A B C

Wide diapason Test
Input
G B D 27
Output
A# D F

Wide diapason Validator
Input
G# B D 25
Output
A C D#

Down a chord Test
Input
C G C -5
Output
G D G

Down a chord Validator
Input
F# C# F# -7
Output
B F# B

No modulation Test
Input
C 0
Output
C

No modulation Validator
Input
D 0
Output
D

Negative Test
Input
F -12
Output
F

Validator 9 Validator
Input
E -11
Output
F

Solution language

Solution

Stub generator input