Skip to main content
Clarified and fixed mistakes in explanation
Source Link
Alex
  • 535
  • 1
  • 5
  • 14

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
O        ƒ        Reduceord() the input list with:(vectorizes)
O  H               Divide by 2 ord(vectorizes)
 H      +             Divide by 2Add...
  +  53            ...53 (all these steps Add...vectorize)
   53     ƒ        Reduce the input ...53list with:
       @             The preceding dyadic link, with its arguments swapped:
     œ?                  The nth permutation of the right argument
                 ...using the following as the starting value for the reduce:
         5           5 (which gets implicitly converted to [1,2,3,4,5] by œ?)
          F      Flatten (implicitly wraps 5 into [5] in case the input list is empty)
            Ƒ    Check if the output of the previous link is equal to its left argument:
           Ṣ         Sort the output list
(The last two bytes effectively check if the list is already in sorted order.)

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
        ƒ        Reduce the input list with:
O                    ord()
 H                   Divide by 2
  +                  Add...
   53                ...53
       @             The preceding dyadic link, with its arguments swapped:
     œ?                  The nth permutation of the right argument
                 ...using the following as the starting value for the reduce:
         5           5
          F      Flatten (implicitly wraps 5 into [5])
            Ƒ    Check if the output of the previous link is equal to its left argument:
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
O                ord() the input list (vectorizes)
 H               Divide by 2 (vectorizes)
  +              Add...
   53            ...53 (all these steps vectorize)
        ƒ        Reduce the input list with:
       @             The preceding dyadic link, with its arguments swapped:
     œ?                  The nth permutation of the right argument
                 ...using the following as the starting value for the reduce:
         5           5 (which gets implicitly converted to [1,2,3,4,5] by œ?)
          F      Flatten (wraps 5 into [5] in case the input list is empty)
            Ƒ    Check if the output of the previous link is equal to its left argument:
           Ṣ         Sort the output list
(The last two bytes effectively check if the list is already in sorted order.)

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Fixed mistake in explanation
Source Link
Alex
  • 535
  • 1
  • 5
  • 14

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
            Ƒ    Check if the output of the previous link is equal to its left argument:
        ƒ            Reduce the input list with:
O                        ord()
 H                       Divide by 2
  +                      Add...
   53                    ...53
       @                 The preceding dyadic link, with its arguments swapped:
     œ?                      The nth permutation of the right argument
                     ...using the following as the starting value for the reduce:
         5               5
          F          Flatten (implicitly wraps 5 into [5])
            Ƒ    Check if the output of the previous link is equal to its left argument:
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
            Ƒ    Check if the output of the previous link is equal to its left argument:
        ƒ            Reduce the input list with:
O                        ord()
 H                       Divide by 2
  +                      Add...
   53                    ...53
       @                 The preceding dyadic link, with its arguments swapped:
     œ?                      The nth permutation of the right argument
                     ...using the following as the starting value for the reduce:
         5               5
          F          Flatten (implicitly wraps 5 into [5])
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
        ƒ        Reduce the input list with:
O                    ord()
 H                   Divide by 2
  +                  Add...
   53                ...53
       @             The preceding dyadic link, with its arguments swapped:
     œ?                  The nth permutation of the right argument
                 ...using the following as the starting value for the reduce:
         5           5
          F      Flatten (implicitly wraps 5 into [5])
            Ƒ    Check if the output of the previous link is equal to its left argument:
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Fixed mistake in explanation
Source Link
Alex
  • 535
  • 1
  • 5
  • 14

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
            Ƒ    Check if the output of the previous link is equal to its left argument:
        ƒ            Reduce the input list with:
O                        ord()
 H                       Divide by 2
  +                      Add...
   53                    ...53
       @                 The preceding dyadic link, with its arguments swapped:
     œ?                      The nth permutation of the right argument
                     ...using the following as the starting value for the reduce:
         5               5
          F              Flatten (implicitly wraps 5 into [5])
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
            Ƒ    Check if the output of the previous link is equal to its left argument:
        ƒ            Reduce the input list with:
O                        ord()
 H                       Divide by 2
  +                      Add...
   53                    ...53
       @                 The preceding dyadic link, with its arguments swapped:
     œ?                      The nth permutation of the right argument
                     ...using the following as the starting value for the reduce:
         5               5
          F              Flatten (implicitly wraps 5 into [5])
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Jelly, 15 13 bytes (thanks @Jonathan Allan!)

OH+53œ?@ƒ5FṢƑ

Try it online!

OH+53œ?@ƒ5FṢƑ
            Ƒ    Check if the output of the previous link is equal to its left argument:
        ƒ            Reduce the input list with:
O                        ord()
 H                       Divide by 2
  +                      Add...
   53                    ...53
       @                 The preceding dyadic link, with its arguments swapped:
     œ?                      The nth permutation of the right argument
                     ...using the following as the starting value for the reduce:
         5               5
          F          Flatten (implicitly wraps 5 into [5])
           Ṣ         Sort the output list

Uses essentially the same logic as @xnor's answer. The two permutations I used were 45231 and 45123, since their indices (94 and 91, respectively) can be easily computed from the ord values of 'R' and 'L' (82 and 76, respectively): divide by 2 and add 53. I wrote a Python script to check all valid pairs of permutations to find the optimal ones (in terms of how many bytes are needed to calculate their indices from 82 and 76), and no other permutations were better than these.

Added Jonathan Allan's improvement
Source Link
Alex
  • 535
  • 1
  • 5
  • 14
Loading
Fixed mismatch between code and explanation
Source Link
Alex
  • 535
  • 1
  • 5
  • 14
Loading
Source Link
Alex
  • 535
  • 1
  • 5
  • 14
Loading