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 14 characters in body
Source Link
math junkie
  • 7.3k
  • 1
  • 23
  • 47

Pyth, (削除) 22 (削除ここまで) 20(削除) 20 (削除ここまで) 17 bytes

-3 bytes using @loopy wait's idea

<X+hQJ%+lQ/Q\'43円\'J<X+hQJ%l``Q43円\'J

Try it online! Try it online! -- Try all test cases Try all test cases

<X+hQJ%+lQ/Q\'43円\'J<X+hQJ%l``Q43円\'J
 lQ ``Q Length ofSurround the input with two pairs of quotes
 + /Q\' plus the number of (Which also escapes `'` incharacters theas input`\'`)
 %%l  4 4 Take the length mod 4
 J (Set J to the result)
 +hQ Prepend the first letter of the input
 X 3円\' 3円\' Translate `3`s to `'`s
< J J Keep the first J elements

Pyth, (削除) 22 (削除ここまで) 20 bytes

<X+hQJ%+lQ/Q\'43円\'J

Try it online! -- Try all test cases

<X+hQJ%+lQ/Q\'43円\'J
 lQ  Length of the input
 + /Q\' plus the number of `'` in the input
 % 4 mod 4
 J (Set J to the result)
 +hQ Prepend the first letter of the input
 X 3円\' Translate `3`s to `'`s
< J Keep the first J elements

Pyth, (削除) 22 (削除ここまで) (削除) 20 (削除ここまで) 17 bytes

-3 bytes using @loopy wait's idea

<X+hQJ%l``Q43円\'J

Try it online! -- Try all test cases

<X+hQJ%l``Q43円\'J
 ``Q Surround the input with two pairs of quotes
  (Which also escapes `'` characters as `\'`)
 %l  4 Take the length mod 4
 J (Set J to the result)
 +hQ Prepend the first letter of the input
 X 3円\' Translate `3`s to `'`s
< J Keep the first J elements
added 397 characters in body
Source Link
math junkie
  • 7.3k
  • 1
  • 23
  • 47

Pyth, (削除) 22 (削除ここまで) 20 bytes

<X+hQJ%+lQ/Q\'43円\'J

Try it online! -- Try all test cases

<X+hQJ%+lQ/Q\'43円\'J
 lQ Length of the input
 + /Q\' plus the number of `'` in the input
 % 4 mod 4
 J (Set J to the result)
 +hQ Prepend the first letter of the input
 X 3円\' Translate `3`s to `'`s
< J Keep the first J elements

Pyth, (削除) 22 (削除ここまで) 20 bytes

<X+hQJ%+lQ/Q\'43円\'J

Try it online! -- Try all test cases

Pyth, (削除) 22 (削除ここまで) 20 bytes

<X+hQJ%+lQ/Q\'43円\'J

Try it online! -- Try all test cases

<X+hQJ%+lQ/Q\'43円\'J
 lQ Length of the input
 + /Q\' plus the number of `'` in the input
 % 4 mod 4
 J (Set J to the result)
 +hQ Prepend the first letter of the input
 X 3円\' Translate `3`s to `'`s
< J Keep the first J elements
added 2 characters in body
Source Link
math junkie
  • 7.3k
  • 1
  • 23
  • 47

Pyth, 22(削除) 22 (削除ここまで) 20 bytes

&J%+lQ<X+hQJ%+lQ/Q\'4-X+hQJ3円\'1Q\'43円\'J

Try it online! Try it online! -- Try all test cases Try all test cases

Pyth, 22 bytes

&J%+lQ/Q\'4-X+hQJ3円\'1

Try it online! -- Try all test cases

Pyth, (削除) 22 (削除ここまで) 20 bytes

<X+hQJ%+lQ/Q\'43円\'J

Try it online! -- Try all test cases

Source Link
math junkie
  • 7.3k
  • 1
  • 23
  • 47
Loading

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