Skip to main content
deleted 8 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly,  31 30  3029 bytes

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$ÞFµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;=”#Ḥ’ƊSµ$Þ

Try it online!Try it online!

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$ÞFµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;=”#Ḥ’ƊSµ$Þ - Link: notes
                            $Þ - sort by: last two links as a monad:
 µ                             -   monadic chain:
F                              -     flatten (this is to get a copy so we don't
                                              alter what we are sorting in place)
                           µ   -   monadic chain:
  Ḣ                            -     head of note (removes it too)
          ḥ                    -     hash with salt & domain:
   “¤ı¶“Œ’                     -       base 250 numbers = [256628,20]
                                         X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ             -     last four links as a monad:
            Ṫ                  -       tail of note (removes it too)
             V                 -       evaluate as Jelly code -> integer
               12              -       twelve
              ×                -       multiply
                                         Y = 12 × octave
           ;                   -     concatenate -> [X,Y]
                        Ɗ€Ɗ     -     for eachlast (ie.three vlinks inas [],a ['#'],monad or- ['b']f(v):
                      i        -       first index  (orv 0)being one of v[], in:
['#'], or ['b'])
                 ⁾a#  =”#        -       equals '#'? ['a',(vectorises)
 '#']                     Ḥ       -       double       -       decrement
                                         O = accidental offsets [], [1], or [-1]
                  ;            -     concatenate -> [X,Y]+O
                          S    -     sum -> note number

Jelly,  31  30 bytes

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ

Try it online!

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                            $Þ - sort by: last two links as a monad:
 µ                             -   monadic chain:
F                              -     flatten (this is to get a copy so we don't
                                              alter what we are sorting in place)
                           µ   -   monadic chain:
  Ḣ                            -     head of note (removes it too)
          ḥ                    -     hash with salt & domain:
   “¤ı¶“Œ’                     -       base 250 numbers = [256628,20]
                                         X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ             -     last four links as a monad:
            Ṫ                  -       tail of note (removes it too)
             V                 -       evaluate as Jelly code -> integer
               12              -       twelve
              ×                -       multiply
                                         Y = 12 × octave
           ;                   -     concatenate -> [X,Y]
                        Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                      i        -       first index (or 0) of v in:
                   ⁾a#         -         ['a', '#']       -       decrement
                                         O = accidental offsets [], [1], or [-1]
                  ;            -     concatenate -> [X,Y]+O
                          S    -     sum -> note number

Jelly,  31 30  29 bytes

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;=”#Ḥ’ƊSµ$Þ

Try it online!

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;=”#Ḥ’ƊSµ$Þ - Link: notes
                           $Þ - sort by: last two links as a monad:
 µ                            -   monadic chain:
F                             -     flatten (this is to get a copy so we don't
                                             alter what we are sorting in place)
                          µ   -   monadic chain:
  Ḣ                           -     head of note (removes it too)
          ḥ                   -     hash with salt & domain:
   “¤ı¶“Œ’                    -       base 250 numbers = [256628,20]
                                        X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ            -     last four links as a monad:
            Ṫ                 -       tail of note (removes it too)
             V                -       evaluate as Jelly code -> integer
               12             -       twelve
              ×               -       multiply
                                        Y = 12 × octave
           ;                  -     concatenate -> [X,Y]
                        Ɗ     -     last three links as a monad - f(v):
                                        (v being one of [], ['#'], or ['b'])
                   =”#        -       equals '#'? (vectorises)
                      Ḥ       -       double
                       ’      -       decrement
                                        O = accidental offsets [], [1], or [-1]
                  ;           -     concatenate -> [X,Y]+O
                         S    -     sum -> note number
deleted 8 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282
FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                            $Þ - sort by: last two links as a monad:
 µ                             -   monadic chain:
F                              -     flatten (this is to get a copy so we don't
                                              alter what we are sorting in place)
                           µ   -   monadic chain:
  Ḣ                            -     head of note (removes it too)
          ḥ                    -     hash with salt & domain:
   “¤ı¶“Œ’                     -       base 250 numbers = [256628,20]
                                         X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ             -     last four links as a monad:
            Ṫ                  -       tail of note (removes it too)
             V                 -       evaluate as Jelly code -> integer
               12              -       twelve
              ×                -       multiply
                                         Y = 12 × octave
           ;                   -     concatenate -> [X,Y]
                        Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                      i        -       first index (or 0) of v in:
                   ⁾a#         -         ['a', '#']
                       ’       -       decrement
                                         O = accidental offsets [], [1], or [-1]
                  ;            -     concatenate -> [X,Y,O]Y]+O
                          S    -     sum -> X+Y+O = note number
FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                            $Þ - sort by: last two links as a monad:
 µ                             -   monadic chain:
F                              -     flatten (this is to get a copy so we don't
                                              alter what we are sorting in place)
                           µ   -   monadic chain:
  Ḣ                            -     head of note (removes it too)
          ḥ                    -     hash with salt & domain:
   “¤ı¶“Œ’                     -       base 250 numbers = [256628,20]
                                         X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ             -     last four links as a monad:
            Ṫ                  -       tail of note (removes it too)
             V                 -       evaluate as Jelly code -> integer
               12              -       twelve
              ×                -       multiply
                                         Y = 12 × octave
           ;                   -     concatenate -> [X,Y]
                        Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                      i        -       first index (or 0) of v in:
                   ⁾a#         -         ['a', '#']
                       ’       -       decrement
                                         O = accidental offsets [], [1], or [-1]
                  ;            -     concatenate -> [X,Y,O]
                          S    -     sum -> X+Y+O = note number
FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                            $Þ - sort by: last two links as a monad:
 µ                             -   monadic chain:
F                              -     flatten (this is to get a copy so we don't
                                              alter what we are sorting in place)
                           µ   -   monadic chain:
  Ḣ                            -     head of note (removes it too)
          ḥ                    -     hash with salt & domain:
   “¤ı¶“Œ’                     -       base 250 numbers = [256628,20]
                                         X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ             -     last four links as a monad:
            Ṫ                  -       tail of note (removes it too)
             V                 -       evaluate as Jelly code -> integer
               12              -       twelve
              ×                -       multiply
                                         Y = 12 × octave
           ;                   -     concatenate -> [X,Y]
                        Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                      i        -       first index (or 0) of v in:
                   ⁾a#         -         ['a', '#']
                       ’       -       decrement
                                         O = accidental offsets [], [1], or [-1]
                  ;            -     concatenate -> [X,Y]+O
                          S    -     sum -> note number
deleted 6 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282

Jelly, 31  31  30 bytes

FµḢ“£ȷẠo“¿’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$ÞFµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ

Try it online!Try it online!

FµḢ“£ȷẠo“¿’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$ÞFµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                             $Þ - sort by: last two links as a monad:
 µ                              -   monadic chain:
F                               -     flatten (this is to get a copy so we don't
                                               alter what we are sorting in place)
                            µ   -   monadic chain:
  Ḣ                             -     head of note (removes it too)
           ḥ                    -     hash with salt & domain:
   “£ȷẠo“¿’“¤ı¶“Œ’                     -       base 250 numbers = [48605612[256628,12]20]
                                          X = CDEFGAB -> 1,3,54,6,8,109,1211,13,15
                  Ʋ             -     last four links as a monad:
             Ṫ                  -       tail of note (removes it too)
              V                 -       evaluate as Jelly code -> integer
                12              -       twelve
               ×                -       multiply
                                          Y = 12 × octave
            ;                   -     concatenate -> [X,Y]
                         Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                       i        -       first index (or 0) of v in:
                    ⁾a#         -         ['a', '#']
                        ’       -       decrement
                                          O = accidental offsets [], [1], or [-1]
                   ;            -     concatenate -> [X,Y,O]
                           S    -     sum -> X+Y+O = note number

Jelly, 31 bytes

FµḢ“£ȷẠo“¿’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ

Try it online!

FµḢ“£ȷẠo“¿’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                             $Þ - sort by: last two links as a monad:
 µ                              -   monadic chain:
F                               -     flatten (this is to get a copy so we don't
                                               alter what we are sorting in place)
                            µ   -   monadic chain:
  Ḣ                             -     head of note (removes it too)
           ḥ                    -     hash with salt & domain:
   “£ȷẠo“¿’                     -       base 250 numbers = [48605612,12]
                                          X = CDEFGAB -> 1,3,5,6,8,10,12
                  Ʋ             -     last four links as a monad:
             Ṫ                  -       tail of note (removes it too)
              V                 -       evaluate as Jelly code -> integer
                12              -       twelve
               ×                -       multiply
                                          Y = 12 × octave
            ;                   -     concatenate -> [X,Y]
                         Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                       i        -       first index (or 0) of v in:
                    ⁾a#         -         ['a', '#']
                        ’       -       decrement
                                          O = accidental offsets [], [1], or [-1]
                   ;            -     concatenate -> [X,Y,O]
                           S    -     sum -> X+Y+O = note number

Jelly,  31  30 bytes

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ

Try it online!

FµḢ“¤ı¶“Œ’ḥ;ṪV×12Ʋ;⁾a#i’Ɗ€Sµ$Þ - Link: notes
                            $Þ - sort by: last two links as a monad:
 µ                             -   monadic chain:
F                              -     flatten (this is to get a copy so we don't
                                              alter what we are sorting in place)
                           µ   -   monadic chain:
  Ḣ                            -     head of note (removes it too)
          ḥ                    -     hash with salt & domain:
   “¤ı¶“Œ’                     -       base 250 numbers = [256628,20]
                                         X = CDEFGAB -> 4,6,8,9,11,13,15
                 Ʋ             -     last four links as a monad:
            Ṫ                  -       tail of note (removes it too)
             V                 -       evaluate as Jelly code -> integer
               12              -       twelve
              ×                -       multiply
                                         Y = 12 × octave
           ;                   -     concatenate -> [X,Y]
                        Ɗ€     -     for each (ie. v in [], ['#'], or ['b']):
                      i        -       first index (or 0) of v in:
                   ⁾a#         -         ['a', '#']
                       ’       -       decrement
                                         O = accidental offsets [], [1], or [-1]
                  ;            -     concatenate -> [X,Y,O]
                          S    -     sum -> X+Y+O = note number
added 1676 characters in body
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282
Loading
Source Link
Jonathan Allan
  • 110.1k
  • 7
  • 65
  • 282
Loading