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

added 162 characters in body
Source Link
FrownyFrog
  • 3.8k
  • 1
  • 15
  • 20

J, (削除) 20 19 (削除ここまで) 11 bytes

Credit to @Bolce Bussiere

1&A.&.>&.;:

Try it online!

 &.;: on words
 &.> on each
 A. apply the permutation
1& number 1, swap the last two elements

J, (削除) 20 19 (削除ここまで) 11 bytes

Credit to @Bolce Bussiere

1&A.&.>&.;:

Try it online!

J, (削除) 20 19 (削除ここまで) 11 bytes

Credit to @Bolce Bussiere

1&A.&.>&.;:

Try it online!

 &.;: on words
 &.> on each
 A. apply the permutation
1& number 1, swap the last two elements
deleted 535 characters in body
Source Link
FrownyFrog
  • 3.8k
  • 1
  • 15
  • 20

J, (削除) 20 19 (削除ここまで) 1911 bytes

[:;<@A.~&2;.2@,&' '

Try it online!

###How it worksCredit to @Bolce Bussiere

 ;1&A.2@,&' ' Split on spaces and add a space to each string
 <@A&.~&2 For each string swap the third and second to last letters
[:>&.; Unbox:

I wonder if it’s shorter to simply calculate the permutation for the entire input.Try it online!

J, (削除) 20 (削除ここまで) 19 bytes

[:;<@A.~&2;.2@,&' '

Try it online!

###How it works

 ;.2@,&' ' Split on spaces and add a space to each string
 <@A.~&2 For each string swap the third and second to last letters
[:; Unbox

I wonder if it’s shorter to simply calculate the permutation for the entire input.

J, (削除) 20 19 (削除ここまで) 11 bytes

Credit to @Bolce Bussiere

1&A.&.>&.;:

Try it online!

added 158 characters in body
Source Link
FrownyFrog
  • 3.8k
  • 1
  • 15
  • 20

J, 20(削除) 20 (削除ここまで) 19 bytes

1&A[:;<@A.&~&2;.>@cut;@2@,.<@'&' '

Try it online! Try it online!

###How it works

 cut  ;.2@,&' ' Split on spaces
 &.>@  and add a space Forto each string
1&A.  Swap<@A.~&2 the last two letters
 For each string <@'swap 'the third and second Ato singlelast spaceletters
[:; ;@,. Append to each and unboxUnbox

I wonder if it’s shorter to simply calculate the permutation for the entire input.

J, 20 bytes

1&A.&.>@cut;@,.<@' '

Try it online!

###How it works

 cut  Split on spaces
 &.>@  For each string
1&A.  Swap the last two letters
 <@' ' A single space
 ;@,. Append to each and unbox

I wonder if it’s shorter to simply calculate the permutation for the entire input.

J, (削除) 20 (削除ここまで) 19 bytes

[:;<@A.~&2;.2@,&' '

Try it online!

###How it works

 ;.2@,&' ' Split on spaces and add a space to each string
 <@A.~&2 For each string swap the third and second to last letters
[:; Unbox

I wonder if it’s shorter to simply calculate the permutation for the entire input.

added 84 characters in body
Source Link
FrownyFrog
  • 3.8k
  • 1
  • 15
  • 20
Loading
deleted 39 characters in body
Source Link
FrownyFrog
  • 3.8k
  • 1
  • 15
  • 20
Loading
Source Link
FrownyFrog
  • 3.8k
  • 1
  • 15
  • 20
Loading

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