Skip to main content
Tweeted twitter.com/StackCodeGolf/status/1490248903723294720
Became Hot Network Question
edited tags
Link
alephalpha
  • 52k
  • 7
  • 75
  • 198
added 4 characters in body
Source Link
drmosley
  • 757
  • 3
  • 14

Write a program that can take a string representing anyany valid key signature (ex: C, D#, Ab) and return the appropriate chord progression for a 12 bar blues in that key.

Write a program that can take a string representing any valid key signature (ex: C, D#, Ab) and return the appropriate chord progression for a 12 bar blues in that key.

Write a program that can take a string representing any valid key signature (ex: C, D#, Ab) and return the appropriate chord progression for a 12 bar blues in that key.

added 1119 characters in body
Source Link
drmosley
  • 757
  • 3
  • 14

Python 3 - Sample Code, not Golfed

def twelve_bar_blues(k_input):

	chords = ['Ab', 'A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G']*2

	if k_input not in chords and k_input[1] == '#':
		k_index = chords.index(k_input[0]) + 1
		k = chords[k_index]
	else:
		k = k_input

	I_index = chords.index(k)
	I = chords[I_index]

	IV_index = I_index + 5
	IV = chords[IV_index]

	V_index = I_index + 7
	V = chords[V_index]

	return f'{I} {I} {I} {I} {IV} {IV} {I} {I} {V} {IV} {I} {I}'

Try it online!

Python 3 - Sample Code, not Golfed

def twelve_bar_blues(k_input):

	chords = ['Ab', 'A', 'Bb', 'B', 'C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G']*2

	if k_input not in chords and k_input[1] == '#':
		k_index = chords.index(k_input[0]) + 1
		k = chords[k_index]
	else:
		k = k_input

	I_index = chords.index(k)
	I = chords[I_index]

	IV_index = I_index + 5
	IV = chords[IV_index]

	V_index = I_index + 7
	V = chords[V_index]

	return f'{I} {I} {I} {I} {IV} {IV} {I} {I} {V} {IV} {I} {I}'

Try it online!

edited body
Source Link
drmosley
  • 757
  • 3
  • 14
Loading
Source Link
drmosley
  • 757
  • 3
  • 14
Loading