Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

!I!n!s!e!r!t! !i!n!b!e!t!w!e!e!n!

Posted from here.

This challenge is highly "distilled" from this question. Special thanks to @Akababa!

In this task, you should insert an exclamation mark at the start of the string and after every character.

Rules

  • There will always be a non-empty-string input. The input will not contain tabs either. You can assume that the input only contain non-extended ASCII printable characters and newlines.
  • The input will not contain trailing newlines as long as your language can't detect a newline.
  • This is a contest; the shortest answer should win.

Examples

  • 4 newlines result in 5 newline-delimited exclamation marks. It is very hard to put this as a Markdown text, so this is stated instead.
1 2 3 4 5 6
129591 129012 129127 129582
0

Outputs

!1! !2! !3! !4! !5! !6!
!1!2!9!5!9!1! !1!2!9!0!1!2! !1!2!9!1!2!7! !1!2!9!5!8!2!
!
!0!
asd afjoK ak:e
kPrLd
 fOJOE;
 KFO
KFkepjgop sgpaoj faj

Outputs

!a!s!d! !a!f!j!o!K! !a!k!:!e!
!k!P!r!L!d!
! ! ! ! !f!O!J!O!E!;!
! ! ! ! !K!F!O!
!K!F!k!e!p!j!g!o!p! !s!g!p!a!o!j! ! ! !f!a!j!

A base test case with only one character:

a

Outputs

!a!

(Auto-completion! Just kidding, there is no such thing.) Contains exclamation marks:

!!
!!
!!
!!
!!

Outputs:

!!!!!
!!!!!
!!!!!
!!!!!
!!!!!

Answer*

Draft saved
Draft discarded
Cancel
4
  • \$\begingroup\$ Actually the Sed code is just 15 characters there: Try it online!. \$\endgroup\$ Commented Aug 19, 2019 at 15:11
  • \$\begingroup\$ Great, thank you. I was unclear how that worked... \$\endgroup\$ Commented Aug 19, 2019 at 15:13
  • 1
    \$\begingroup\$ s/\b\|\B/!/g also works for 12 bytes \$\endgroup\$ Commented Aug 20, 2019 at 7:15
  • \$\begingroup\$ @Cowsquack thank you. updated. \$\endgroup\$ Commented Aug 20, 2019 at 12:47

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