| Bytes | Lang | Time | Link |
|---|---|---|---|
| 774 | Marbles | 230610T115026Z | Vincent |
| nan | 230531T052937Z | Dadsdy | |
| 042 | C | 230609T032900Z | Zoey |
| 025 | Rust | 230607T182931Z | JSorngar |
| 005 | Thunno 2 | 230607T164859Z | The Thon |
| 018 | ><> Fish | 230603T211601Z | chunes |
| 029 | Python 3 | 230531T054741Z | Dadsdy |
| 067 | Rockstar | 230530T160206Z | Shaggy |
| 030 | Python | 230529T090046Z | The Empt |
| 011 | AWK | 230529T061517Z | RARE Kpo |
| 012 | ARM Thumb machine code | 221026T202509Z | EasyasPi |
| 080 | Python 3 | 221025T134335Z | Mr.McNug |
| 011 | BQN | 221024T221640Z | DLosc |
| 011 | APL Dyalog Unicode | 221024T173445Z | Seggan |
| 028 | Factor | 221003T225020Z | chunes |
| 039 | C gcc | 190819T233402Z | att |
| 016 | Wolfram Language Mathematica | 190819T235114Z | att |
| 044 | Excel | 221003T202231Z | Engineer |
| nan | 221003T201247Z | bigyihsu | |
| 012 | K ngn/k | 210212T162022Z | coltim |
| 023 | Zsh | 190818T113857Z | GammaFun |
| 011 | Subleq 8bit | 210511T120846Z | Axuary |
| 013 | BRASCA | 210511T122031Z | SjoerdPe |
| 019 | Julia | 210419T143638Z | MarcMush |
| 011 | AWK | 210511T102550Z | cnamejj |
| 004 | Vyxal | 210511T035348Z | Undersla |
| 013 | Vim | 210419T141918Z | Aaroneou |
| 011 | Branch | 210418T041239Z | hyper-ne |
| 011 | Hexagony | 201101T012919Z | Undersla |
| 012 | Zsh | 210214T155842Z | pxeger |
| 008 | x8616 machine code | 210212T211408Z | 640KB |
| 005 | Pip | 210212T130932Z | Razetime |
| 008 | Husk | 201031T230240Z | LegionMa |
| 019 | 1+ | 200812T055912Z | Twilight |
| 018 | MAWP | 200812T051851Z | Razetime |
| 142 | C# | 190819T182519Z | canttalk |
| 027 | Javascript | 191225T030735Z | dhilln |
| 009 | Pushy | 191224T200509Z | FlipTack |
| 008 | Keg | 190820T110105Z | lyxal |
| 031 | PHP 7.4 | 190819T100134Z | Night2 |
| 072 | VBA | 190819T181407Z | Ben |
| 039 | Forth gforth | 190819T145628Z | reffu |
| 054 | BrainFlak | 190913T091629Z | Dorian |
| 047 | Red | 190913T075214Z | Galen Iv |
| 032 | C gcc | 190822T121618Z | jdt |
| 050 | Kotlin | 190911T133351Z | pappbenc |
| 031 | Lua | 190826T201828Z | lqdev |
| 012 | Ahead | 190824T053820Z | snail_ |
| 019 | JavaScript ES6 | 190818T104301Z | Arnauld |
| 032 | Elvish | 190822T115249Z | kon |
| 011 | Perl 6 | 190818T143110Z | Jo King |
| 069 | MarioLANG | 190820T201045Z | squid |
| 010 | Brachylog | 190820T211610Z | Unrelate |
| 016 | Ruby | 190819T081845Z | G B |
| 042 | Wolfram Language Mathematica | 190819T044231Z | Kai |
| 036 | Bash | 190819T172132Z | spuck |
| 021 | PowerShell | 190820T150556Z | AdmBorkB |
| 012 | sed | 190819T145558Z | Jonah |
| 023 | SimpleTemplate | 190819T102356Z | Ismael M |
| 075 | PHP | 190819T144356Z | ShiSHcat |
| 006 | ><> | 190819T075418Z | Sok |
| 026 | Python 3 | 190820T071345Z | U13-Forw |
| 1213 | 6502 | 190819T203444Z | lee |
| 041 | Emacs Lisp | 190819T181319Z | Jordon B |
| 022 | brainfuck | 190818T145505Z | Kamila S |
| 017 | Scala | 190819T081539Z | V. Court |
| 013 | Triangular | 190818T173114Z | squid |
| 006 | Perl 5 p0 | 190818T123108Z | Kjetil S |
| 026 | Python 3 | 190819T123410Z | waterbyt |
| 007 | Befunge98 PyFunge | 190819T094019Z | Cinaski |
| 006 | MathGolf | 190819T084050Z | maxb |
| 079 | Whitespace | 190819T084002Z | Kevin Cr |
| 006 | 05AB1E | 190818T111143Z | Mr. Xcod |
| 032 | 8086 machine code | 190819T073056Z | ErikF |
| 004 | 05AB1E | 190819T072836Z | Kevin Cr |
| 061 | Aheui esotope | 190819T072114Z | LegenDUS |
| 012 | J | 190819T021655Z | Jonah |
| 020 | Java 8 | 190819T014909Z | Jakob |
| 050 | C gcc | 190818T230119Z | WarmTaun |
| 025 | R | 190819T000054Z | Nick Ken |
| 009 | Labyrinth | 190818T153214Z | Jonathan |
| 001 | QuadR | 190818T185952Z | Adá |
| 028 | C# Visual C# Interactive Compiler | 190818T183847Z | dana |
| 008 | Pyth | 190818T185002Z | hakr14 |
| 011 | Perl 5 + p | 190818T184053Z | Dom Hast |
| 004 | Japt | 190818T104341Z | Shaggy |
| 004 | Japt | 190818T174518Z | Gymhgy |
| 005 | Stax | 190818T143911Z | recursiv |
| 018 | Haskell | 190818T123821Z | pommicke |
| 094 | SNOBOL4 CSNOBOL4 | 190818T143813Z | Giuseppe |
| 005 | Jelly | 190818T121311Z | Jonathan |
| 027 | Python 2 | 190818T125149Z | Jonathan |
| 047 | Pepe | 190818T123756Z | u-ndefin |
| 027 | Python 3 | 190818T120909Z | squid |
| 011 | Gema | 190818T115107Z | manatwor |
| 006 | Charcoal | 190818T111129Z | Neil |
| 002 | Retina 0.8.2 | 190818T110155Z | Neil |
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
((),()()()()()()()())((),(())(())(())(())())(,,,(()()),(,(()(),((()()())),,(())))(()()),())
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);
}
Thunno 2, 5 bytes
""'!v
Thunno 2, 6 bytes
'!j'!ṛ
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
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
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:
(∾⊢∾∾¨)⟜'!'
APL (Dyalog Unicode), 11 bytes
(∊⊢⍪⍪¨)∘'!'
@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
{'!'⍪∊⍉↑⍵('!'⍴⍨≢⍵)}
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]]
33 interleavedInsert an exclamation point between each character of the input.[I !${}!I]Interpolate the above string into the${}, adding exclamation points to the beginning and end, and print.
Wolfram Language (Mathematica), 26 16 bytes
"!"<>#&/@#<>"!"&
Input a list of characters. Returns a string.
Excel, 44 bytes
="!"&CONCAT(MID(A1,SEQUENCE(LEN(A1)),1)&"!")
"!"is just the first!.CONCAT(MID(A1,SEQUENCE(LEN(A1)),1)&"!")SEQUENCE(LEN(A1))creates an array1, 2, ... XwhereXis the length of the input.MID(A1,SEQUENCE(~),1)pulls the nth character from the input.MID(~)&"!"adds!after every one of those characters.CONCAT(MID(~)&"!")combines all those nth character +!into one string.
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)}
K (ngn/k), 13 12 bytes
-1 byte from @ngn's savings
{x,/y,'x}"!"
Creates a function projection, with x fixed to "!".
y,'xpair-wise append an exclamation mark to each character in the inputx,/flatten the list, using "!" as the seed (to prepend the leading "!")
Subleq (8-bit), 1211 bytes
-1 byte for removing last 0
2 -1 33
-1 8 -1
8 -1 0
8 8
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
Explanation
, - Reverse stack
![$ {] - Loop stack length:
'!oo - Print "!" followed by the next letter
'!o - Print the last "!"
AWK, 11 bytes
gsub(a,"!")
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 "".
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.
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;,<
$ > P
. . . @
1 ; , < .
. . . .
. . .
P1in place of33so that it resets the memory.- MP is stationary
(old) Hexagony, 17 bytes
{33...@;",<./{;/>
{ 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
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:
1+, 20 19 bytes
1##11"+""*"**+;,;1#
1+ 19 vs 18 MAWP
Error-terminating because comparison is expensive.
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"
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
Answer History
9 bytes
?^(\!')\!
Pretty much a port of the MathGolf submission.
PHP (7.4), 31 bytes
Based on Petah's comment.
fn($s)=>preg_replace(__,'!',$s)
PHP, 52 bytes
function($s){return'!'.join('!',str_split($s)).'!';}
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 ;
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
(()){({}<>)((((()()()()){}){}){}())<>}<>{({}<>)<>}<>{}
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
Kotlin, 50 bytes
fun f(s:String)=s.map{"!$it"}.joinToString("")+"!"
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("","!")))
JavaScript (ES6), 19 bytes
Takes input as an array of characters.
s=>`!${s.join`!`}!`
JavaScript (ES6), 23 20 bytes
Saved 3 bytes thanks to @ShieruAsakoto
Takes input as a string.
s=>[,...s,,].join`!`
JavaScript (ES6), 22 bytes
Suggested by @tjjfvi
Takes input as a string.
s=>s.replace(/|/g,"!")
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/<(/!/}
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
++++++
======< >)
>+++++++",+[
=======<.==<
>+++++++!(.-
========#===
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⊥
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.
Wolfram Language (Mathematica), 49 48 42 bytes
#~StringSplit~""~StringRiffle~{a="!",a,a}&
-6 bytes thanks to @attinat
Bash, 36 bytes
while read -n1 c;do printf \!$c;done
This counts on the newline terminating the input for the last ! mark.
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:
!- Prints the literal!character{@each argv.0 as char}- Loops through every character, with the value set to the variablechar(optional, the default variable is_).
argv.0is the first parameter passed to therender()method of the compiler.{@echo char}!- outputs thecharvariable and a literal!character.
For the golfed version, the default variable_is used instead.{@/}- closes the loop (optional)
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"!";
PHP, 100 bytes
foreach(explode("\n",file_get_contents('php://stdin'))as$e)echo'!'.implode("!",str_split($e))."!\n";
PHP, 117 bytes
foreach(explode("\n",file_get_contents('php://stdin'))as$e){echo'!';foreach(str_split($e)as$c)echo $c."!";echo "\n";}
><>, 11 6 bytes
"!"oio
Saved 5 bytes thanks to Jo King, suggesting exiting with an error. Previous version which does not exit with an error:
"!"oi:0(?;o
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
Scala, 17 bytes
_.replace("","!")
-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;#*~.,</@<
-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
My original answer was -p and $_='!'.s,.,$&!,gr. Thanks to @Nahuel Fouilleul for cutting 11 bytes and to @Grimy for the -p0 tip.
MathGolf, 6 bytes
É'!\'!
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 '!'
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:
I saved some data space by reusing memory that had already been executed (the
21HinINT 21Hhappens to be!)I was almost able to use an interesting trick that I found on the page "The Hidden Power of BCD Instructions" which would have allowed me to use
AAAinstead of a standardTESTto compareALto 0, saving one byte. Unfortunately, this is not fully documented so I couldn't rely on it: for example, PCjs doesn't adjust anything but the carry and auxiliary carry flags. :-(
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.
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)
C (gcc), 69 62 50 bytes
Saved 12 bytes, thanks to ErikF's suggestion:
f(char*s){for(printf("!");*s;)printf("%c!",*s++);}
Labyrinth, 19 11 10 9 bytes
33
..
",@
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.
Pyth, 8 bytes
+\!s+R\!
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)
Japt, 4 bytes
rP'!
Japt -P, 7 bytes
Unfortunately ! is a reserved character, necessitating the quotation marks.
ï'! i'!
Not much to explain: ï is Cartesian product and i prepends.
Japt, 4 bytes
rP'!
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
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.
- If input was provided in an escaped literal e.g.
"line1\nline2". But I opted against that for the sake of "usability". - If there was not a
bugfeature in stax's zip implementation when encountering empty strings/arrays.
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
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.
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!
Pepe, 47 bytes
REREEeRErEErREeeEeeeeEREEeeREEeereeREEEEeeEReee
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)}!"
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!
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 !!.



