Skip to main content
In line 3 I don't change the order anymore, so I can use & instead of repeating all groups
Source Link
Philippos
  • 2.7k
  • 1
  • 13
  • 40

sed -E,  266 258 254  254238 bytes

(248 bytes with ugly GNU extensions and bugs)(230 bytes with ugly GNU extensions and bugs)

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/.*/0123456789#:-1:1&:/ :1 s/((.)(.).*:)([a-z]*)(.*)\2\1([a-z])([^:]*:)$/\1\4\5\2\6\7\4\6\5\3\7&\3\5\4\2\6/ s/(#.*[a[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].:$/!b1 s/([a-z]*)([0-9]+)[^:]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!Try it online!

sed -E,  266 258  254 bytes

(248 bytes with ugly GNU extensions and bugs)

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/.*/0123456789#:-1:1&:/ :1 s/((.)(.).*:)([a-z]*)(.*)\2([a-z])([^:]*:)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].:$/!b1 s/([a-z]*)([0-9]+)[^:]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!

sed -E,  266 258 254  238 bytes

(230 bytes with ugly GNU extensions and bugs)

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/.*/0123456789#:-1:1&:/ :1 s/(.)(.).*:([a-z]*)(.*)\1([a-z])([^:]*:)$/&\3\5\4\2\6/ s/([a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].:$/!b1 s/([a-z]*)([0-9]+)[^:]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!

Shorter to add the trailing : right at the beginning
Source Link
Philippos
  • 2.7k
  • 1
  • 13
  • 40

sed -E,  266 258  258254 bytes

(248 bytes with ugly GNU extensions and bugs)

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/^.*/0123456789#:-1:11&:/ :1 s/((.)(.).*:)(:[a-z]*)(.*)\2([a-z])([a-z]*[^:]*:)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].:$/!b1 s//&:/ s/([a-z]*)([0-9]+)[a-z][^:]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!Try it online!

sed -E,  266  258 bytes

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/^/0123456789#:-1:1/ :1 s/((.)(.).*)(:[a-z]*)(.*)\2([a-z])([a-z]*)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].$/!b1 s//&:/ s/([a-z]*)([0-9]+)[a-z]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!

sed -E,  266 258  254 bytes

(248 bytes with ugly GNU extensions and bugs)

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/.*/0123456789#:-1:1&:/ :1 s/((.)(.).*:)([a-z]*)(.*)\2([a-z])([^:]*:)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].:$/!b1 s/([a-z]*)([0-9]+)[^:]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!

Stupid me! I can add the default -1 at the start to avoid extra treatment. Greedy .* always takes the last possible solution.
Source Link
Philippos
  • 2.7k
  • 1
  • 13
  • 40

sed -E, 266 266  258 bytes

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/^/0123456789#:-1:1/ :1 s/((.)(.).*)(:[a-z]*)(.*)\2([a-z])([a-z]*)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].$/!b1 s//&:/ s/([a-z]*)([0-9]+)[a-z]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([0[-0-9]*).?:.*/\1/ /:/s/.*/-1/ 

Try it online!Try it online!

sed -E, 266 bytes

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/^/0123456789#:1/ :1 s/((.)(.).*)(:[a-z]*)(.*)\2([a-z])([a-z]*)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].$/!b1 s//&:/ s/([a-z]*)([0-9]+)[a-z]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([0-9]*).?:.*/\1/ /:/s/.*/-1/ 

Try it online!

sed -E,  266  258 bytes

Unfortunally, sed needs to be tought how to count; otherwise this could have been much shorter. Anyhow, I think this is quite a clever approach and highly golfed. The idea is to put a 1 in front of the first char (line 1, along with counting helper), then to double the word with an increased number at an increased position (line 3). Then comes some overhead to count past 9 and even more overhead to count past 99. Could be golfed by switching to non-decimal output.

Finally, starting from :3, all strings are eaten up from the start and from the end, until there is only 1 or no char left. I'm pretty sure this is the shortest way to check for a palindrome.

s/^/0123456789#:-1:1/ :1 s/((.)(.).*)(:[a-z]*)(.*)\2([a-z])([a-z]*)$/\1\4\5\2\6\7\4\6\5\3\7/ s/(#.*[a-z])(9*)#/\10\2#/ :2 s/((.)(.).*)\2#/\1\30/ t2 /[0-9].$/!b1 s//&:/ s/([a-z]*)([0-9]+)[a-z]/\2\1/g :3 s/([0-9])(.)([^:]*)\2:/\1\3:/ t3 s/.*:([-0-9]*).?:.*/\1/ 

Try it online!

Source Link
Philippos
  • 2.7k
  • 1
  • 13
  • 40
Loading