Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Golfed 2 bytes
Source Link
Sok
  • 6.2k
  • 1
  • 19
  • 30

Pyth, 23(削除) 23 (削除ここまで) 21 bytes

s%2c*<r1G7"bs<R7c.>*<r1G7"b #"xLG"fhoq#"2 9

Try it online! Try it online!

s%2c*<r1G7"bs<R7c.>*<r1G7"b #"xLG"fhoq"#"2 9 Implicit: G=lowercase alphabet
 Trailing " inferred
 r1G Convert G to Upperupper case alphabet
 < 7 < 7 First 7 characters
 *  "b #"* "b #" Cartesian product of the above with "b #"
 This yields all note names, including the redundant ones
 L "fhoq" For each character in "fhoq"...> x G 2 Rotate ...the findabove its2 indexplaces into the alphabetright
 This yields [5, 7, 14, 16]
 c 9 Split theChop fullinto listpieces of notes at theselength indexes9
 %2  <R7 Take every other sublist, i.e.Trim dropeach theto redundantlength notes7
s Flatten back into single list, implicit print

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

Pyth, 23 bytes

s%2c*<r1G7"b #"xLG"fhoq

Try it online!

s%2c*<r1G7"b #"xLG"fhoq" Implicit: G=lowercase alphabet
 Trailing " inferred
 r1G Upper case alphabet
 < 7 First 7 characters
 *  "b #" Cartesian product of the above with "b #"
 This yields all note names, including the redundant ones
 L "fhoq" For each character in "fhoq"... x G ... find its index in the alphabet
 This yields [5, 7, 14, 16]
 c Split the full list of notes at these indexes
 %2  Take every other sublist, i.e. drop the redundant notes
s Flatten back into single list, implicit print

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"fhoqTry it online!

Added explanation
Source Link
Sok
  • 6.2k
  • 1
  • 19
  • 30

Pyth, 23 bytes

s%2c*<r1G7"b #"xLG"fhoq

Try it online!

s%2c*<r1G7"b #"xLG"fhoq" Implicit: G=lowercase alphabet
 Trailing " inferred
 r1G Upper case alphabet
 < 7 First 7 characters
 * "b #" Cartesian product of the above with "b #"
 This yields all note names, including the redundant ones
 L "fhoq" For each character in "fhoq"...
 x G ... find its index in the alphabet
 This yields [5, 7, 14, 16]
 c Split the full list of notes at these indexes
 %2 Take every other sublist, i.e. drop the redundant notes
s Flatten back into single list, implicit print

Pyth, 23 bytes

s%2c*<r1G7"b #"xLG"fhoq

Try it online!

Pyth, 23 bytes

s%2c*<r1G7"b #"xLG"fhoq

Try it online!

s%2c*<r1G7"b #"xLG"fhoq" Implicit: G=lowercase alphabet
 Trailing " inferred
 r1G Upper case alphabet
 < 7 First 7 characters
 * "b #" Cartesian product of the above with "b #"
 This yields all note names, including the redundant ones
 L "fhoq" For each character in "fhoq"...
 x G ... find its index in the alphabet
 This yields [5, 7, 14, 16]
 c Split the full list of notes at these indexes
 %2 Take every other sublist, i.e. drop the redundant notes
s Flatten back into single list, implicit print
Source Link
Sok
  • 6.2k
  • 1
  • 19
  • 30

Pyth, 23 bytes

s%2c*<r1G7"b #"xLG"fhoq

Try it online!

AltStyle によって変換されたページ (->オリジナル) /