J, (削除) 20 19 (削除ここまで) 11 bytes
Credit to @Bolce Bussiere
1&A.&.>&.;:
&.;: 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.&.>&.;:
&.;: on words
&.> on each
A. apply the permutation
1& number 1, swap the last two elements
J, (削除) 20 19 (削除ここまで) 1911 bytes
[:;<@A.~&2;.2@,&' '
###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@,&' '
###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(削除) 20 (削除ここまで) 19 bytes
1&A[:;<@A.&~&2;.>@cut;@2@,.<@'&' '
###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;@,.<@' '
###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@,&' '
###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.