*You are a composer who just wrote an awesome piece of music. Now it's time to present it to a band that will perform your piece, but there's a problem! The singers vocal range doesn't stretch as your piece requires, and you have to transpose the whole piece.*

# Your task
Given a list of notes (represented as strings) and an interval, output a list of transposed notes in *sharp* notation.

**Input notes may be represented both in flat and sharp notations (more on that below).**

**For this kata, assume that input is always valid and the song is *at least* 1 note long.**

**Assume that interval is an integer between -12 and 12.**

# Short intro to musical notation
Transposing a single note means shifting its value by a certain interval.

The notes are as following:

    A, A#, B, C, C#, D, D#, E, F, F#, G, G#.

This is using *sharp* notation, where '#' after a note means that it is one step higher than the note. So A# is one step higher than A.

An alternative to sharp notation is the *flat* notation:

    A, Bb, B, C, Db, D, Eb, E, F, Gb, G, Ab.

The 'b' after a note means that it is one step lower than the note.

# Examples

    ['G'] -> 5 steps -> ['C']
    ['Db'] -> -4 steps -> ['A#']
    ['E', 'F'] -> 1 step -> ['F', 'F#']

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Starter code: def transpose(song, interval):
	

Solutions:
def transpose(song, interval):
	altern = {'Bb': 'A#', 'Db': 'C#', 'Eb': 'D#', 'Gb': 'F#', 'Ab': 'G#'}
	notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
	return [notes[(notes.index(altern.get(i, i)) + interval) % 12] for i in song]


table = 'A Bb B C Db D Eb E F Gb G Ab'.split()
table += 'A A# B C C# D D# E F F# G G#'.split() * 3

def transpose(song, interval):
	return [table[table.index(note) + interval % 12 + 12] for note in song]


SHARP = 'A, A#, B, C, C#, D, D#, E, F, F#, G, G#'.split(', ')
FLAT = 'A, Bb, B, C, Db, D, Eb, E, F, Gb, G, Ab'.split(', ')
REVERSED_INDEX = {**{note: i for (i, note) in enumerate(SHARP)}, **{note: i for (i, note) in enumerate(FLAT)}}

def transpose(song, interval):
	return [SHARP[(REVERSED_INDEX[note] + interval) % 12] for note in song]


def transpose(song, interval):
	sharp = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
	flat = ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab']
	return [sharp[(12 + (sharp.index(nt) if nt in sharp else flat.index(nt)) + interval) % 12] for nt in song]


def transpose(song, interval):
	notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab']
	return [notes[(12 + notes.index(n) + interval) % 12] for n in song]


transpose = lambda s, i: (lambda sharp, flat: [sharp[(flat.index(n) + i + 12) % 12] if n in flat else sharp[(sharp.index(n) + i + 12) % 12] for n in s])(['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'], ['A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab'])


d = {'Bb': 'A#', 'Db': 'C#', 'Eb': 'D#', 'Gb': 'F#', 'Ab': 'G#'}
q = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']

def transpose(a, n):
	return [q[(q.index(d.get(x, x)) + n) % len(q)] for x in a]