Skip to main content
added 504 characters in body
Source Link
Kevin Cruijssen
  • 136.9k
  • 14
  • 158
  • 399

05AB1E, 3535 31 bytes

A7£ÀÀSD¤«s.•4hθîÈÁhƒÏ‰Aȇ{V&8•#DIk•íƒò=Z•¦S+è馄fbKDIk•íƒò=Z•¦S+è

Try it onlineTry it online or verify all test casesverify all test cases.

.•4hθîÈÁhƒÏ‰Aȇ{V&8•
 A                 # Push compressedthe stringlowercase "calphabet
 db d eb e f gb g ab a bb b"
     # Only leave the first 7 letters: "abcdefg"
   ÀÀ             # SplitRotate it onright spacestwice: "cdefgab"
     S            # Convert it to a list of characters
  D    D           # Duplicate it
       ¤          # Push the last character (without popping): "b"
        «         # Append it to each in the copy:
                  #  ["cb","db","eb","fb","gb","ab","bb"]
         s.ι      # Swap, and interleave the lists:
                  #  ["cb","c","db","d","eb","e","fb","f","gb","g","ab","a","bb","b"]
            ¦     # Remove the first ("cb")
             „fbK # As well as the "fb"
                  #  ["c","db","d","eb","e","f","gb","g","ab","a","bb","b"]
D                 # Duplicate it
 Ik               # Get the index of the input in this list
   •íƒò=Z•  •íƒò=Z•      # Push compressed integer 1000055007500
          ¦  ¦     # Remove the leading 1: "000055007500"
           S  S    # Convert it to a list of digits
            +  +   # Add the earlier index to each
             è  è  # Use that to 0-based modular index into the list of notes
                  # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to compress strings not part of the dictionary? andsection How to compress large integers?) to understand why .•4hθîÈÁhƒÏ‰Aȇ{V&8• is "c db d eb e f gb g ab a bb b" and •íƒò=Z• is 1000055007500.

05AB1E, 35 bytes

.•4hθîÈÁhƒÏ‰Aȇ{V&8•#DIk•íƒò=Z•¦S+è

Try it online or verify all test cases.

.•4hθîÈÁhƒÏ‰Aȇ{V&8•
                  # Push compressed string "c db d eb e f gb g ab a bb b"
 #                # Split it on spaces to a list
  D               # Duplicate it
   Ik             # Get the index of the input in this list
     •íƒò=Z•      # Push compressed integer 1000055007500
            ¦     # Remove the leading 1: "000055007500"
             S    # Convert it to a list of digits
              +   # Add the earlier index to each
               è  # Use that to 0-based modular index into the list of notes
                  # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to compress strings not part of the dictionary? and How to compress large integers?) to understand why .•4hθîÈÁhƒÏ‰Aȇ{V&8• is "c db d eb e f gb g ab a bb b" and •íƒò=Z• is 1000055007500.

05AB1E, 35 31 bytes

A7£ÀÀSD¤«s.馄fbKDIk•íƒò=Z•¦S+è

Try it online or verify all test cases.

A                 # Push the lowercase alphabet
                # Only leave the first 7 letters: "abcdefg"
   ÀÀ             # Rotate it right twice: "cdefgab"
     S            # Convert it to a list of characters
      D           # Duplicate it
       ¤          # Push the last character (without popping): "b"
        «         # Append it to each in the copy:
                  #  ["cb","db","eb","fb","gb","ab","bb"]
         s.ι      # Swap, and interleave the lists:
                  #  ["cb","c","db","d","eb","e","fb","f","gb","g","ab","a","bb","b"]
            ¦     # Remove the first ("cb")
             „fbK # As well as the "fb"
                  #  ["c","db","d","eb","e","f","gb","g","ab","a","bb","b"]
D                 # Duplicate it
 Ik               # Get the index of the input in this list
   •íƒò=Z•        # Push compressed integer 1000055007500
          ¦       # Remove the leading 1: "000055007500"
           S      # Convert it to a list of digits
            +     # Add the earlier index to each
             è    # Use that to 0-based modular index into the list of notes
                  # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why •íƒò=Z• is 1000055007500.

Source Link
Kevin Cruijssen
  • 136.9k
  • 14
  • 158
  • 399

05AB1E, 35 bytes

.•4hθîÈÁhƒÏ‰Aȇ{V&8•#DIk•íƒò=Z•¦S+è

Port of @emanresuA's Vyxal answer. It also only uses lowercase inputs without sharps; and outputs (in lowercase) as single list.

Try it online or verify all test cases.

Explanation:

.•4hθîÈÁhƒÏ‰Aȇ{V&8•
                  # Push compressed string "c db d eb e f gb g ab a bb b"
 #                # Split it on spaces to a list
  D               # Duplicate it
   Ik             # Get the index of the input in this list
     •íƒò=Z•      # Push compressed integer 1000055007500
            ¦     # Remove the leading 1: "000055007500"
             S    # Convert it to a list of digits
              +   # Add the earlier index to each
               è  # Use that to 0-based modular index into the list of notes
                  # (after which the result is output implicitly)

See this 05AB1E tip of mine (sections How to compress strings not part of the dictionary? and How to compress large integers?) to understand why .•4hθîÈÁhƒÏ‰Aȇ{V&8• is "c db d eb e f gb g ab a bb b" and •íƒò=Z• is 1000055007500.