g | x | w | all
Bytes Lang Time Link
774Marbles230610T115026ZVincent
nan230531T052937ZDadsdy
042C230609T032900ZZoey
025Rust230607T182931ZJSorngar
005Thunno 2230607T164859ZThe Thon
018><> Fish230603T211601Zchunes
029Python 3230531T054741ZDadsdy
067Rockstar230530T160206ZShaggy
030Python230529T090046ZThe Empt
011AWK230529T061517ZRARE Kpo
012ARM Thumb machine code221026T202509ZEasyasPi
080Python 3221025T134335ZMr.McNug
011BQN221024T221640ZDLosc
011APL Dyalog Unicode221024T173445ZSeggan
028Factor221003T225020Zchunes
039C gcc190819T233402Zatt
016Wolfram Language Mathematica190819T235114Zatt
044Excel221003T202231ZEngineer
nan221003T201247Zbigyihsu
012K ngn/k210212T162022Zcoltim
023Zsh190818T113857ZGammaFun
011Subleq 8bit210511T120846ZAxuary
013BRASCA210511T122031ZSjoerdPe
019Julia210419T143638ZMarcMush
011AWK210511T102550Zcnamejj
004Vyxal210511T035348ZUndersla
013Vim210419T141918ZAaroneou
011Branch210418T041239Zhyper-ne
011Hexagony201101T012919ZUndersla
012Zsh210214T155842Zpxeger
008x8616 machine code210212T211408Z640KB
005Pip210212T130932ZRazetime
008Husk201031T230240ZLegionMa
0191+200812T055912ZTwilight
018MAWP200812T051851ZRazetime
142C#190819T182519Zcanttalk
027Javascript191225T030735Zdhilln
009Pushy191224T200509ZFlipTack
008Keg190820T110105Zlyxal
031PHP 7.4190819T100134ZNight2
072VBA190819T181407ZBen
039Forth gforth190819T145628Zreffu
054BrainFlak190913T091629ZDorian
047Red190913T075214ZGalen Iv
032C gcc190822T121618Zjdt
050Kotlin190911T133351Zpappbenc
031Lua190826T201828Zlqdev
012Ahead190824T053820Zsnail_
019JavaScript ES6190818T104301ZArnauld
032Elvish190822T115249Zkon
011Perl 6190818T143110ZJo King
069MarioLANG190820T201045Zsquid
010Brachylog190820T211610ZUnrelate
016Ruby190819T081845ZG B
042Wolfram Language Mathematica190819T044231ZKai
036Bash190819T172132Zspuck
021PowerShell190820T150556ZAdmBorkB
012sed190819T145558ZJonah
023SimpleTemplate190819T102356ZIsmael M
075PHP190819T144356ZShiSHcat
006><>190819T075418ZSok
026Python 3190820T071345ZU13-Forw
12136502190819T203444Zlee
041Emacs Lisp190819T181319ZJordon B
022brainfuck190818T145505ZKamila S
017Scala190819T081539ZV. Court
013Triangular190818T173114Zsquid
006Perl 5 p0190818T123108ZKjetil S
026Python 3190819T123410Zwaterbyt
007Befunge98 PyFunge190819T094019ZCinaski
006MathGolf190819T084050Zmaxb
079Whitespace190819T084002ZKevin Cr
00605AB1E190818T111143ZMr. Xcod
0328086 machine code190819T073056ZErikF
00405AB1E190819T072836ZKevin Cr
061Aheui esotope190819T072114ZLegenDUS
012J190819T021655ZJonah
020Java 8190819T014909ZJakob
050C gcc190818T230119ZWarmTaun
025R190819T000054ZNick Ken
009Labyrinth190818T153214ZJonathan
001QuadR190818T185952ZAdá
028C# Visual C# Interactive Compiler190818T183847Zdana
008Pyth190818T185002Zhakr14
011Perl 5 + p190818T184053ZDom Hast
004Japt190818T104341ZShaggy
004Japt190818T174518ZGymhgy
005Stax190818T143911Zrecursiv
018Haskell190818T123821Zpommicke
094SNOBOL4 CSNOBOL4190818T143813ZGiuseppe
005Jelly190818T121311ZJonathan
027Python 2190818T125149ZJonathan
047Pepe190818T123756Zu-ndefin
027Python 3190818T120909Zsquid
011Gema190818T115107Zmanatwor
006Charcoal190818T111129ZNeil
002Retina 0.8.2190818T110155ZNeil

Marbles, 774 bytes

An elegant 25 x 31 grid of 774 characters:

○══════════════════════╗
║○═══════════════════╗ ║
║║○════════════════╗ ║ ║
║║║○═════════════╗ ║ ║ ║
║║║║○══════════╗ ║ ║ ║ ║
║║║║║○═══════╗ ║ ║ ║ ║ ║
║║║║║║○════╗ ║ ║ ║ ║ ║ ║
║║║║║║║○═╗ ║ ║ ║ ║ ║ ║ ║
║║║║║║║║○╜○╜○╜○╜○╜○╜○╜○╜
║║║║║║║║ ┃ ║ ║ ║ ║ ┃ ║ ║
║║║║║║║║◆╢◆╢◆╢◆╢◆╢◆╢◆╢◆╢
║║║║║║║║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃
║║║║║║║║◇╢◇╢◇╢◇╢◇╢◇╢◇╢◇╢
║║║║║║║║○╬═╬═╬═╬═╬═╬═╬╗║
║║║║║║║║║║╔╬╗║╔╬╗║╔╬╗║║║
║║║║║║║║╓╢╙╢╓╢╙╢╓╢╙╢╓╢╙╢
║║║║║║║║╚╬╝║╚╬╝║╚╬╝║╚╬╝║
║║║║║║║║○╜○╜○╜○╜○╜○╜○╜○╜
║║║║║║║║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃
║║║║║║║║◇╜◇╜◇╜◇╜◇╜◇╜◇╜◇╜
║║║║║║║║◆╢◆╢◆╢◆╢◆╢◆╢◆╢◆╢
║║║║║║║║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃
║║║║║║║║◇╢◇╢◇╢◇╢◇╢◇╢◇╢◇╢
║║║║║║║╚═╝ ║ ║ ║ ║ ║ ║ ║
║║║║║║╚════╝ ║ ║ ║ ║ ║ ║
║║║║║╚═══════╝ ║ ║ ║ ║ ║
║║║║╚══════════╝ ║ ║ ║ ║
║║║╚═════════════╝ ║ ║ ║
║║╚════════════════╝ ║ ║
║╚═══════════════════╝ ║
╚══════════════════════╝

Marbles is not available on tio.run yet but the test examples can be run using marbles.py:

± echo test | ./marbles.py exclamation.txt --quiet --no-display
!t!e!s!t!
!

Ungolfed version:

╔══════════════════════════════════════════════════╗
║  ╔════════════════════════════════════════════╗  ║
║  ║  ╔══════════════════════════════════════╗  ║  ║
║  ║  ║  ╔════════════════════════════════╗  ║  ║  ║
║  ║  ║  ║  ╔══════════════════════════╗  ║  ║  ║  ║
║  ║  ║  ║  ║  ╔════════════════════╗  ║  ║  ║  ║  ║
║  ║  ║  ║  ║  ║  ╔══════════════╗  ║  ║  ║  ║  ║  ║    ┓ 8 marbles representing a byte
║  ║  ║  ║  ║  ║  ║  ╔════════○  ○  ○  ○  ○  ○  ○  ○    ┛ This is the main variable
║  ║  ║  ║  ║  ║  ║  ║        ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗  ┓
║  ║  ║  ║  ║  ║  ║  ║        ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝  ┃
║  ║  ║  ║  ║  ║  ║  ║     ○══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╗ ┃ Synchronization
║  ║  ║  ║  ║  ║  ║  ║     ║  ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗║ ┃ Right-most marble exits first
║  ║  ║  ║  ║  ║  ║  ║     ║  ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝║ ┃
║  ║  ║  ║  ║  ║  ║  ║     ╚══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╝ ┛
║  ║  ║  ║  ║  ║  ║  ║        ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○   ┓ Set value to 0x21
║  ║  ║  ║  ║  ║  ║  ║        ║  ║  ┃  ║  ║  ║  ║  ┃    ┛ (the ascii character '!')
║  ║  ║  ║  ║  ║  ║  ║        ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆   ┓
║  ║  ║  ║  ║  ║  ║  ║        ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃    ┃ Write the byte to stdout
║  ║  ║  ║  ║  ║  ║  ║        ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇   ┃ LSB is on the right
║  ║  ║  ║  ║  ║  ║  ║        ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃    ┛
║  ║  ║  ║  ║  ║  ║  ║        ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗  ┓
║  ║  ║  ║  ║  ║  ║  ║        ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝  ┃
║  ║  ║  ║  ║  ║  ║  ║     ○══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╗ ┃ Synchronization
║  ║  ║  ║  ║  ║  ║  ║     ║  ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗║ ┃ Right-most marble exits first
║  ║  ║  ║  ║  ║  ║  ║     ║  ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝║ ┃
║  ║  ║  ║  ║  ║  ║  ║     ╚══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╝ ┛
║  ║  ║  ║  ║  ║  ║  ║        ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○   ┓ Read a byte from stdin
║  ║  ║  ║  ║  ║  ║  ║        ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃    ┃ LSB is on the right
║  ║  ║  ║  ║  ║  ║  ║        ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇   ┛
║  ║  ║  ║  ║  ║  ║  ║        ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆   ┓
║  ║  ║  ║  ║  ║  ║  ║        ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃    ┃ Write the byte to stdout
║  ║  ║  ║  ║  ║  ║  ║        ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇   ┃ LSB is on the right
║  ║  ║  ║  ║  ║  ║  ║        ┃  ┃  ┃  ┃  ┃  ┃  ┃  ┃    ┛
║  ║  ║  ║  ║  ║  ║  ╚════════╝  ║  ║  ║  ║  ║  ║  ║
║  ║  ║  ║  ║  ║  ╚══════════════╝  ║  ║  ║  ║  ║  ║
║  ║  ║  ║  ║  ╚════════════════════╝  ║  ║  ║  ║  ║
║  ║  ║  ║  ╚══════════════════════════╝  ║  ║  ║  ║
║  ║  ║  ╚════════════════════════════════╝  ║  ║  ║
║  ║  ╚══════════════════════════════════════╝  ║  ║
║  ╚════════════════════════════════════════════╝  ║
╚══════════════════════════════════════════════════╝

This is the first marbles submission ever :)

(,) 111 91 Chars or \$91\log_{256}(3)\approx18.03\$ Bytes

((),()()()()()()()())((),(())(())(())(())())(,,,(()()),(,(()(),((()()())),,(())))(()()),())

TIO

C, 42 bytes

f(char *s){printf("!%c",*s);if(*s++)f(s);}

Essentially to not have to have two printf statments I have the printf run on the null byte of the string which prints the '!' but the null byte is ignored.

Easier to read

f(char *s){
  // Prints ! and char of string
  printf("!%c", *s);
 
  // If more string than recurse for next char
  if(*s != 0) f(s+1);
}

Rust, 25 bytes

|s:&str|s.replace("","!")

Attempt This Online!

Thunno 2, 5 bytes

""'!v

Attempt This Online!

Thunno 2, 6 bytes

'!j'!ṛ

Attempt This Online!

Explanations

""'!v  # Implicit input
    v  # Replace...
""     # ...the empty string...
  '!   # ...with "!" in the input
       # Implicit output
'!j'!ṛ  # Implicit input
'!j     # Join by "!"
   '!ṛ  # Surround by "!"
        # Implicit output

><> (Fish), 18 bytes

'!'orl0=?;o'!'o40.

Try it

Python 3, 29 Bytes

print('',*input(),'',sep="!")

Try It Online

Rockstar, 67 bytes

listen to S
while S
cut S
join S with "!"
say "!"+S+"!"
listen to S

Try it here (Code will need to be pasted in)

Python, 30 Bytes

lambda x:'!%s!'%'!'.join([*x])

It feels like these methods were designed for the challenge!

-1 from Jacob (now noodle man) by using the cursed % (Dun dun dun!)

-3 from Glorfindel for using a starred method for conversion!

!T!r!y! !r!u!n!n!i!n!g! !i!t! !o!n!l!i!n!e!

AWK, 11 bytes

gsub(_,"!")
 echo '
1 2 3 4 5 6
129591 129012 129127 129582

0
asd afjoK ak:e
kPrLd
    fOJOE;
    KFO
KFkepjgop sgpaoj   faj
!!
!!
!!
!!
!!' | awk 'gsub(_,"!")'

!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!
!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!
!!!!!
!!!!!
!!!!!
!!!!!
!!!!!

ARM Thumb machine code, 12 bytes

21 22 08 c8 0c c1 00 2b fb d1 70 47

Assembly source:

    .syntax unified
    .arch armv7-a
    .thumb
    .thumb_func
    .globl insert_between
// input: r0: pointer to null terminated UTF-32LE string
//        r1: pointer to buffer
// output: null terminated UTF-32LE string at *r1
// C callable prototype:
//   void insert_between(const char32_t *in, char32_t *out);
insert_between:
    // Put '!' in a register for later
    movs   r2, #'!'
.Lloop:
    // Load char from pointer, advance pointer
    ldmia  r0!, {r3}                          @ tmp = *in++;
    // Store '!' then the char from the pointer.
    // The null terminator will be included,
    // which also adds the trailing '!'.
    stmia  r1!, {r2, r3}                      @ *out++ = '!', *out++ = tmp;
    // Loop if r3 wasn't a null terminator
    cmp    r3, #0
    bne    .Lloop
    // return
    bx     lr

Callable from C with the following prototype:

void insert_between(const char32_t *in, char32_t *out);

As with most of my Thumb string solutions, everything is null terminated UTF-32 thanks to ldmia and stmia being the only narrow instructions to load and advance a pointer.

Python 3, 80 bytes

s=list(input())
n=0
print(end="!")
for x in s:
    print(s[n],end="!")
    n=n+1

Try it online!

BQN, 11 bytes

'!'⊸(⊣∾´∾¨)

Anonymous tacit function that takes and returns a string. Try it at BQN online!

Explanation

'!'⊸(⊣∾´∾¨)
    (      )  Call the following function with the original argument on the right
'!'⊸          and '!' on the left:
         ∾¨     Concatenate each (prepends '!' to each character, resulting
                in a list of two-character strings)
       ∾´       Right-fold that list on concatenation
     ⊣          with a starting value of the left argument (i.e. '!')

A port of Sʨɠɠan's APL solution is also 11 bytes:

(∾⊢∾∾¨)⟜'!'

Try it!

APL (Dyalog Unicode), 11 bytes

(∊⊢⍪⍪¨)∘'!'

Try it online!

@Adám's golf to mine (see below).

{'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)}  ⍝ original
{'!'⍪∊⍵⍪¨('!'⍴⍨≢⍵)}  ⍝ concatenate each instead of transpose mix
{'!'⍪∊⍵⍪¨ '!'}       ⍝ each already handles many-to-one
{ ⍵ ⍪∊⍺⍪¨  ⍵ }∘'!'   ⍝ break out "!"
{∊⍵ ⍪ ⍺⍪¨  ⍵ }∘'!'   ⍝ defer flattening to later
(∊⊢ ⍪  ⍪¨    )∘'!'   ⍝ go tacit
(∊⊢⍪⍪¨)∘'!'          ⍝ remove spacing

APL (Dyalog Unicode), 19 bytes

{'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)}

Try it online!

My first APL submission :P Loving this language. No idea why I need the parentheses after .

{'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)}
{                   } ⍝ Boilerplate
              ⍴⍨      ⍝ Repeat
           '!'        ⍝ Exclamation point
                 ≢⍵  ⍝ len(input) times
         ⍵(        )  ⍝ Wrap ^ into an array with the input
       ↑              ⍝ Matrixify
      ⍉               ⍝ Transpose
     ∊                ⍝ Flatten
    ⍪                  ⍝ Prepend
 '!'                  ⍝ An exclamation point

Factor,  31  28 bytes

[ 33 interleaved [I !${}!I]]

Attempt This Online!

C (gcc), 48 45 39 bytes

f(char*s){printf("!%.1s",s++)>1&&f(s);}

Try it online!

-3 thanks to ceilingcat

Wolfram Language (Mathematica), 26 16 bytes

"!"<>#&/@#<>"!"&

Try it online!

Input a list of characters. Returns a string.

Excel, 44 bytes

="!"&CONCAT(MID(A1,SEQUENCE(LEN(A1)),1)&"!")

Screenshot

Note: The line breaks are there with or without Word Wrap turned on but it won't look right until you turn it on. The screenshot has Word Wrap turned on.

Go, 105 bytes

import."regexp"
func f(s[]byte)[]byte{return append(MustCompile(`(?s).`).ReplaceAll(s,[]byte(`!$0`)),33)}

Attempt This Online!

K (ngn/k), 13 12 bytes

-1 byte from @ngn's savings

{x,/y,'x}"!"

Try it online!

Creates a function projection, with x fixed to "!".

Zsh, 32 23 bytes

<<<!${(j:!:)${(s::)1}}!

Try it online! Try it online!

(s::) splits into characters, (j:!:) joins on !s.

Subleq (8-bit), 1211 bytes

-1 byte for removing last 0

2 -1 33
-1 8 -1
8 -1 0
8 8 

Subleq emulator

Explanation

0:  2 -1 33 ' Output 2: (char(33)); 3rd argument is not used for output so use it for memory
3: -1  8 -1 ' Read input to 8:, exit if null
6:  8 -1  0 ' Output 8:
9:  8  8    ' 8: = 0 goto 0

BRASCA, 14 13 bytes

-1 byte thanks to RezNesX

,![$'!oo{]'!o

Try it online!

Explanation

,               - Reverse stack
 ![$    {]      - Loop stack length:
    '!oo        -     Print "!" followed by the next letter
          '!o   - Print the last "!"

Julia, 21 20 19 bytes

x->'!'join(x,!)*'!'

Try it online!

AWK, 11 bytes

gsub(a,"!")

Try it online!

This is similar to some other entries. It changes a null string to ! globally, using $0 as the default target, then prints the result since no other action is defined. Using a works since it's an undefined variable and is shorter than using "" (which would do the same thing).

Vyxal, 4 bytes

¤\!V
 ¤\!V - Full program
-------
 ¤    - Push empty string to the stack
  \!  - Push exclamation mark to the stack, better than `!`
    V - take implicit input and replace the empty 
        string with the exclamation point

For an empty input, it will produce !0! because it considers the empty input 0, but I don't believe this can be fixed since taking input plainly returns 0 for "".

Try it Online!

Vim, 13 bytes

:%s/\_./!&/g

Works by putting a ! before every character, including newline characters. The TIO version doesn't work properly for the 4 newline testcase, but it does work in Vim.

Try it online!

Branch, 11 bytes

33.,[.33.,]

Try it on the online Branch interpreter!

Put 33 on the tree and output (!). Then, grab input. Finally, while that value is not EOF, output it, output 33 (!), and grab input again.

Hexagony, 11 bytes

$>P...@1;,<

Try it online!

  $ > P
 . . . @
1 ; , < .
 . . . .
  . . .

(old) Hexagony, 17 bytes

{33...@;",<./{;/>

Try it online!

  { 3 3
 . . . @
; " , < .
 / { ; /
  > . .

{33 Puts an ! in left memory

;" Prints ! at the start and sets back mem

, Gets the next byte of input, < sends the IP U-R if null (which terminates it with @), D-R else

/{;/ Reflects IP, prints current byte, and sets it to the next line

> Redirects the IP to the start of the loop

Zsh, 12 bytes

<<<${1///!}!

Try it online!

x86-16 machine code, 8 bytes

00000000: b021 aaa4 aae2 fcc3                      .!......

Listing:

B0 21       MOV  AL, '!'        ; character to insert
AA          STOSB               ; write first ! to output string  
        CLOOP: 
A4          MOVSB               ; copy input char to output string 
AA          STOSB               ; write ! to output string 
E2 FC       LOOP CLOOP          ; loop until end of input 
C3          RET                 ; return to caller

Callable function, input at SI, length in CX. Output to string at DI.

Test runs:

enter image description here

enter image description here

enter image description here

Pip, 5 bytes

aJW'!

Try it online!

The JW builtin was made for challenges like this.

Husk, 10 8 bytes

-2 bytes thanks to Razetime!

`:'!ṁe'!

Try it online!

1+, 20 19 bytes

1##11"+""*"**+;,;1#

1+ 19 vs 18 MAWP

Error-terminating because comparison is expensive.

MAWP, 18 bytes

%|092M3W!;~[;~!;~]

Dion's solution.

Try it!

Older solution(19 bytes):

%|0~[65W3M;;]65W3M;

Try it!

C#, 142 bytes

public class P{public static void Main(string[]a){System.Console.Write("!");foreach(char c in a[0]){System.Console.Write(c.ToString()+"!");}}}

Javascript (27 bytes)

My first code golf, 27 bytes in Javascript. Could probably shave some more bytes off, but I'm not too sure.

f={x:s=>`!${s.join('!')}!`}

Example Usage

console.log(f.x('1 2 3 4 5'.split('')))
// Output: !1! !2! !3! !4! !5!

Pushy, 9 bytes

L:33{;33"

Try it online!

L:   ;        \ len(input) times do:
  33          \    Append character 33 (exclamation mark)
    {         \    Cyclically shift the string left once
      33      \ Append character 33 again
        "     \ Print the result

Keg, 9 8 bytes

?⑷\!⑸\!^

Using a mapping approach really does help

Try it online!

Answer History

9 bytes

?^(\!')\!

Pretty much a port of the MathGolf submission.

Try it online!

PHP (7.4), 31 bytes

Based on Petah's comment.

fn($s)=>preg_replace(__,'!',$s)

Try it online!


PHP, 52 bytes

function($s){return'!'.join('!',str_split($s)).'!';}

Try it online!

VBA, 75 bytes 72 bytes

72 bytes as a sub that outputs to the immediate window (thanks @taylorscott)

Sub s(x):Debug.?"!";:For i=1To Len(x):Debug.?Mid(x,i,1)"!";:Next:End Sub

75 bytes as a function that returns the formatted string.

Function t(x):t="!":For i=1To Len(x):t=t &Mid(x,i,1) &"!":Next:End Function

Which expands to and is readable as

Public Function t(x)
    t = "!"
    For i = 1 To Len(x)
        t = t & Mid(x, i, 1) & "!"
    Next
End Function

Test cases

Public Sub test_golf()

    x = "1 2 3 4 5 6" & vbCr & "129591 129012 129127 129582" & vbCr & vbCr & "0"
    'x = "a"
    'x = "!!" & vbCr & "!!" & vbCr & "!!" & vbCr & "!!" & vbCr & "!!"
    
    Debug.Print x
    s(x)              ' to call the sub
    Debug.Print t(x)  ' to call the function

End Sub

Forth (gforth), 40 39 bytes

: f ." !"bounds do i 1 type ." !"loop ;

Try it online!

Code Explanation

: f           \ start a new word definition
  ." !"bounds \ print ! and place the ending address on the stack
  do          \ start a counted loop from start-addr to end-addr      
    i         \ get address of current char
    1 type    \ print the char at the given address
    ." !"     \ print !
  loop        \ end the loop
;             \ end the word definition

Brain-Flak, 54 bytes

(()){({}<>)((((()()()()){}){}){}())<>}<>{({}<>)<>}<>{}

Try it online!

Code:

(())                            push 1, so the loop runs at least one time
{                               while stack 1 isn't empty
    ({}<>)                      move letter to stack 2
    ((((()()()()){}){}){}())    push 33 (Exclamation Mark) on stack 2
    <>                          return to stack 1 for checking if the end is reached
}
<>{({}<>)<>}                    move everything from stack 2 back to stack 1 (otherwise the text would be reversed)
<>{}                            switch to stack 1 and delete leading 1

Red, 47 bytes

func[s][parse s[insert"!"any[skip insert"!"]]s]

Try it online!

C (gcc), 32 bytes

f(s){printf("!%s",s)-1&&f(s+4);}

Try it online!

Kotlin, 50 bytes

fun f(s:String)=s.map{"!$it"}.joinToString("")+"!"

Try it online!

This is my first participation on this site, thought I would try a challenge with my new favourite language.

Lua, 31 bytes

print((io.read():gsub("","!")))

Ahead, 12 bytes

~irj!'~
@Wu<

Try it online!

JavaScript (ES6), 19 bytes

Takes input as an array of characters.

s=>`!${s.join`!`}!`

Try it online!


JavaScript (ES6),  23  20 bytes

Saved 3 bytes thanks to @ShieruAsakoto

Takes input as a string.

s=>[,...s,,].join`!`

Try it online!


JavaScript (ES6), 22 bytes

Suggested by @tjjfvi

Takes input as a string.

s=>s.replace(/|/g,"!")

Try it online!

Elvish, 32 bytes

use re;re:replace "" "!" (slurp)

Copy and paste into the Live Environment to try it out!

Perl 6, 16 11 bytes

{S:g/<(/!/}

Try it online!

Replaces all zero width matches with exclamation marks. Null regexes are not allowed, so we use a capture marker to capture nothing instead

MarioLANG, 95 94 90 89 69 bytes

++++++
======< >)
>+++++++",+[
=======<.==<
>+++++++!(.-
========#===

Try it online!

First time trying out MarioLANG, that was a lot of fun!

Thanks to Jo King for -20 bytes

Explanation:

So, as the name implies, MarioLANG is made to execute like a game of Super Mario Bros. It operates similarly to BF, with memory arranged in a tape of cells. There are operators to increment, decrement, print (as ascii or numeric) and read into the current memory cell, and operators to move left or right along the tape.

Mario (the instruction pointer) always begins in the top left cell of the program, with his intended direction of motion set to the right. If Mario does not have a floor-like object beneath him (=, ", or #), he will fall until he reaches a floor-like object. If Mario leaves the program space, the program ends due to Game Over :(

This specific program can basically be split into two halves: the setup, and the loop.

   Setup                          Loop
-----------------------------------------------
                       |
++++++                 |          
======<                |          >)
>+++++++               |          ",+[
=======<               |          .==<
>+++++++               |          !(.-
========               |          #===

In the Setup section, we're simply incrementing the first memory cell until we reach 33 - the ASCII value for "!". Easy enough; if this can be golfed, it's purely a matter of shape. Mario starts from the top left, picks up 10 coins, starts falling when picking up the 11th, switches directions, then repeats. He picks up the last 11 coins without switching directions; he ends the setup section at the bottom-rightmost "+".

In the loop section, Mario starts by reaching an elevator. The "!" operator makes him cease motion, so that he remains on the elevator. On the way up, it prints the corresponding ASCII character to the current memory cell's value (this one is always 33, "!"), then switches to the next cell in memory. Mario reaches the top and sets his direction to the right. He falls, and reads a character from input as its ASCII value (or -1 if no character). We increment because the only measure of control in MarioLANG is to skip an instruction if the current memory cell has a value of 0. If it does, we skip changing Mario's direction, so he will walk right off of the next floor to his doom. If it does not, we set direction to left; walking left off of the floor below decrements the current cell back to its previous value, that value is printed, and we move back to the first memory cell before getting back on the elevator.


Previous version (89 bytes):

+++++++++++>,
==========@"+
+++++++++++)[
@==========.==<
+++++++++++!(.-
===========#===

Brachylog, 10 bytes

"!"w.∋w?w⊥

Try it online!

Takes input through the output variable, and unifies the input variable with "!", printing the output.

"!"w          Print "!", which is the input variable.
    .∋w       Print an element of the output variable.
       ?w     Print the input variable again.
         ⊥    Fail.

Ruby, 17 16 bytes

->s{s.gsub'',?!}

Try it online!

Thanks Value Ink for -1 byte

Wolfram Language (Mathematica), 49 48 42 bytes

#~StringSplit~""~StringRiffle~{a="!",a,a}&

Try it online!

-6 bytes thanks to @attinat

Bash, 36 bytes

while read -n1 c;do printf \!$c;done

Try it online!

This counts on the newline terminating the input for the last ! mark.

PowerShell, 21 bytes

"$args"-replace"","!"

Try it online!

Boring regex replacement is boring. ;-)

sed, 12 bytes

s/\b\|\B/!/g

Try it online!

-3 bytes thanks to Cows Quack

SimpleTemplate, 23 bytes

This is a language I wrote, and it was supposed to be for templates, but well.

!{@eachargv.0}{@echo_}!

Should be almost self-explanatory, once you see the ungolfed code:

!{@each argv.0 as char} {@echo char}!{@/}

And an explanation:


Pure SimpleTemplate solution:

{@fn x}!{@eachargv.0}{@echo_}!{@/}{@/}

Creates a function x that outputs the same result.

You can use it like this:

{@call x "this is an example"}

You can try all of this on: http://sandbox.onlinephpfunctions.com/code/f6baff8d411fc8227ece81eccf05b6e7d3586bfa

On the line 908, you can use the variables $golfed, $ungolfed and $fn to test all the versions.



However, if it is allowed to use a character array, the code is simplified (20 bytes):

!{@echoj"!" argv.0}!

And ungolfed:

!{@echo separator "!" argv.0}!

Basically, outputs all items in the array, joined by "!", surrounded by literal !.
Due to limitations in the compiler class, the space is mandatory (in the golfed version).

This code is also extremelly harder to use in pure SimpleTemplate (using the function as example):

{@fn x}!{@echoj"!" argv.0}!{@/}

{@// alternative: @call str_split into a "a char array"}
{@set a "a", " ", "c", "h", "a", "r", " ", "a", "r", "r", "a", "y"}

{@call x a}

The @call can call a function that exists in PHP, which means that it isn't a pure SimpleTemplate solution.

PHP, 75 bytes

Full program.

foreach(file('php://stdin')as$e)echo'!'.implode("!",str_split($e));echo"!";

Try it online!

PHP, 100 bytes

foreach(explode("\n",file_get_contents('php://stdin'))as$e)echo'!'.implode("!",str_split($e))."!\n";

Try it online!

PHP, 117 bytes

foreach(explode("\n",file_get_contents('php://stdin'))as$e){echo'!';foreach(str_split($e)as$c)echo $c."!";echo "\n";}

Try it online!

><>, 11 6 bytes

"!"oio

Try it online!

Saved 5 bytes thanks to Jo King, suggesting exiting with an error. Previous version which does not exit with an error:

"!"oi:0(?;o

Try it online!

Python 3, 26 bytes

lambda x:x.replace('','!')

Try it online!

6502, 12 bytes (13 bytes if Apple II)

6502

The machine code assumes that a pair of zero page locations are connected to character input ($FE) and output (FF) hardware. Many 6502-based systems facilitate I/O in this fashion, albeit I/O address are usually not in zero page.

For simplicity, I used Py65, a 6502 microcomputer system simulator written in Python.

Here is a memory dump from Py65. You can load the following code anywhere in zero page such that it does not overlap $FE and $FF.

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110010
.mem 0:b
0000:  a9  21  85  ff  a5  fe  f0  fc  85  ff  d0  f4

Running in a Windows command window, you can paste (Ctrl+V) any text you desire, or you can simply type. If typing, press Ctrl+J for a newline (same ASCII char). Press Ctrl+C to interrupt the processor and return to the Py65 command prompt.

Naturally, assembly code is easier to read.

       PC  AC XR YR SP NV-BDIZC
6502: 0000 00 00 00 ff 00110010
.d 00:0b
$0000  a9 21     LDA #$21
$0002  85 ff     STA $ff
$0004  a5 fe     LDA $fe
$0006  f0 fc     BEQ $0004
$0008  85 ff     STA $ff
$000a  d0 f4     BNE $0000

For clarity, here is the assembly code in CBA65 format.

; ASSEMBLE:
; cba65 bangit
;
; LOAD/RUN
; python3 py65/monitor.py -i 00fe -o 00ff -l bangit.bin
; goto 0000

        .FILES  BIN=256

; I/O LOCATIONS
GETC    .EQU    $FE             ; (1) MOVING PY65'S GETC TO ZP SHAVES 1 BYTE
PUTC    .EQU    $FF             ; (1) MOVING PY65'S PUTC TO ZP SHAVES 2 BYTES

        .ORG    $0000

VROOM   LDA     #'!'
        STA     PUTC
VROOM2  LDA     GETC
        BEQ     VROOM2
        STA     PUTC
        BNE     VROOM

        .END

Apple II

The code above assumes a null indicates there is no input, so continues polling until a non-null value is returned.

For comparison, the Apple I and Apple II signals availability of a new character by setting bit 7 of the keyboard I/O address, which then needs to be cleared after fetching the character. On those systems, character I/O usually is performed by calling system monitor routines instead of accessing the hardware directly.

By calling RDKEY ($FD0C) and COUT ($FDED), the Apple II equivalent of the above can be coded in 13 bytes, and is runnable anywhere in RAM. Here is the code I ran in an Apple //e emulator, a2ix on Android 9.

Pressing Return has the same effect as a newline.

*300L

0300-   A9 A1       LDA   #$A1
0302-   20 ED FD    JSR   $FDED
0305-   20 0C FD    JSR   $FD0C
0308-   20 ED FD    JSR   $FDED
030B-   F0 F3       BEQ   $0300

Did you notice that instead of the normal ASCII value #$21 for the exclamation point, #$A1 is used instead? That's because sending standard ASCII values to COUT causes them to be displayed in "inverse mode," black on white. Displaying ASCII in normal white on black requires adding #$80 to the character value in the accumulator before calling COUT. Because RDKEY returns characters with the hi-bit set, assembly programs generally cleared the bit of the character to obtain its ASCII value before using it.

Emacs Lisp, 41 bytes

(while(or(insert"!")(not(forward-char))))

Assuming input is received as the contents of the current buffer

brainfuck, 24 22 bytes

-2 bytes thanks to JoKing.

-[-[-<]>>+<],[>.<.,]>.

Try it online!

Scala, 17 bytes

_.replace("","!")

Try it online!

-3b thanks to Jo King!
Thanks to Dr Y Wit for linking me to the fact that not enforcing typing is allowed, and for the working TIO link.

Triangular, 15 13 bytes

B\3;#*~.,</@<

Try it online!

-2 bytes after remembering that Triangular has a conditional halt operator.

I believe this is as short as it gets on this one. Triangular does have conditional direction-change operators, but they unfortunately work differently than the other conditionals. While all others check if ToS <= 0, the direction-changing conditionals check ToS != 0. If this weren't the case, we would have 10 bytes in the form of Bq3~#*/@<<.

Ungolfed:

    B
   \ 3
  ; # *
 ~ . , <
/ @ <
----------------------------------------------------
B3*              - Push 11 and 3, then pop both and push their product.
    <,<          - Change directions 3 times (to save 2 bytes on last line)
        @/       - Print Top of Stack value as a character, do not pop
          ~;\    - Push a character from input to ToS. Halt if ToS <= 0. Change Direction.
              #  - Print ToS as a character and pop

Previous Version (15 bytes):

B.3\.*#).(/?~@<

Perl 5 -p0, 17 6 bytes

s,,!,g

Try it online!

My original answer was -p and $_='!'.s,.,$&!,gr. Thanks to @Nahuel Fouilleul for cutting 11 bytes and to @Grimy for the -p0 tip.

Python 3, 26 bytes

lambda s:s.replace('','!')

Try it online!

Befunge-98 (PyFunge), 7 bytes

'!,#@~,

Try it online!

MathGolf, 6 bytes

É'!\'!

Try it online!

Explanation

Nothing fancy here, just a loop

É        for each character do the next 3 operations
 '!      push single character "!"
   \     swap top elements
    '!   push single character "!"

Whitespace, 79 bytes

[N
S S N
_Create_Label_LOOP][S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve_input][S N
S _Duplicate_input][S S S T S S T   N
_Push_9_tab][T  S S T   _Subtract][N
T   S S N
_If_0_jump_to_Label_END][S S S T    S S S S T   N
_Push_33_!][T   N
S S _Print_as_character][T  N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP][N
S S S N
_Create_Label_END][S S S T  S S S S T   N
_Push_33_!][T   N
S S _Print_as_character]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Since Whitespace inputs one character at a time, the input should contain a trailing tab (\t) so it knows when to stop reading characters and the input is done.

Try it online (with raw spaces, tabs and new-lines only).

Explanation in pseudo-code:

Start LOOP:
  Character c = STDIN as character
  If(c == '\t'):
    Call function END
  Print '!'
  Print c
  Go to next iteration of loop

function END:
  print '!'

05AB1E, 6 bytes

-1 thanks to Kevin Cruijssen. Takes input as a list of characters.

õ.ø'!ý

Try it online! or Try it online! (with input as a string)

8086 machine code, .COM format (MS-DOS 2+), 32 bytes

(-1 depending on emulator: see below)

For best results redirect standard input from a file, as typing gives odd-looking output due to no buffering; also, newlines look a little weird because they are stored as CR LF, and the CR part messes up the output.

This program behaves fine in an actual MS-DOS emulation (e.g. PCjs) but DOSBox seemed to have issues with Ctrl+Z EOF (see comments in the assembly listing), so DON'T try to enter input using the console in DOSBox unless you add the extra check!

BB 01 00 53 59 BA 0B 01 B4 40 CD 21 4A 4B B4 3F CD 21 85 C0 74 09 B4 40 43 41 CD 21 49 EB EE C3

Some interesting bits:

Assembly code (TASM ideal mode):

IDEAL
MODEL   TINY

CODESEG
ORG 100H

;; DOSBox (tested with 0.74-2) didn't seem to handle Ctrl-Z as EOF
;; so uncomment the ";;" lines to run it there.
MAIN:
    MOV     BX,1
    PUSH    BX
    POP     CX
    MOV     DX,OFFSET MAIN_1+1  ; The 21H in INT 21H
    MOV     AH,40H
MAIN_1:
    INT     21H
    DEC     DX
    ;;PUSH  DX
    ;;POP   SI
IO_LOOP:
    DEC     BX
    MOV     AH,3FH
    INT     21H
    ;;; This should work on an non-emulated PC. 
    ;;;AAA      ; AL=0?
    TEST    AX,AX
    JZ      DONE
    ;;CMP   [BYTE PTR SI],1AH
    ;;JZ    DONE
    MOV     AH,40H
    INC     BX
    INC     CX
    INT     21H
    DEC     CX
    JMP     IO_LOOP
DONE:
    RET
ENDS
END MAIN

05AB1E, 4 bytes

€'!Ć

I/O as a list of characters.

Try it online.

Explanation:

€'!  '# Prepend a "!"-item before each character in the (implicit) input-list
   Ć  # Enclose (append the first character of the list at the end of it)
      # (after which the result is output implicitly)

Aheui (esotope), 61 bytes

붖다따삭바사빠맣삭붛
밙봆@뫃선차희져썬뻐

Try it online!

Nice small aheui code.

J, 12 bytes

'!',,@,.&'!'

Try it online!

Java 8, 20 bytes

A lambda function from String to String.

s->s.replace("","!")

Try It Online

C (gcc), 69 62 50 bytes

Saved 12 bytes, thanks to ErikF's suggestion:

f(char*s){for(printf("!");*s;)printf("%c!",*s++);}

Try it online!

R, 25 bytes

function(x)gsub("","!",x)

Try it online!

A function accepting and returning a character vector.

Labyrinth,  19 11 10  9 bytes

33
..
",@

Try it online!

How?

We enter the Labyrinth at the top-left facing right with an infinite stack of zeros...

                         I / O    stack
                                  0,0,0,...
3 - pop * 10 + 3                  3,0,0,0,...
  - 2 neighbours, forward
3 - pop * 10 + 3                  33,0,0,0,...
  - 2 neighbours, forward
. - pop & print chr          !    0,0,0,...
  - T junction from the side
  -   TOS==0, forward
, - read chr or -1       L        76,0,0,0,...   or   -1,0,0,0
  - T junction from the base
  -   if TOS > 0 right:
" -     no-op                     76,0,0,0,...
  -     2 neighbours, forward
. -     pop & print chr      L    0,0,0,...
  -     T junction from the side
  -       TOS==0, forward
3 -       ...back to the start
  -   elif TOS == -1 left:
@ -     exit                                          we're out!


  * right, but on the first occasion (from above) we hit the wall and turn
    around, so that's like a left

Luckily we don't need to handle un-printables, otherwise the first zero-byte would turn us around at , and play havoc.

QuadR, 1 byte

Thanks to A__ for halving the byte count!

!

Try it online!

Replaces nothing with !

C# (Visual C# Interactive Compiler), 28 bytes

s=>$"!{String.Join("!",s)}!"

Try it online!

Pyth, 8 bytes

+\!s+R\!

Try it online!


     Code | Explanation
----------+-------------------------------------
+\!s+R\!  | Code
+\!s+R\!Q | with implicit variables filled
----------+-------------------------------------
     R  Q | For each d in input, replace d with:
    +R\!  |  d+"!"
   s      | Join results on empty string
+\!       | Add "!" to beginning
          | Print (implicit)

Perl 5 + -p, 11 bytes

s/^|.\K/!/g

Try it online!

Japt, 4 bytes

rP'!

Try it

Japt -P, 7 bytes

Unfortunately ! is a reserved character, necessitating the quotation marks.

ï'! i'!

Try it

Not much to explain: ï is Cartesian product and i prepends.

Japt, 4 bytes

rP'!

Try it

r      Replace
 P     all empty strings "" with
  '!   An exclamation mark (If '!' wasn't a special character in Japt I could remove the quote)

Stax, 6 5 bytes

_z'!R

Run and debug it

Replace "" with "!" using regex replacement. I don't exactly understand why this works.

Edit: Found it in the Ecma spec: 15.5.4.10

If there is a match with an emptystring (in other words, if the value of regexp.lastIndex is left unchanged), increment regexp.lastIndex by 1.

Old Stuff:

I would have been able to get to 5 bytes in either of two scenarios.

  1. If input was provided in an escaped literal e.g. "line1\nline2". But I opted against that for the sake of "usability".
  2. If there was not a bug feature in stax's zip implementation when encountering empty strings/arrays.

Haskell, 18 bytes

('!':).(>>=(:"!"))

-1 byte thanks to @nimi

Try it online!

SNOBOL4 (CSNOBOL4), 94 bytes

I	I =INPUT	:F(END)
S	I LEN(1) . X REM . I	:F(O)
	O ='!' O X	:(S)
O	OUTPUT =O '!'
	O =	:(I)
END

Try it online!

Prints with an additional trailing newline (as SNOBOL always prints a line break). The way input is consumed, there is no way of distinguishing between a final line ending in \n or not.

Jelly, 5 bytes

Ż”!ṁż

A full program accepting a string, which prints the result.

Try it online!

How?

Ż”!ṁż - Main Link: list of characters, s   e.g. "abc"
 ”!   - character '!'                           '!'
   ṁ  - mould like:
Ż     -   s with a zero prepended              "!!!!"
    ż - zip together with s                    ["!a","!b","!c",'!']
      - implicit (smashing) print              !a!b!c!

Python 2, 27 bytes

lambda s:'!%s!'%'!'.join(s)

Try it online!

Pepe, 47 bytes

REREEeRErEErREeeEeeeeEREEeeREEeereeREEEEeeEReee

Try it online!

Explanation:

REREEeRE # Push 0,then input (str),then 0 -> (R)
         # The zeroes are pushed to correct the inserting
rEE # Begin loop labelled 0 -> (r)
  rREeeEeeeeE # Push "!" -> (R)
              # r flag inserts it instead of pushing
  REEeeREEee # Move pointer pos 2 steps forward -> (R)
ree # Loop while (R) != 0
REEEEeeE # Remove characters of (R) that are in stack of (r)
         # Removes the 0 in (R)
Reee # Output (R)

Python 3, 27 bytes

lambda s:f"!{'!'.join(s)}!"

Try it online!

Honestly, I hope someone can show me a cool way to do this with a smaller byte count.

Gema, 11 characters

\A=\!
?=?\!

Unfortunately ! starts a comment in Gema, so must be escaped.

Sample run:

bash-5.0$ echo -ne '1 2 3 4 5 6\n129591 129012 129127 129582\n\n0' | gema '\A=\!;?=?\!'
!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!

Try it online!

Charcoal, 6 bytes

⭆S⁺!ι!

Try it online! Link is to verbose version of code. Works on empty strings too. Input format is somewhat cumbersome due to Charcoal's lack of EOF. Works by preceding each character with a ! and then suffixing a final ! on the end. Alternative version, also 6 bytes:

⪫!!⪫S!

Try it online! Link is to verbose version of code. Works by joining the characters on ! and then wrapping them in !!.

Retina 0.8.2, 2 bytes


!

Try it online! At last, a challenge where Retina has a built-in!