All puzzles › Music

Music Practice Problems

13 puzzles (6 easy, 6 medium, 1 hard), 3 free, in Python, JavaScript and C++.

Notes, scales, intervals and rhythm turned into code puzzles.

The puzzles, easiest first

  1. Spread the Beats Evenly (Easy, free): Place 3 drum hits as evenly as possible across 8 steps and you get the tresillo, the rhythm under a huge share of Latin and pop music.
  2. Interval in Semitones (Easy): Given two MIDI notes, return how many semitones apart they are.
  3. Lowest Note (Root) (Easy): Given the notes of a chord, return the lowest one.
  4. Total Beats (Easy): Given a list of note lengths in beats, return the total.
  5. Transpose a Melody (Easy): Given a list of MIDI note numbers and a shift n, return every note moved up by n.
  6. Transpose Down (Easy): Given a list of MIDI notes and a number of semitones, return every note lowered by that much.
  7. Find the Beat (Medium, free): A music app detects the tempo of a song from the moments when notes begin, called onsets.
  8. Name That Chord (Medium, free): Three notes played together form a triad, and its sound depends on the gaps between them.
  9. Count Accidentals (Medium): Given a list of MIDI notes, return how many land on black piano keys.
  10. In Key? (Medium): Given a scale as pitch classes (0 to 11) and a MIDI note, return true if the note is in the scale.
  11. Longest Rising Run (Medium): Given a melody as note numbers, return the most times in a row the melody goes up.
  12. Same Pitch Class (Medium): Given a list of MIDI notes and a target note, return how many notes are the same pitch as the target, in any octave.
  13. Build a Major Scale (Hard): Given a root note, return the seven notes of its major scale.

Practice another pattern

Or browse by subject

Browse all 676 puzzles