| Bytes | Lang | Time | Link |
|---|---|---|---|
| 418 | Malbolge Unshackled | 250811T095933Z | Weird Gl |
| 025 | Vyxal 3 | 250811T122833Z | Themooni |
| 053 | AWK | 250807T152002Z | xrs |
| 266 | BrainFlak c | 170414T192408Z | Wheat Wi |
| 083 | nroff | 221019T121033Z | 鳴神裁四点一号 |
| 034 | Carrot | 170414T154156Z | user4180 |
| 064 | Aceto | 170419T091817Z | L3viatha |
| 181 | Brainfuck | 190422T190513Z | Lucca Fe |
| 061 | TSQL | 190520T200652Z | BradC |
| 056 | Scala | 190520T180952Z | pme |
| 063 | Haskell | 190426T144931Z | Max Yekh |
| 078 | cgcc | 190423T122857Z | jdt |
| 085 | C gcc | 170414T180500Z | cleblanc |
| 041 | Retina 0.8.2 | 170414T151742Z | Riley |
| 229 | Whitespace | 190418T142231Z | Kevin Cr |
| 054 | Excel Formula | 190418T124634Z | i_saw_dr |
| 025 | 05AB1E | 190418T123124Z | Kevin Cr |
| 114 | brainfuck | 180416T232424Z | Jo King |
| 016 | SOGL V0.12 | 170414T155939Z | dzaima |
| 066 | Excel VBA | 170416T140352Z | Taylor R |
| 063 | Ruby | 171229T230157Z | Håv |
| 016 | Charcoal | 170414T145408Z | user4180 |
| 140 | BF | 170415T013302Z | Esolangi |
| 053 | Python 3.6 | 170414T152624Z | Jonathan |
| 058 | ><> | 170523T042445Z | Not a tr |
| 088 | Swift | 170414T160551Z | Mr. Xcod |
| 073 | Common Lisp | 170513T191158Z | user6516 |
| 052 | Alice | 170414T231817Z | Martin E |
| 036 | Pyth | 170503T064831Z | Leaky Nu |
| 049 | C | 170419T090427Z | Khaled.K |
| 079 | Java 7 | 170419T072959Z | Kevin Cr |
| 060 | JS ES6 | 170417T204309Z | user6827 |
| 140 | C# | 170416T090851Z | Adola |
| 031 | Vim | 170416T061910Z | Brian Mc |
| 084 | C gcc | 170415T215749Z | Ian M. |
| 087 | Cgcc | 170415T204908Z | Jake Rey |
| nan | 170415T150632Z | auhmaan | |
| 055 | JavaScript ES6 | 170414T145542Z | ETHprodu |
| 208 | C++ | 170414T175418Z | takintoo |
| 065 | [R] | 170415T030707Z | user1159 |
| 035 | Japt | 170414T210257Z | Oliver |
| 050 | Bash | 170414T201912Z | Max Mikh |
| 041 | Retina | 170414T191937Z | Dennis |
| 066 | Lua | 170414T182055Z | Blab |
| 051 | PHP | 170414T154242Z | Jör |
| 022 | Jelly | 170414T145521Z | Jonathan |
| 047 | JavaScript ES6 | 170414T145845Z | Shaggy |
| 026 | 05AB1E | 170414T145728Z | Magic Oc |
| 048 | PowerShell | 170414T144747Z | AdmBorkB |
| 043 | Sed | 170414T151306Z | manatwor |
| 059 | Python | 170414T151033Z | Riker |
| 032 | 05AB1E | 170414T144328Z | Emigna |
| 046 | Röda | 170414T150136Z | fergusq |
| 062 | Python 2 | 170414T144320Z | Dead Pos |
| 070 | SpecBAS | 170414T144904Z | Brian |
| 076 | Batch | 170414T144327Z | Neil |
Malbolge Unshackled, 418 bytes
(aBA@?>=<;:9876543210/.-,+*)('&%$dc!-}=Nz:x77$G"rqp|/.lkjiha`_H6ba`_X]V?-SRWVUTS6Q4I!MLKDzHGFED'B;_^o=<;:{8765.uc1*NM^,m*)('hg$#"cxP|{z]r8IutmEqponmPkd*;KJedcbaZC1]\[ZS<;u(TSRQPONG0|JIHGFE>ba%q?>!<}:981g54321r/(onJ[)('h}U#"!bw=N^yxwvutmVDponmfON*;gfedcbaZC1]\[ZYXQut8rq$4O2MLKDzHGFED'B;$#]n<;:{2h654u,Paq.-,+*#jX&%|BdcQ}|{zyxwvoXFrqponmf,+*):f_H6baZ~BA/[Z=R*VUT7L5o"NG}KJIHG*E>'ar@?>=<;|9876/vd2+rNMLK\*)('h%|eS!~}|u;(
This challenge uses two equations in order to print the egg:
crazy(crazy(x,0t1111111111...),0t1111111111...) = x, which is useful in order to save a value on the tape, in this case the painted character.
crazy(0t2222222222...,crazy(0t2222222222...,x)) = x, which is useful in order to retrieve a value from the tape.
0t1111111111... can be obtained with one or two crazyops, and since this challenge only has one character as input, 0t2222222222... can be obtained by retrieving the EOF from the input.
After that, the rest of the code is just printing the egg. Nothing special about it. Here's the normalized code:
jiooooooo
ooooooooo
ooooooooo
oooooo**o
vo</o<oi<
v/vooov<<
ooooo <- Data section
pppj <- Code section
/oooopopj
/ppoooooj
ojp/ooop/
ooooojop<
</oooojoo
oopj/op<<
/ojoooojj
ooojp/ooo
jp</oop/o
oooojop</
jjooooopj
/oooopjj<
/ooooooop
j/oooooop
<<j/oojoj
ooop/oooo
ojopjj</o
oojp/oooj
p</jooooo
opj/oooop
jj</ooooo
oopj/oooo
oop<<j<</
jojooop/o
oooojopjj
</ooojp/o
oojp</joo
ooopj/oop
<jj/ooooo
ooopj/ooo
ooop<<<</
opj/oop<j
j/oojp/oo
ojpj</op/
ooooojopj
</ooooooj
oooopj/op
j<<<</ooo
ojopj/ooo
op<v
Vyxal 3, 25 bytes
"⎂②lᑂ▦⎇⎇c▦↯∨“"_ \n/\|"?+⊢
"⎂②lᑂ▦⎇⎇c▦↯∨“"_ \n/\|"?+⊢
"⎂②lᑂ▦⎇⎇c▦↯∨“ # compressed integer
⊢ # to base
"_ \n/\|" # literal string
?+ # with input added at the end
💎
Created with the help of Luminespire.
<script type="vyxal3">
"⎂②lᑂ▦⎇⎇c▦↯∨“"_ \n/\|"?+⊢ ¶p
</script>
<script>
args=[["_"],["%"],["~"],["&"],["#"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
Brain-Flak -c, 270 268 266 bytes
(((((((((({}<(((([(()()())]((((((((((({}){}){}){}){}[()]))<>)<>{}())))))<>)<>(((()()()()()){}))({}()){})<>)<>>))))<<>({}<>)((()()()()()){})<>({}<>)>))))<<>((({})<>)({})<((()()()()()){})>[()()])>))<>((((({})<>)[(()()()()())({}){}])<((()()()()()){})<>((({}<>){}()))>))
I was going to write an explanation, but I took a nap first and forgot how this whole thing works. Your guess is as good as mine.
nroff, 83 bytes
I found a way to outgolf to get a verbatim output so I could draw ascii art with fewer bytes: it was to use .nf.
.de F
__
.nf
/\\$1\\$1\\\\
/\\$1\\$1\\$1\\$1\\\\
|\\$1\\$1\\$1\\$1|
\\\\____/
..
nroff, 103 bytes
.de F
__
.sp 0
/\\$1\\$1\\\\
.sp 0
/\\$1\\$1\\$1\\$1\\\\
.sp 0
|\\$1\\$1\\$1\\$1|
.sp 0
\\\\____/
..
I tried using more macros to shorten but failed. I had to do such annoying escaping a lot.
Usage
.F #
.F %
Carrot, 34 bytes
__
/##\\
/####\\
|####|
\\____/
Try it online here.
First, we are in caret-mode, where every character gets pushed to the "stack". And finally the "stack" gets printed as output.
In caret-mode, # pushes the input, so the instances of # are basically replaced with the input (FYI # is a one-byte cat program).
Aceto, 68 64 bytes
8 by 8, so a 3rd order Hilbert curve.
/"ppp(pp
np(p"pp)
\\)p|n
"\"\\\
)k,p\\n"
pp/"__\|
n__
"__\/"p
Since we're already non-competing, I used features introduced after the question was posted.
Output:
__
/==\
/====\
|====|
\____/
Brainfuck - 257 bytes 181 bytes
Golfed: Live version click here
+++++++[>++++++<-]>[>+>++>++>++<<<<-]>+++++>>>>++++++++++[>+++>+<<<++++<+<+>>>-]>++<<<--<+>>>,>..<<<<..>>>>>.<.<<<<<.>>>>..<<.>>>>.<<<<<<.>>>>....<<.>>>>.<<<.>....<.>>>.<<<<.<....<.
I'm not a professional golfer though; this is my first attempt.
Output:
__
/XX\
/XXXX\
|XXXX|
\____/ where X is the given char.
Ungolfed ( + comments) :
; chars:
; _ 95
; / 47
; \ 92
; | 142
; min val = 42 (7 times 6)
; lets do some math
+++++++[>++++++<-]> ; effectively 7 times 6
; now lets copy this to the next pointers multiplying by 2
the subsequent ones after the 1st
[>+>++>++>++<<<<-]
>+++++
>>>
> ; empty space starting from this pointer
++++++++++[>+++>+<<<++++<+<+>>>-]
>++<
<<--<+
>>>,
>..<<<<..>>>>>.<.
<<<<<.
>>>>..<<.>>>>.
<<<<<<.>>>>....<<.>>>>.
<<<.>....<.
>>>.<<<<.<....<.
T-SQL, 63 61 bytes
SELECT REPLACE(' __
/11\
/1111\
|1111|
\____/',1,v)FROM t
Old challenge, but didn't see a SQL solution.
Input is taken via pre-existing table t with text field v, per our IO standards.
SQL allows line break literals in strings, so a pretty straight-forward replace. Lines 2 and 3 have an extra space after the final \, so the line break isn't escaped.
EDIT: Discovered that I can save 2 bytes by using a numeral as the replacement character instead of something like '.' that needs quotes. Turns out REPLACE does the implicit conversion to string.
Haskell, 70 63 bytes
7 bytes down with great help from Laikoni
(<$>" __\n /~~\\\n/~~~~\\\n|~~~~|\n\\____/").(?)
d?'~'=d
d?c=c
The function f takes a character to paint the egg with.
c(gcc) 81 78 bytes
*s;f(c){for(s=LR"( __
/00\
/0000\
|0000|
\____/)";*s;s++)printf(*s%6?s:&c);}
C (gcc), 95 88 85 bytes
Thanks to Albert for -7 bytes
Thanks also to ceilingcat -3 bytes
f(c){for(int*s=L" __\n /00\\\n/0000\\\n|0000|\n\\____/\n";*s;s+=printf(*s%6?s:&c));}
Retina 0.8.2, 43 41 bytes
-2 bytes thanks to Kevin Cruijssen
.
$&$&
..
__¶ /$&\¶/$&$&\¶|$&$&|¶\____/
Whitespace, 240 229 bytes
[S S S T S T T T T N
_Push_47][S S S T S T T T T T N
_Push_95][S N
S _Duplicate_95][S N
S _Duplicate_95][S N
S _Duplicate_95][S S S T S T T T S S N
_Push_92][S S S T S T S N
_Push_10][S S S T T T T T S S N
_Push_124][S T S S T S N
_Copy_0-based_2nd_(92)][S N
S _Duplicate_92][T N
T S _Read_STDIN_as_character][T T T _Retrieve][S N
S _Duplicate_input][S N
S _Duplicate_input][S N
S _Duplicate_input][S S S T T T T T S S N
_Push_124][S S S T S T S N
_Push_10][S T S S T S S S N
_copy_0-based_8th_(92)][S N
S _Duplicate_92][T T T _Retrieve][S N
S _Duplicate_input][S N
S _Duplicate_input][S N
S _Duplicate_input][S S S T S T T T T N
_Push_47][S S S T S T S N
_Push_10][S S S T S T T T S S N
_Push_92][S N
S _Duplicate_92][T T T _Retrieve][S N
S _Duplicate_input][S T S S T S S N
_Copy-0-based-4th-(47)][S S S T S S S S S N
_Push_32][S S S T S T S N
_Push_10][S S S T S T T T T T N
_Push_95][S N
S _Duplicate_95][S T S S T T N
_Copy-0-based-3rd-(32)][S N
S _Duplicate_32][N
S S N
_Create_Label_LOOP][T N
S S _Print_as_character][N
S N
N
_Jump_to_Label_LOOP]
Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.
Explanation:
Since we have to incorporate the input character in the output, I couldn't apply this Whitespace tip of mine which I always use for ASCII-art or other print challenges in Whitespace, which would lower each value and inside the printing loop add it again. So instead this is a pretty simple program which does the following:
- Push all characters reversed to the stack, including the input-characters
- With bytes saved using Duplicates and Copy's-of
- Then loop and print the characters from the top of the stack to the bottom (which is why we push the characters in reverse order).
Excel Formula, 54 bytes
Makes use of multi-line entry in the formula bar (Alt+Enter), where # is your chosen character to paint!
=SUBSTITUTE(" __
/~~\
/~~~~\
|~~~~|
\____/","~","#")
05AB1E, 25 bytes
"ÿ_
\/|"•θ8Ë1Âõ]ư•6вèJ.c
Explanation:
"ÿ_
\/|" # Push the string "ÿ\n\/|", where `ÿ` is automatically filled
# with the (implicit) input-character
•θ8Ë1Âõ]ư• # Push compressed integer 1269961759550053939510
6в # Converted to Base-6 as list:
# [1,1,2,4,0,0,3,2,4,0,0,0,0,3,2,5,0,0,0,0,5,2,3,1,1,1,1,4]
èJ # Index each into the string, and then join together
.c # And centralize it to add the appropriate leading spaces
# (after which the result is output implicitly)
See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •θ8Ë1Âõ]ư• is 1269961759550053939510 and •θ8Ë1Âõ]ư•6в is [1,1,2,4,0,0,3,2,4,0,0,0,0,3,2,5,0,0,0,0,5,2,3,1,1,1,1,4].
brainfuck, 114 bytes
-----[[<+>->++>++<<]->]<+++++++++++<+..<..>>.<.<<.>>,..<---.>>.<<<.>>....<.>>.<<<<---.>>>....<<<.>>>>.<<.+++....<.
I've used BF Crunch here to find a more optimal way to generate the individual characters.
SOGL V0.12, 21 18 16 bytes
0≈⁾‛≤¦¶W?5┼EB§ ‘
The whole program is the following compressed:
__
/ŗŗ\
/ŗŗŗŗ\
|ŗŗŗŗ|
\____/
where ŗ gets replaced with the input.
13 bytes almost works too, but it does unneeded things with certain inputs..
Excel VBA, 66 Bytes
Anonymous Excel VBE immediates window function that takes a clean input of 1 character from cell [A1] on the ActiveSheet object and prints to the VBE immediate window.
?Replace(Replace(" __0 /11\0/1111\0|1111|0\____/",0,vbCr),1,[A1])
Ruby, 63 bytes
puts" __ \n /00\\ \n/0000\\\n|0000|\n\\____/".gsub"0",$*[0]
As basic as it gets, honestly
Charcoal, 30 26 16 bytes
Two bytes saved thanks to @Neil by filling after making the shape
__↗¹←↑¹↖²↓_‖M←¤S
Explanation
The program works by first creating the right half of the egg, and then reflecting it to generate the left half.
__↗¹ Write the two bottom _s and write the /
←↑¹ Move left and write the |
↖² Then write two \s
↓_ And the top _
‖M← Reflect the canvas to the left
¤S Fill the shape with the string input
BF, 142 140 bytes
++++[->++++<]>[->+++>++++++>+>++++++>++>++++++++<<<<<<],>->---->------>->..<..<.>>.<<<<.<..
>>.>.<<.<....>>.>.>>>----.<....>.<<<.<.>>....<<<.
This is split across two lines for clarity; the newline is not counted.
It's fairly easy to write this sort of thing in BF, but it's non-trivial how to optimize the order of the cells to minimize movement. I wrote a brute-forcer script to try all the combinations and find the shortest, and I golfed it a bit to account for a golfing opportunity I hadn't included in the brute-forcer.
Python 3.6, 53 bytes
lambda x:fr''' __
/{2*x}\
/{4*x}\
|{4*x}|
\____/'''
- Unnamed function taking the character
xand returning a string. - Uses Python 3.6's f-strings as an added alternative to earlier version's
.format()- the{}enclosed parts of the f-string are code to be evaluated. - The string is also an r-string and triple quoted saving one byte over:
lambda x:f' __\n /{2*x}\\\n/{4*x}\\\n|{4*x}|\n\____/'
I can't see an online interpreter for Python 3.6 though.
Try it at repl.it (says 3.5 but it is 3.6)
><>, 58 bytes
|v" __ /":{"\ /"}::::{"\|"}::::i"|\____/"
o>ooooool?!;a
Try it online, or at the fish playground!
Takes input from STDIN. If you're allowed to exit with an error, you can get rid of the l?!; in the second line.
Explanation: The fish swims through the first line backwards, so it reads "/____\|"i::::}"|\"{::::}"/ \"{:"/ __ ". This builds up the string in reverse, keeping a copy of the input at the back of the stack for when it's needed again. The fish then gets to row 2, which prints six characters and a newline and then loops until the stack is empty.
Swift - 88 bytes
var f={x in" __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/".replacingOccurrences(of:"&",with:x)}
Lambda-like function with usage: print(f("x")).
NOTE: In some environments, as in the one linked above, this requires import Foundation, but on a standard project it doesn't. That's because replacingOccurrences() belongs to Foundation, but Xcode projects have that optimised, and is not required.
Common Lisp, SBCL, 73 bytes
(format t" __
/~@?\\
/~@?~@?\\
|~@?~@?|
\\____/""~2@{~a~:*~}~@*"(read))
Alice, 53 52 bytes, non-competing
Thanks to Leo for indirectly saving 1 byte.
/o *^i}'.*[;.h~r}}~"{.[^\\
@"S .^~ y~a}~~.["{!~"}^^^
Unfortunately, I had to fix a bug with y (transliteration) to make this work, so I've marked it as non-competing.
Explanation
The basic idea is to create a string of the egg but with ~ as a placeholder for two copies of the input. However, the other characters of the input aren't particularly friendly for Alice strings, because those can't contain linefeeds, and all of /\_| would need escaping (because they're treated as mirrors and walls). So I can save some bytes by using placeholders for these as well, and then transliterating them. The placeholders for /\_| are .[^{, which are simply the character right before the one they represent. For the linefeed I'm using }.
Now the code... the entire program can be solved in Ordinal mode since we only need string processing and no processing of integers. Furthermore, we don't need any conditional control flow. The entire program can be expressed linearly. The general structure of the program is this:
/...//
@....
In such a program, the IP bounces up and down through the ... section, first only executing half of the characters. Then the two / at the end move the IP right by one cell, so that on the way back it executes the other half (again bouncing up and down) until finally the @ terminates the program. So if we unfold the funny zigzag structure in the middle, the program we're executing really looks like this:
" ^^} .~[}.~~[}{~~{}[^^^^.""!}"r.h~;a*y'~i.*So
Let's go through this:
" ^^} .~[}.~~[}{~~{}[^^^^."
This first string is simply the egg template I've talked about.
"!}" Push this string. It covers all the characters we need to replace
in the template except ~.
r Range expansion. Turns '!}' into '!"#$...z{|}'.
. Duplicate.
h~; Split off the first character, swap it to the top and discard it.
a* Append a linefeed.
We've now basically rotated the string to the left, but appended
a linefeed instead of the exclamation mark we've shifted off.
This maps each character in the string to the next one, except }
which gets mapped to a linefeed.
y Transliterate. Since the strings have the same length, this just maps
each character in the first string to the corresponding character in
the second string, replacing all of our placeholder characters.
'~ Push "~".
i.* Read the input and duplicate it.
S Substitute all "~" with the doubled input.
o Output the result.
C, 49 bytes
f(){puts(" __\n /~~\\n/~~~~\\n|~~~~|\n\____/");}
Output Live
__
/~~\
/~~~~\
|~~~~|
\____/
Unicode, 77 bytes
g(){printf(" .\u2322.\n\n\u239bHAPPY\u239e\n EASTER\n\u239d.___.\u23a0\n");}
Output
.⌢.
⎛HAPPY⎞
EASTER
⎝.___.⎠
Java 7, 79 bytes
String f(String c){return" __\n /x\\\n/xx\\\n|xx|\n\\____/".replace("x",c+c);}
Explanation:
String f(String c){ // Method with String(-character) parameter and String return-type
return " __\n /x\\\n/xx\\\n|xx|\n\\____/" // Return this String
.replace("x",c+c); // And replace every 'x' with two times the input String-character
} // End of method
Test code:
class Main{
static String f(String c){return" __\n /x\\\n/xx\\\n|xx|\n\\____/".replace("x",c+c);}
public static void main(String[] a){
System.out.println(f("^"));
System.out.println(f("|"));
System.out.println(f("o"));
}
}
Output:
__
/^^\
/^^^^\
|^^^^|
\____/
__
/||\
/||||\
||||||
\____/
__
/oo\
/oooo\
|oooo|
\____/
JS (ES6), 60 bytes
x=>` __
/~\\
/~~\\
|~~|
\\____/`.replace(/~/g,x.repeat(2))
Basically the same thing as the python answer.
C#, 140 Bytes
class x{static void Main(){System.Console.WriteLine((" __\n"+@" /%%\"+'\n' +@"/%%%%\"+'\n'+@"|%%%%|"+'\n' +@"\____/ ").Replace("%","A"));}}
It's my first time codegolfing :) Anyway, this works by replacing '%' from the example to any character you want. This prints out:
__
/AA\
/AAAA\
|AAAA|
\____/
Vim, 31 bytes
Expects the input character to be the only thing in the buffer to start. Ends in insert mode with the egg displayed in the buffer. I have replaced ^M and ^O with <CR> and <C-O> for readability. All whitespace is significant.
s __<CR> /<C-O>2p\<CR>/<C-O>4p\<CR>|<C-O>4p|<CR>\____/
Since V is backwards-compatible, you can Try it online!
Explanation:
s " Delete input (storing it to the default register) and enter insert mode
__<CR> " Type " --\n"
/ " Type " /"
<C-O>2p " Paste twice from the default register without leaving insert mode (e.g. put "%%")
\<CR> " Type "\\\n"
/ " Type "/"
<C-O>4p " This time paste 4 times
\<CR> " Type "\<CR>"
|<C-O>4p|<CR> " Same drill, but with | before and after
\____/ " The bottom of the egg
C (gcc), 84 bytes
g(f){char e[]={f,f,f,f};printf(" __\n /%.2s\\\n/%.4s\\\n|%.4s|\n\\____/\n",e,e,e);}
C(gcc), 87 bytes
e(d){printf(" __\n /%c%c\\\n/%c%c%c%c\\\n|%c%c%c%c|\n\\____/\n",d,d,d,d,d,d,d,d,d,d);}
printf without stdio.h causes warnings but no errors, allowing successful compilation.
Explanation
Printf statement that crams everything into one line, formatting the decoration character with %c.
C#, 56 bytes
Golfed
i=>" __\n /i\\\n/ii\\\n|ii|\n\\____/".Replace("i",i+i);
Ungolfed
i =>
" __\n /i\\\n/ii\\\n|ii|\n\\____/"
.Replace( "i", i + i );
Ungolfed readable
i =>
" __\n /i\\\n/ii\\\n|ii|\n\\____/"
// Replace every instance of 'i' with the input cloned twice
.Replace( "i", i + i );
Full code
using System;
using System.Collections.Generic;
namespace Namespace {
class Program {
static void Main( String[] args ) {
Func<String, String> f = i =>
" __\n /i\\\n/ii\\\n|ii|\n\\____/"
.Replace( "i", i + i );
List<String>
testCases = new List<String>() {
"-",
"%",
"~",
"o",
" ",
};
foreach( String testCase in testCases ) {
Console.WriteLine( $" Input: {testCase}\nOutput:\n{f( testCase )}\n" );
}
Console.ReadLine();
}
}
}
Releases
- v1.0 -
56 bytes- Initial solution.
Notes
The printed results within the link provided will not look like pretended, due to the font used not being monospace.
JavaScript (ES6), 55 bytes
x=>` __
/0\\
/00\\
|00|
\\____/`.replace(/0/g,_=>x+x)
C++ 208 bytes
In response to comments: This is a complete re-post.
#include<iostream>
using namespace std;int main(){char e;cin>>e;cout<<" __ \n";cout<<" /"<<e<<e<<"\\ "<<endl;cout<<"/"<<e<<e<<e<<e<<"\\"<<endl;cout<<"|"<<e<<e<<e<<e<<"|"<<endl;cout<<"\\____/ \n";return 0;}
[R], 65 bytes
cat(gsub('x',scan(,'')," __\n /xx\\\n/xxxx\\\n|xxxx|\n\\____/"))
Pretty unspectacular, please find a shorter one in R... It's your basic gsub
Japt, 35 bytes
" __
/01
/001
|00|
1____/"d0U²1'\
41-byte solution:
[S²'_²RS'/U²'\R'/U²²'\R'|U²²'|R'\'_²²'/]q
Bash, 50 bytes
echo " __
/$1$1\\
/$1$1$1$1\\
|$1$1$1$1|
\____/"
I've also tried to do pattern substitution during parameter expansion, but it seems like the most straightforward way to do this is also the shortest.
Lua, 66 bytes
print((([[ __
/ee\
/eeee\
|eeee|
\____/]]):gsub("e",io.read())))
((([[#NailedIt]])))
PHP, 51 bytes
$a.=$a=$argn;echo" __
/$a\
/$a$a\
|$a$a|
\____/";
PHP, 58 Bytes without physical linebreaks
$a.=$a=$argn;echo" __\n /$a\\\n/$a$a\\\n|$a$a|\n\\____/";
run this with -R option
61 Bytes
echo strtr(" __\n /88\\\n/8888\\\n|8888|\n\\____/",8,$argn);
Jelly, 24 22 bytes
Ḥ;“ ¶/\|_”“Ṁ¢ṚR;ḳ}AṠ’ṃ
How?
Ḥ;“ ¶/\|_”“Ṁ¢ṚR;ḳ}AṠ’ṃ - Main link: character c e.g. '~'
Ḥ - double c: ['~','~']
“ _¶/\|” - string literal: [' ','_',<newline>,'/','\','|']
; - concatenate c: [['~','~'],' ','_',<newline>,'/','\','|']
“Ṁ¢ṚR;ḳ}AṠ’ - base 250 number: 3067183430901851641706
ṃ - base decompression with reversed @rguments:
- take the number and convert it to a base length(the list)
- then index (1-based) into that same list.
- i.e.: 3067183430901851641706 in base 7
= 22003241534115361163500004
indexed into [['~','~'],' ','_',<newline>,'/','\','|']
= [' ',' ','_','_',<newline>,' ','/',['~','~'],'\',<newline>,'/',['~','~'],['~','~'],'\',<newline>,'|',['~','~'],['~','~'],'|',<newline>,'\','_','_','_','_','/']
- implicit print: __
/~~\
/~~~~\
|~~~~|
\____/
JavaScript (ES6), 53 49 47 bytes
I'm sure I can squeeze a bit more out of this - having to escape the \s is annoying me.
f=
c=>` __
/${c+=c}\\
/${c+=c}\\
|${c}|
\\____/`
console.log(f`-`)
console.log(f`%`)
console.log(f`~`)
console.log(f`&`)
console.log(f`#`)
- 4 bytes saved by moving the
s=c+cvariable assignment inside the first set of{}. - 2 bytes saved by using
c+=cinstead ofs=c+c&s=s+s, with thanks in part to Neil who spotted this improvement at the same time as I was making it.
Paint Your Own!
f=
c=>` __
/${c+=c}\\
/${c+=c}\\
|${c}|
\\____/`
o.innerText=f` `;i.addEventListener("input",function(){o.innerText=f(this.value||" ");})
<input maxlength="1" id="i">
<pre id=o></pre>
05AB1E, 32 29 26 bytes (Thanks to Emigna/Adnan)
•jÀňiXƒÐ[Z•6B6ôvy5ÝJ¹"_ |/\ÿ"‡,
•jÀňiXƒÐ[Z•6B6ô # Push ['110011', '135541', '355554', '255552', '400003']
vy # For each encrypted block...
5ÝJ # Push 012345.
¹"_ |/\ÿ" # Push "_ |/\{input_char}".
‡, # Swap the charsets.
29 byte version (smarter w/o iteration needed due to encoding newlines as well):
05AB1E, 29 bytes (Emigna)
•P£<r7»TwDšç6•5ÝJI"
_/ÿ\|"‡.c
26 byte extension of Emigna's suggestion, using S to separate the chars into an array, then a[b] to interpolate each digit with the corresponding location in the previous array. This is essentially an element-wise transliteration (smart).
05AB1E, 26 bytes (Adnan)
"
_/ÿ\|"•P£<r7»TwDšç6•Sè.c
PowerShell, 50 49 48 bytes
' __
/11\
/1111\
|1111|
\____/'-replace1,$args
Straightforward string replacement into a literal string. Not much room for golfing.
-1 byte thanks to HyperNeutrino; -1 byte thanks to wubs
Sed, 43 characters
s:.: __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/:
Sample run:
bash-4.3$ sed 's:.: __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/:' <<< '★'
__
/★★\
/★★★★\
|★★★★|
\____/
Python, 59 bytes
lambda n:r''' __
/a\
/aa\
|aa|
\____/'''.replace('a',n*2)
05AB1E, 34 33 32 bytes
„__I244S×'/ì'\«`©¦¨'|.ø®R¹'_‡).c
Explanation
„__ # push "__"
I244S× # push a list of the input repeated 2 and 4 and 4 times
'/ì # prepend "/"
'\« # append "\"
` # split list to separate items
© # store a copy of the last one in register
¦¨ # remove first and last item of the string
'|.ø # surround with pipes
®R # retrieve the string from register and reverse it
¹'_‡ # replace input with "_"
).c # print each line centered
Python 2, 62 bytes
Super straight-forward. Try it online.
-1 byte, thanks to @mbomb007
print r''' __
/~\
/~~\
|~~|
\____/'''.replace('~',input()*2)
SpecBAS - 70 bytes
1 INPUT a$: ?" __"'" /";a$*2;"\"'"/";a$*4;"\"'"|";a$*4;"|"'"\____/"
? is shorthand for PRINT command, and apostrophe moves cursor to next line.
Batch, 76 bytes
@for %%l in (" __" " /%1%1\" "/%1%1%1%1\" "|%1%1%1%1|" \____/)do @echo %%~l
Note: To run this with special characters such as &, prefix the character with a ^.