This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯.

All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of one. Sharp or flat notes that can be described with a single letter, like B♯ (C) or F♭ (E) should not be outputted.

Here is an example of the output:

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


  • The program or function must not take any input.

  • The notes may be printed in any order, and in any list output permitted by our standard I/O rules

  • The sharp and flat Unicode symbols (♯/♭) may be substituted with b and #

  • As always, Standard loopholes are forbidden.

  • As this is , the smallest program, in bytes, wins.

  • 3
    \$\begingroup\$ related \$\endgroup\$ – Jonathan Allan Aug 14 '19 at 22:32
  • 1
    \$\begingroup\$ May we output "C " instead of "C"? \$\endgroup\$ – Arnauld Aug 14 '19 at 22:55
  • 1
    \$\begingroup\$ @Arnauld yes you may \$\endgroup\$ – TheOnlyMrCat Aug 14 '19 at 23:04
  • 8
    \$\begingroup\$ By the way, B# exists in music notation; it's for example in the key signature for the key of C#, where it serves as the leading tone. \$\endgroup\$ – Kaz Aug 14 '19 at 23:39
  • 2
    \$\begingroup\$ I don't know, it feels like Cb is missing here ;) \$\endgroup\$ – AJFaraday Aug 15 '19 at 11:31

31 Answers 31


C, 57 bytes

Trivial version 57 bytes in C (gcc)

#include <stdio.h>


int main()

Try it Online!

| improve this answer | |
  • 2
    \$\begingroup\$ You can omit #include <stdio.h>, and the rules also allow you to define just a function that produces the output, you don't have to have a main(). So: f(){puts(...);} would be a valid code golf submission. Don't forget to include the actual code! \$\endgroup\$ – G. Sliepen Aug 17 '19 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.