Please in order to save solutions and appear on the leaderboards.

Musical Chords


For each set of three musical notes forming a triad, print the name of the chord they form, consisting of the root note and the type of triad.

Each note is represented as an uppercase letter, optionally followed by a single accidental, either sharp ( U+266F) or flat ( U+266D).


There are twelve pitch classes in twelve-tone equal temperament, some of which have multiple names due to and raising and lowering the pitch, respectively. They are, in ascending order:

#Name 1Name 2

A triad consists of a root note on the bottom followed by two thirds stacked on top of it. Thirds describe the distance between the preceding and following note. A third can be either of two types:

Minor third3A C (note 0 to note 3)
Major third4C E (note 3 to note 7)

Being that there are 2 thirds in a triad and each third can be of 2 different types, there are 4 total “types” of triads. They are:

Triad NameThirds (Bottom to Top)Example
Diminished TriadMinor, MinorB D F
Minor TriadMinor, MajorE G B
Major TriadMajor, MinorC E G
Augmented TriadMajor, MajorD F♯ A♯


  • Triads of notes will always be written out so that the letters in the name used ascend by 2 between each third (wrapping back to A after G). Therefore, a triad consisting of notes 3, 6, and 9 may be written as B♯ D♯ F♯ or C E♭ G♭, but not, for example, as C D♯ F♯.
  • The notes may appear in any order, e.g., C E G and E C G both may appear.


  • Chords are named by the root note followed by nothing for major, m for minor, ° U+00B0 for diminished, and + for augmented.
  • The spelling of the root note in the output must match the input, e.g. the expected output for C E♭ G♭ is , not B♯°.
0 bytes, 0 chars
Compiled from AT&T syntax to x86-64 Linux. Use syscalls to write output. For accurate byte counts and syntax highlighting, please use the new editor.
Top-level programs are supported, args holds ARGV. Implicit using directives for console applications are enabled.
Arguments are available via STDIN, each argument is NULL terminated. Taking input after EOF leaves the cell unchanged, the tape is circular with 65536 cells, and cells are 8-bit with wrapping.
Arguments are available via STDIN, each argument is NULL terminated. x is a no-op.
Arguments are available via STDIN, each argument is NULL terminated.
arguments holds ARGV, print() to output with a newline, write() to output without a newline.
say() is available without any import.
$args to access the arguments.
prolog_flag(argv, Args) to access the arguments.
SELECT arg FROM argv to access the arguments, only the first column of the first result set will be printed, NULL values will be skipped, and the dialect is SQLite.
Arguments are available via args list variable. To terminate script execution, write and quit the current buffer.
ctrl + enter or Run