5 added 830 characters in body
source | link

** The challenge **

Given a set of notes (as a string, or a list, or any other reasonable input - but as letters and accidentals, not a numerical equivalent), the key those notes are in, and a target key; output the notes transposed into the new key. Some of the notes may not exist in the scale for the given key (e.g Eb in the key of C).

** Inputs **

The complete set of input notes for this challenge will use the English naming convention, and so are as follows:

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

where "b" represents a flattened note (down one semitone per b), and # represents a sharpened note (up one semitone per #). Any of theseTheoretically all notes can be changed withextended further flatswith more #s and sharps (e.g. C## means C, up two semitones; Bbb means B, down two semitones)bs; but for the purposes of this program that won't happen beyond what is already given.

** What is transposing? **

Transposing a song involves "moving" the song into a different key, by finding the equivalent note of the scale in that key.

We will assume Major scales for the purposes of this challenge (minor keys are just duplicates of the relative major anyway).

For completeness, the** Scales **

The scales for this challenge are officially as follows:

For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab, C##/D, F##/G, G##/A are enharmonically equivalent (i.e. interchangeable - although they're not, always);.

For scales with double-sharps, I will accept the enharmonic equivalents as an alternative implementation:

  • D#: D#, E#, G, G#, A#, B#, D, D#
  • G#: G#, A#, B#, C#, D#, E#, G, G#
  • A#: A#, B#, D, D#, E#, G, A, A#

but apart from incidentals (notes that aren'tfor all other notes in the scale), they must match. If the option that isnote isn't in the scale should, either can be used.

e.g. F in the key of C should transpose to F# in the key of C#, and not to Gb, because that option in the pair is explicitly in the scale; but D in the key of C# could transpose to either C# or Db in the key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be. (BONUS feel-good points*

  • F in the key of C should transpose to F# in the key of C#, and not to Gb, because that option in the pair is explicitly in the scale
  • but D in the key of C# could transpose to either C# or Db in the key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be.

BONUS feel-good points *: normally it's # if you're going up, and a b if you're going down - feel free to implement this if you want!)

For double-sharps (e.g F##) in all cases, It's OK if the program "resolves" these (e.g.to G in that case); even if they are in the scale; but again, some BONUS feel-good points*BONUS feel-good points * if you keep the double-sharps in.

  • Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score?

* Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score?

Given a set of notes (as a string, or a list, or any other reasonable input - but as letters and accidentals, not a numerical equivalent), the key those notes are in, and a target key; output the notes transposed into the new key. Some of the notes may not exist in the scale for the given key (e.g Eb in the key of C).

The complete set of input notes for this challenge will use the English naming convention, and so are as follows:

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

where "b" represents a flattened note (down one semitone), and # represents a sharpened note (up one semitone). Any of these notes can be changed with further flats and sharps (e.g. C## means C, up two semitones; Bbb means B, down two semitones).

Transposing a song involves "moving" the song into a different key.

We will assume Major scales for the purposes of this challenge (minor keys are just duplicates of the relative major anyway).

For completeness, the scales are officially as follows:

For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab are enharmonically equivalent (i.e. interchangeable - although they're not, always); but apart from incidentals (notes that aren't in the scale), the option that is in the scale should be used.

e.g. F in the key of C should transpose to F# in the key of C#, and not to Gb, because that option in the pair is explicitly in the scale; but D in the key of C# could transpose to either C# or Db in the key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be. (BONUS feel-good points*: normally it's # if you're going up, and a b if you're going down - feel free to implement this if you want!)

For double-sharps (e.g F##), It's OK if the program "resolves" these (e.g.to G in that case); but again, some BONUS feel-good points* if you keep the double-sharps in.

  • Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score?

** The challenge **

Given a set of notes (as a string, or a list, or any other reasonable input - but as letters and accidentals, not a numerical equivalent), the key those notes are in, and a target key; output the notes transposed into the new key. Some of the notes may not exist in the scale for the given key (e.g Eb in the key of C).

** Inputs **

The complete set of input notes for this challenge will use the English naming convention, and so are as follows:

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

where "b" represents a flattened note (down one semitone per b), and # represents a sharpened note (up one semitone per #). Theoretically all notes can be extended further with more #s and bs; but for the purposes of this program that won't happen beyond what is already given.

** What is transposing? **

Transposing a song involves "moving" the song into a different key, by finding the equivalent note of the scale in that key.

We will assume Major scales for the purposes of this challenge.

** Scales **

The scales for this challenge are officially as follows:

For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab, C##/D, F##/G, G##/A are enharmonically equivalent (i.e. interchangeable - although they're not, always).

For scales with double-sharps, I will accept the enharmonic equivalents as an alternative implementation:

  • D#: D#, E#, G, G#, A#, B#, D, D#
  • G#: G#, A#, B#, C#, D#, E#, G, G#
  • A#: A#, B#, D, D#, E#, G, A, A#

but for all other notes in the scale, they must match. If the note isn't in the scale, either can be used.

e.g.

  • F in the key of C should transpose to F# in the key of C#, and not to Gb, because that option in the pair is explicitly in the scale
  • but D in the key of C# could transpose to either C# or Db in the key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be.

BONUS feel-good points *: normally it's # if you're going up, and a b if you're going down - feel free to implement this if you want!

For double-sharps (e.g F##) in all cases, It's OK if the program "resolves" these (e.g.to G in that case) even if they are in the scale; but again, some BONUS feel-good points * if you keep the double-sharps in.

* Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score?

4 added 830 characters in body
source | link

Given a set of notes (as a string, or a list, or any other reasonable input - but as letters and accidentals, not a numerical equivalent), the key those notes are in, and a target key; output the notes transposed into the new key. Some of the notes may not exist in the scale for the given key (e.g Eb in the key of C).

For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab are equivalent; although it does make sense to use the correct notation for the key signature.

Transposing a song involves "moving" the song into a different key.

Any noteFor simplicity, we can assume that is not a part ofboth notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab are enharmonically equivalent (i.e. interchangeable - although they're not, always); but apart from incidentals (notes that aren't in the scale is an "accidental"), andthe option that is in the scale should also be transposed correctlyused.

I have no problem with a program that represents thee.g. F##F in the key of AC as ashould transpose to GF# insteadin the key of C#, for exampleand not to -Gb, because that option in the abovepair is only whatexplicitly in the notes officially are for each scale; as you then have only onebut D in the key of each note letterC# could transpose to either C# or Db in each scalethe key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be. (BONUS feel-good points*: normally it's # if you're going up, and a b if you're going down - feel free to implement this if you want!)

For double-sharps (e.g F##), It's OK if the program "resolves" these (e.g.to G in that case); but again, some BONUS feel-good points* if you keep the double-sharps in.

  • CDEFGABC in C to A -> ABC#DEF#G#A
  • C# in C to A -> A# OR Bb
  • ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb
  • CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#
  • Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score?

Given a set of notes (as a string, or a list, or any other reasonable input), the key those notes are in, and a target key; output the notes transposed into the new key.

For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab are equivalent; although it does make sense to use the correct notation for the key signature.

Transposing a song involves "moving" the song into a different key.

Any note that is not a part of the scale is an "accidental", and should also be transposed correctly.

I have no problem with a program that represents the F## in the key of A as a G instead, for example - the above is only what the notes officially are for each scale; as you then have only one of each note letter in each scale.

  • CDEFGABC in C to A -> ABC#DEF#G#A
  • C# in C to A -> A#
  • ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb
  • CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#

Given a set of notes (as a string, or a list, or any other reasonable input - but as letters and accidentals, not a numerical equivalent), the key those notes are in, and a target key; output the notes transposed into the new key. Some of the notes may not exist in the scale for the given key (e.g Eb in the key of C).

Transposing a song involves "moving" the song into a different key.

For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab are enharmonically equivalent (i.e. interchangeable - although they're not, always); but apart from incidentals (notes that aren't in the scale), the option that is in the scale should be used.

e.g. F in the key of C should transpose to F# in the key of C#, and not to Gb, because that option in the pair is explicitly in the scale; but D in the key of C# could transpose to either C# or Db in the key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be. (BONUS feel-good points*: normally it's # if you're going up, and a b if you're going down - feel free to implement this if you want!)

For double-sharps (e.g F##), It's OK if the program "resolves" these (e.g.to G in that case); but again, some BONUS feel-good points* if you keep the double-sharps in.

  • CDEFGABC in C to A -> ABC#DEF#G#A
  • C# in C to A -> A# OR Bb
  • ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb
  • CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#
  • Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score?
3 added 12 characters in body
source | link

CDEFGABC in C to A -> ABC#DEF#G#A C# in C to A -> A# ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#

  • CDEFGABC in C to A -> ABC#DEF#G#A
  • C# in C to A -> A#
  • ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb
  • CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#

CDEFGABC in C to A -> ABC#DEF#G#A C# in C to A -> A# ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#

  • CDEFGABC in C to A -> ABC#DEF#G#A
  • C# in C to A -> A#
  • ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb
  • CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A#
2 added 691 characters in body
source | link
1
source | link