Skip to main content
deleted 47 characters in body
Source Link
algorithmshark
  • 9k
  • 3
  • 35
  • 58

J - 82 char

Self-contained, reads from console input. If you need stdin, change the final 1 to a 3. Claiming no bonuses, and only covering the triads.

+/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1

Instead of # you must use h, and instead of a flatsharp note e.g. DbC# you must use the equivalent sharp noteflat name ChDb. (Correcting either peculiarityfor this would inflate the code by more than a bit.) The four types of chords are 0 for diminishing, m for minor, M for major, and + for augmented.

The logic is as follows: we use the last character to add an offset to the base 0-3-6, which selects the kind of third and fifth. Meanwhile, we use the note to find where in the scale to pull the notes from. The ;: both makes the note compatible with indexing into the scale at the start, and later (by &.) turns the pulled notes into a space separated string.

Example usage:

   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
AM
A Ch E
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
Gh0Ab0
GhAb B D
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
B+
B DhEb G
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
Em
E G B

J - 82 char

Self-contained, reads from console input. If you need stdin, change the final 1 to a 3. Claiming no bonuses, and only covering the triads.

+/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1

Instead of # you must use h, and instead of a flat note e.g. Db you must use the equivalent sharp note Ch. (Correcting either peculiarity would inflate the code by more than a bit.) The four types of chords are 0 for diminishing, m for minor, M for major, and + for augmented.

The logic is as follows: we use the last character to add an offset to the base 0-3-6, which selects the kind of third and fifth. Meanwhile, we use the note to find where in the scale to pull the notes from. The ;: both makes the note compatible with indexing into the scale at the start, and later (by &.) turns the pulled notes into a space separated string.

Example usage:

   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
AM
A Ch E
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
Gh0
Gh B D
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
B+
B Dh G
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
Em
E G B

J - 82 char

Self-contained, reads from console input. If you need stdin, change the final 1 to a 3. Claiming no bonuses, and only covering the triads.

+/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1

Instead of a sharp note e.g. C# you must use the equivalent flat name Db. (Correcting for this would inflate the code by more than a bit.) The four types of chords are 0 for diminishing, m for minor, M for major, and + for augmented.

The logic is as follows: we use the last character to add an offset to the base 0-3-6, which selects the kind of third and fifth. Meanwhile, we use the note to find where in the scale to pull the notes from. The ;: both makes the note compatible with indexing into the scale at the start, and later (by &.) turns the pulled notes into a space separated string.

Example usage:

   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
AM
A Ch E
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
Ab0
Ab B D
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
B+
B Eb G
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Db`D`Eb`E`F`Gb`G`Ab`A`Bb`B)i.;:)}:e=.1!:1]1
Em
E G B
Source Link
algorithmshark
  • 9k
  • 3
  • 35
  • 58

J - 82 char

Self-contained, reads from console input. If you need stdin, change the final 1 to a 3. Claiming no bonuses, and only covering the triads.

+/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1

Instead of # you must use h, and instead of a flat note e.g. Db you must use the equivalent sharp note Ch. (Correcting either peculiarity would inflate the code by more than a bit.) The four types of chords are 0 for diminishing, m for minor, M for major, and + for augmented.

The logic is as follows: we use the last character to add an offset to the base 0-3-6, which selects the kind of third and fifth. Meanwhile, we use the note to find where in the scale to pull the notes from. The ;: both makes the note compatible with indexing into the scale at the start, and later (by &.) turns the pulled notes into a space separated string.

Example usage:

   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
AM
A Ch E
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
Gh0
Gh B D
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
B+
B Dh G
   +/&(0 3 6++/\_3{.#:'0mM+'i.{:e)&.((,~C`Ch`D`Dh`E`F`Fh`G`Gh`A`Ah`B)i.;:)}:e=.1!:1]1
Em
E G B