29
\$\begingroup\$

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#

Specifications

  • 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.

\$\endgroup\$
7
  • 3
    \$\begingroup\$ related \$\endgroup\$ Aug 14, 2019 at 22:32
  • 1
    \$\begingroup\$ May we output "C " instead of "C"? \$\endgroup\$
    – Arnauld
    Aug 14, 2019 at 22:55
  • 1
    \$\begingroup\$ @Arnauld yes you may \$\endgroup\$ Aug 14, 2019 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, 2019 at 23:39
  • 2
    \$\begingroup\$ I don't know, it feels like Cb is missing here ;) \$\endgroup\$
    – AJFaraday
    Aug 15, 2019 at 11:31

32 Answers 32

13
\$\begingroup\$

Malbolge, 482 370 353 bytes

R1: Removed commas inbetween (as not required by the challenge)

R2: Shave off a few bytes

('<;_#!=6Z|{8xUwvt,PrqonKmk)"FhCUTdb?`+<;:[Z7YtVU2T|/g-O+i(gJrHc#EC~B{@zZxw:tt'r5Qo"!l/K-hUfe?bP``_Lo~[}|X2VCTR3Q+N`_^9+7Hji3ffdAc~w|u;]\wpon4VUSSQ.PONcb(JI^]#DCYX|@?>=<:u9NMRKo32MFj.C,Ae)>'<%:^"!~5:3WxwwuRts0q(Lnml)"Fhgfe"y?a`_zyxq7YXWlUj0RgfkjMb(JI^c\[Z~BAV?T=Rv987Mq44310FEi-,G@)>b&%#"8=6Z{{yyw/Sut1*)('Km$k(!Efe{zyx>`uz]r8ZXnm3TTih.PkNchg`&HFF[DY}Az

Try it online!

\$\endgroup\$
12
\$\begingroup\$

CP-1610 assembly (Intellivision), 31 DECLEs1 = 39 bytes

A routine taking an output pointer in R4 and writing the notes there, separated with spaces. In the example code, we write directly to the screen.

Hex dump (routine only)

275 001 2BD 03C 048 1DB 2B8 012 044 2A9 2BA 108 078 201 003 262
261 263 2FA 008 37A 140 225 00B 089 22C 011 2B7 018 210 000

Full source

                ROMW    10              ; use 10-bit ROM width
                ORG     $4800           ; map this program at $4800

                ;; ------------------------------------------------------------- ;;
                ;;  test code                                                    ;;
                ;; ------------------------------------------------------------- ;;
4800            SDBD                    ; set up an interrupt service routine
4801            MVII    #isr,     R0    ; to do some minimal STIC initialization
4804            MVO     R0,       $100
4806            SWAP    R0
4807            MVO     R0,       $101

4809            EIS                     ; enable interrupts

480A            MVII    #$200,    R4    ; R4 = backtab pointer
480C            CALL    notes           ; invoke our routine

480F            DECR    R7              ; loop forever

                ;; ------------------------------------------------------------- ;;
                ;;  ISR                                                          ;;
                ;; ------------------------------------------------------------- ;;
      isr       PROC

4810            MVO     R0,       $0020 ; enable display

4812            CLRR    R0
4813            MVO     R0,       $0030 ; no horizontal delay
4815            MVO     R0,       $0031 ; no vertical delay
4817            MVO     R0,       $0032 ; no border extension
4819            MVII    #$D,      R0
481B            MVO     R0,       $0028 ; light-blue background
481D            MVO     R0,       $002C ; light-blue border

481F            JR      R5              ; return from ISR

                ENDP

                ;; ------------------------------------------------------------- ;;
                ;;  routine                                                      ;;
                ;; ------------------------------------------------------------- ;;
      notes     PROC

4820            PSHR    R5              ; save return address

4821            SDBD                    ; R5 = pointer to @@chr
4822            MVII    #@@chr,   R5
4825            CLRR    R3              ; R3 = 0 (space)
4826            MVII    #$12,     R0    ; R0 = bitmask = $12
4828            SWAP    R0,       2     ; extend it to $1212

4829  @@loop    MVI@    R5,       R1    ; R1 = next symbol
482A            MVII    #('A'-32)*8, R2 ; R2 = 'A' character

482C  @@note    SARC    R0              ; right shift the bitmask
482D            BC      @@next          ; skip this note if the carry is set

482F            MVO@    R2,       R4    ; append the note
4830            MVO@    R1,       R4    ; append the symbol
4831            MVO@    R3,       R4    ; append a space

4832  @@next    ADDI    #8,       R2    ; advance to the next note
4834            CMPI    #('H'-32)*8, R2 ; is it now a 'H'?
4836            BLT     @@note          ; if not, process the inner loop

4838            TSTR    R1              ; was the symbol a space?
4839            BNEQ    @@loop          ; if not, process the outer loop

483B            PULR    R7              ; return

483C  @@chr     DECLE   ('#'-32)*8      ; '#'
483D            DECLE   ('b'-32)*8      ; 'b'
483E            DECLE   0               ; space

                ENDP

Output

output

screenshot from jzIntv


1. A CP-1610 opcode is encoded with a 10-bit value, known as a 'DECLE'. This routine is 31 DECLEs long, starting at $4820 and ending at $483E (included).

\$\endgroup\$
9
\$\begingroup\$

Python 3, 50 bytes

print(*map(''.join,zip(3*'ADGBCEF',7*' '+5*'#b')))

Try it online!

Python 2: 48 bytes

This code can be adjusted as to include B# and Cb, at the cost of no additional bytes. This can be achieved by replacing 5 with 6.


Additionally, it is (finally) shorter than just outputting the plain string:

Python 3, 51 bytes

exit('Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G#')

Try it online!

Python 2: 50 bytes

\$\endgroup\$
1
  • 2
    \$\begingroup\$ This is a very creative solution \$\endgroup\$ Aug 15, 2019 at 7:46
7
\$\begingroup\$

05AB1E, 16 15 13 bytes

Au…b #âŽ7×bûÏ

-2 bytes thanks to @maxb.

Try it online.

Outputs as a list, where the single-char notes are with a trailing space.

Explanation:

Au             # Push the lowercase alphabet, and uppercase it
  …b #         # Push string "b #"
      â        # Take the cartesian product of both strings to create all possible pairs:
               #  ["Ab","A ","A#","Bb","B ","B#",...,"Zb","Z ","Z#"]
       Ž7×     # Push compressed integer 1999
          b    # Convert it to a binary string "11111001111"
           û   # Palindromize it to "111110011111110011111"
            Ï  # Only leave the notes in the list at the truthy values (1), (the trailing
               # items beyond the length of this binary string are also discarded)
               # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž7× is 1999.

Ž7× could alternatively be ₄·< (1000, double, decrease by 1) for the same byte-count.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ Is the really necessary? Seems to run fine without it. \$\endgroup\$
    – maxb
    Aug 15, 2019 at 12:38
6
\$\begingroup\$

Perl 6, 41 bytes

{S:g/[E|B]\#...//}o{'A'..'G'X~'b #'.comb}

Try it online!

Simple cross product of the notes and the sharps/flats, followed by removing the extra invalid notes. This is an anonymous code block that produces the string:

Ab A  A# Bb B   C  C# Db D  D# Eb E   F  F# Gb G  G#
\$\endgroup\$
6
\$\begingroup\$

Jelly, 18?* 20 bytes

ØAḣ7µp⁾b#Żs6ḣ€4ẎḊ;W€

A monadic Link returning a list of lists of characters.

* If a mixed list of (a) lists of characters and (b) characters is acceptable remove the trailing W€ for 18.

Try it online!

How?

ØAḣ7µp⁾b#Żs6ḣ€4ẎḊ;W€ - Link: no argument
ØA                   - list of characters     [A-Z]
  ḣ7                 - head to 7              "ABCDEFG"
    µ                - new monadic link (call that X)
      ⁾b#            - list of characters     "b#"
     p               - Cartesian product      ["Ab","A#","Bb","B#","Cb","C#","Db","D#","Eb","E#","Fb","F#","Gb","G#"]
         Ż           - prepend a zero       [0,"Ab","A#","Bb","B#","Cb","C#","Db","D#","Eb","E#","Fb","F#","Gb","G#"]
          s6         - split into sixes    [[0,"Ab","A#","Bb","B#","Cb"],["C#","Db","D#","Eb","E#","Fb"],["F#","Gb","G#"]]
            ḣ€4      - head each to 4      [[0,"Ab","A#","Bb"],["C#","Db","D#","Eb"],["F#","Gb","G#"]]
               Ẏ     - tighten              [0,"Ab","A#","Bb","C#","Db","D#","Eb","F#","Gb","G#"]
                Ḋ    - dequeue                ["Ab","A#","Bb","C#","Db","D#","Eb","F#","Gb","G#"]
                  W€ - wrap each (of X)       ["A","B","C","D","E","F","G"]
                 ;   - concatenate            ["Ab","A#","Bb","C#","Db","D#","Eb","F#","Gb","G#","A","B","C","D","E","F","G"]
\$\endgroup\$
1
  • \$\begingroup\$ @mirabilos this is 20 bytes of source code, the Unicode characters each represent a byte of the source code - see the code page linked by the word bytes in the header. \$\endgroup\$ Aug 15, 2019 at 18:20
5
\$\begingroup\$

Retina 0.8.2, 33 bytes


ABCDEFG
.
 $&b $& $&#
 [BE]#...

Try it online! Explanation:


ABCDEFG

Insert the base note names.

.
 $&b $& $&#

Expand each note to include flat and sharp versions.

 [BE]#...

Delete B#, E# and also the notes following them (Cb and Eb).

\$\endgroup\$
4
\$\begingroup\$

R, 50 bytes

cat("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#")

Try it online!

Boring answer.

R, 60 bytes

cat(outer(LETTERS[1:7],c("#","","b"),paste0)[-c(2,5,17,20)])

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think the list of examples of redundant notes isn't meant to be exhaustive--the example output also omits Cb and E#. \$\endgroup\$ Aug 14, 2019 at 22:09
4
\$\begingroup\$

Charcoal, 21 bytes

Φ⪪⭆…α⁷⭆b #⁺ι벧↨⊖⊘φ²κ

Try it online! Link is to verbose version of code. Explanation:

    α                   Predefined variable uppercase alphabet
   … ⁷                  First 7 letters i.e. `ABCEDFG`
  ⭆                     Map over characters and join
       b #              Literal string `b #`
      ⭆                 Map over characters and join
          ⁺ιλ           Concatenate outer and inner characters
 ⪪           ²          Split back into substrings of length 2
Φ                       Filter where nonzero
                  φ     Predefined variable 1000
                 ⊘      Halved i.e. 500
                ⊖       Decremented i.e 499
               ↨   ²    Converted to base 2 i.e. [1, 1, 1, 1, 1, 0, 0, 1, 1]
              §     κ   Cyclically indexed by outer index
                        Implicitly print matching values on separate lines
\$\endgroup\$
3
\$\begingroup\$

Stax, 17 15 bytes

║♠+I▬┌ó£ΔφΔ`╗╨Å

Run and debug it

Bonus program: print the fancy symbols

\$\endgroup\$
3
\$\begingroup\$

Japt, 23 22 bytes

;B¯7
ï"b #" fÏÄ %9%8<6

Try it

;B          Alphabet
  ¯7        First seven characters ("ABCDEFG")
            Assign to U
ï"b #"       Cartesian product with "b #" ("Ab,A ,A#,Bb,B ,B#,Cb,C ,C#,Db,D ,D#,Eb,E ,E#,Fb,F ,F#,Gb,G ,G#")
f           Filter:
 ÏÄ           Is index + 1
   %9%8       Mod 9 Mod 8
     <6       Less than 6
            End filter ("Ab,A ,A#,Bb,B ,C ,C#,Db,D ,D#,Eb,E ,F ,F#,Gb,G ,G#")
\$\endgroup\$
2
  • \$\begingroup\$ Your code contains <6 but it's <5 in the explanation. \$\endgroup\$ Aug 16, 2019 at 21:11
  • \$\begingroup\$ @TheOnlyMrCat Edited \$\endgroup\$
    – Gymhgy
    Aug 16, 2019 at 22:35
2
\$\begingroup\$

dzaima/APL REPL, 38 28 25 bytes

(⊤2056111)⌿,' b#'∘.,⍨7↑⎕A

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ I think that you can remove the ⎕←. \$\endgroup\$ Aug 14, 2019 at 23:22
  • \$\begingroup\$ @EriktheOutgolfer hmm yeah, if I switch to REPL \$\endgroup\$
    – dzaima
    Aug 14, 2019 at 23:23
  • \$\begingroup\$ Oh right, I forgot to count the {} LOL. \$\endgroup\$ Aug 14, 2019 at 23:25
2
\$\begingroup\$

Ruby, 43 bytes

p (2..18).map{|i|"FCGDAEB"[i%7]+"b #"[i/7]}

Try it online!

With the range 0..20 this would print an array containing all the flats, all the naturals and all the sharps. The undesired ones Fb Cb E# B# are omitted by using the range 2..18

The notes are printed out ordered according to https://en.wikipedia.org/wiki/Circle_of_fifths , or in other words ascending by 7 semitones (a frequency ratio of almost exactly 1.5) each time.

This leads to the note letter order given, in which each note is five degrees inclusive (known as a "fifth") above the previous one. For example F->C is FGABC

\$\endgroup\$
1
  • \$\begingroup\$ I like that you ascend by fifths. Nice. \$\endgroup\$ Aug 17, 2019 at 1:18
2
\$\begingroup\$

brainfuck, 106 bytes

+++[[-<+>>++<]>]<<[-<->]++<<++<,+<-<[->+>+<<]<+[>>>>>+>-[<.<<<.>.[<]]>[>]<+[---<.<.<.[<]]>[>]<++<.<<.<<<-]

Try it online!

Outputs each note separated by carriage returns.

\$\endgroup\$
2
\$\begingroup\$

Zsh, 36 bytes

<<<${${(F):-{A..G}{b,,#}}//[BE]#???}

An uglier solution, but it saves two characters. (F) joins a list on newlines, and //[BE]#??? removes the parts of the string we need.

Try it online!


Zsh, 38 bytes

<<<${${:-{A..G}{b,,#}}:#([BE]#|[CF]b)}

I always enjoy it when Zsh beats Perl (hopefully I don't speak too soon...).

<<<${${:-{A..G}{b,,#}}:#([BE]#|[CF]b)}
     ${:-             }                 # empty-fallback, basically an anonymous parameter expansion
         {A..G}{b,,#}                   # Cross product range A-G with b,(nothing),#
   ${                 :#             }  # Remove matching elements
                        ([BE]#|[CF]b)   # B#, E#, Cb, Fb
<<<                                     # Print to stdout

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Lost, 105 bytes

v<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
>%?"Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G\9"-+@

Outputs with #b and space delimiter.

Try it online or verify that it's deterministic.

Explanation:

Explanation of the language in general:

Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that both the start position AND starting direction it travels in is completely random. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.

A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.

In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.

Explanation of the program:

All arrows, including the reflect \ in the string, will lead the path towards the leading > on the second line. From there the program flow is as follows:

  • >: travel in an east/right direction
  • %: Put the safety 'off'. In a Lost program, an @ will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character @ would immediately terminate without doing anything. The % will turn this safety 'off', so when we now encounter an @ the program will terminate (if the safety is still 'on', the @ will be a no-op instead).
  • ?: Clean the top value on the stack. In some program flows it's highly likely we have a partial string on the stack, so we use this to wipe the stack clean of that potential string.
  • ": Start a string, which means it will push the integer code-points of the characters used.
  • Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G\9: Push the code-points for these characters, being 65 98 32 65 32 65 35 32 66 98 32 66 32 67 32 67 35 32 68 98 32 68 32 68 35 32 69 98 32 69 32 70 32 70 35 32 71 98 32 71 32 71 92 57 respectively
  • ": We're done pushing code-points of this string
  • -+: Subtract the top two values from one another: (92-57=) 35
  • @: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly. Using the -A program argument flag, these code-points will be output as characters instead.

Minor note: The top part could also have been v<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< instead. Lost will wrap around to the other side when moving in a direction. So using v<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>> could be a slightly shorter path, and since it's the same byte-count anyway, why not use it. :)

\$\endgroup\$
1
\$\begingroup\$

Jelly, 21 bytes

ØAḣ7;p¥⁾b#“¿€×Ø‘œPẎẎ€

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Brachylog, 36 bytes

"#b"ẹ,Ẹ↺;Ṇh₇ᵗ↔{∋ᵐc}ᶠ⟨h₅ct₁₄⟩⟨h₁₂ct₅⟩

Try it online!

I'm currently in the process of brute-forcing the powerset index that would let me get rid of ⟨h₅ct₁₄⟩⟨h₁₂ct₅⟩ (and by extension , since the output doesn't need to be in the same order as the example output), but it's taking quite a while... maybe I should put a minute aside to actually work out what order sublists are generated in, and compute the index that way...

\$\endgroup\$
1
\$\begingroup\$

Canvas, 23 bytes

Z7m{#+¹¹b+]{“╷!↕„2┬²@?P

Try it here!

22 bytes with extra newlines in the output

\$\endgroup\$
1
\$\begingroup\$

PHP, 65 bytes

Makes the list with a loop. Items are separated by _ with a trailing separator.

for(;$l=ABCDEFG[$i++];)echo$l._.[$a="$l#_",$a.$b=$l.b_,$b][$i%3];

Try it online!


PHP, 43 bytes

PHP outputs anything as is, when not inside <?php and ?> tags.

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

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Pyth, 23 21 bytes

s<R7c.>*<r1G7"b #"2 9

Try it online!

s<R7c.>*<r1G7"b #"2 9   Implicit: G=lowercase alphabet
         r1G            Convert G to upper case
        <   7           First 7 characters
       *     "b #"      Cartesian product with "b #"
     .>           2     Rotate the above 2 places to the right
    c               9   Chop into pieces of length 9
 <R7                    Trim each to length 7
s                       Flatten, implicit print

Edit: Partial rewrite to save 2 bytes, previous version: s%2c*<r1G7"b #"xLG"fhoq Try it online!

\$\endgroup\$
1
\$\begingroup\$

Commodore C64/TheC64 Mini (probably other Commodore 8-bit BASIC variants) - 52 tokenized BASIC bytes

 0?"{CTRL+N}Ab A A# Bb B C C# Db D D# Eb E F F# Gb GG#

Pressing the CTRL key plus N on the C64 keyboard goes into 'business mode' on the character set for upper/lower case characters. We may print this out in a string in one byte / token; and as we have 40 columns, the space from G to G# is not required.

We do not need to close the string in this case as it is not a multi-statemented line with a : separator.

How this looks on a Commodore C64 (and compatibles) screen is shown below.

Commodore 64 musical notes

\$\endgroup\$
1
\$\begingroup\$

T-SQL, 124 bytes

SELECT value+a
FROM STRING_SPLIT('A-B-C-D-E-F-G','-')
    ,(VALUES('b'),(''),('#'))b(a)
WHERE value+a NOT IN ('B#','E#','Cb','Fb')

Line breaks are for display purposes only.

Longer but much more interesting than the trivial version (50 bytes):

PRINT'Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#'
\$\endgroup\$
1
\$\begingroup\$

Keg, 43 bytes

The string, compressed.

AbAA\#BbBCC\#DbDD\#EbEFF\#GbGG\#(:H<[ $]')'

TIO

\$\endgroup\$
0
\$\begingroup\$

APL (Dyalog Unicode), 45 bytes

2↓(,¨⎕A)⎕R', &'⊢'AbAA#BbBCC#DbDD#EbEFF#GbGG#'

Try it online!

Simple ⎕Replace operation, prepending , to each element in the string that matches each letter in the ⎕Alphabet, then dropping the first 2 characters, which are ,.

\$\endgroup\$
0
\$\begingroup\$

Brainfuck, 214 Bytes

>>>>++++++++[<++++<++++<++++++++++++<++++++++>>>>-]<<+++<++<+.>.>>.<<<.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<+.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<+.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<.>>.>.<<<+

Try it Online!

\$\endgroup\$
0
\$\begingroup\$

JavaScript (Node.js), 84 bytes

_=>[...'ABCDEFG'].map((n,i)=>`${i%3!=2?n+'b,':''}${n}${i%3!=1?`,${n}#`:''}`).join`,`

Try it online!

Just returning the string (as shown below) would be shorter by 36 bytes, but where's the fun in that?

_=>'Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#'
\$\endgroup\$
0
\$\begingroup\$

brainfuck, 255 115 bytes

--[----->+<]>-----[<+>>+>+<<-]>>+<<<-[->+++<]>+++[->>>+>+<
<<<]>>>>--->+++++++[-<<<<.>.>>.<<<.>>>.<<<.>>.>.<<<+>>>>]

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I would upvote this, but it's wrong. There's no black note between B and C, or between E and F. So you're not supposed to output. B#, Cb, E# or Fb. Also, I don't see anything in the spec about it being OK to use lowercase. \$\endgroup\$ Aug 15, 2019 at 22:29
  • \$\begingroup\$ @LevelRiverSt the challenge didn't state anywhere that we don't have notes between B and C & E and F \$\endgroup\$ Aug 16, 2019 at 8:12
  • \$\begingroup\$ 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. That seems fairly clear to me, and I'm seeing no edit history on the OP on my screen. \$\endgroup\$ Aug 16, 2019 at 19:53
0
\$\begingroup\$

Bash 5, 42 bytes

x=`echo {A..G}{b,,#}`;echo ${x//[BE]#???/}

Output:

Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G#
\$\endgroup\$
0
\$\begingroup\$

Perl 5, 47 41 bytes

say for'AbA#DbD#GbG#BbEbC#F#'=~/../g,A..G

Try it online!

\$\endgroup\$

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.