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
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
<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(削除) 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
Loading