27
\$\begingroup\$

No, not the ^^vv<><>BA kind of Easter eggs, real Easter eggs that we paint.

Here is an (awfully drawn) egg.

  __
 /  \
/    \
|    |
\____/

In easter, we paint them with patterns. Like these:

  __
 /--\
/----\
|----|
\____/
  __
 /%%\
/%%%%\
|%%%%|
\____/
  __
 /~~\
/~~~~\
|~~~~|
\____/

The challenge

Given a character (printable ascii) to paint the egg, print the painted egg.

Examples:

&:
  __
 /&&\
/&&&&\
|&&&&|
\____/

#:
  __
 /##\
/####\
|####|
\____/

Specs

  • Trailing newlines/spaces are allowed.
\$\endgroup\$
8
  • 9
    \$\begingroup\$ Why the downvote? If you do not like this question, downvote then leave a reason please. \$\endgroup\$ Apr 14, 2017 at 14:41
  • 2
    \$\begingroup\$ One potential reason might be that they don't think this task is clear enough or clear enough. I'd say it is clear enough, and it's not literally trivial either. That said, I'm not particularly excited either. \$\endgroup\$ Apr 14, 2017 at 14:43
  • 18
    \$\begingroup\$ The challenge will be very trivial in most languages. The egg is too short to allow much originality in the golfing. In my opinion, it's an uninteresting challenge (that hasn't been sandboxed, because you seem to be boycotting the sandbox for I don't know what reasons), therefor, I downvote it. \$\endgroup\$
    – Dada
    Apr 14, 2017 at 14:53
  • 27
    \$\begingroup\$ Upvoted because simple challenges like this are great for beginners like me to ease into golf. \$\endgroup\$
    – Shaggy
    Apr 14, 2017 at 15:40
  • 8
    \$\begingroup\$ POOF! You're an easter egg. (Sorry, couldn't resist) \$\endgroup\$ Apr 14, 2017 at 20:16

53 Answers 53

17
\$\begingroup\$

Brain-Flak, 270 268 266 + 1 = 267 bytes

+1 from the -c flag

(((((((((({}<(((([(()()())]((((((((((({}){}){}){}){}[()]))<>)<>{}())))))<>)<>(((()()()()()){}))({}()){})<>)<>>))))<<>({}<>)((()()()()()){})<>({}<>)>))))<<>((({})<>)({})<((()()()()()){})>[()()])>))<>((((({})<>)[(()()()()())({}){}])<((()()()()()){})<>((({}<>){}()))>))

Try it online!

I was going to write an explanation, but I took a nap first and forgot how this whole think works. Your guess is as good as mine.

\$\endgroup\$
1
  • 14
    \$\begingroup\$ This is the best explanation I've ever read on here. +1 \$\endgroup\$ Apr 15, 2017 at 7:32
12
\$\begingroup\$

Python 2, 62 bytes

Super straight-forward. Try it online.
-1 byte, thanks to @mbomb007

print r'''  __
 /~\
/~~\
|~~|
\____/'''.replace('~',input()*2)
\$\endgroup\$
5
  • 1
    \$\begingroup\$ 62 bytes \$\endgroup\$
    – mbomb007
    Apr 14, 2017 at 14:50
  • \$\begingroup\$ @mbomb007 Good one, thanks \$\endgroup\$ Apr 14, 2017 at 14:58
  • 2
    \$\begingroup\$ You can save two bytes by using lambda function like this \$\endgroup\$ Apr 16, 2017 at 9:59
  • \$\begingroup\$ @KeerthanaPrabhakaran I'm not sure if lambdas are OK for ascii challenges \$\endgroup\$ Apr 17, 2017 at 10:36
  • 1
    \$\begingroup\$ what is the problem in using lambda in ascii challenges? how are they even related!? :o \$\endgroup\$ Apr 17, 2017 at 11:49
11
\$\begingroup\$

Charcoal, 30 26 16 bytes

Two bytes saved thanks to @Neil by filling after making the shape

__↗¹←↑¹↖²↓_‖M←¤S

Try it online!

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
\$\endgroup\$
2
  • \$\begingroup\$ ←_↘ can be just ↓_ but in fact you can fill after you reflect for 16 bytes: __↗¹←↑¹↖²↓_‖M←¤S. \$\endgroup\$
    – Neil
    Dec 27, 2017 at 21:26
  • \$\begingroup\$ @Neil Thanks for introducing me to ¤ \$\endgroup\$
    – user41805
    Dec 28, 2017 at 17:59
9
\$\begingroup\$

Jelly, 24  22 bytes

Ḥ;“ ¶/\|_”“Ṁ¢ṚR;ḳ}AṠ’ṃ

Try it online!

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:  __
                                         /~~\
                                        /~~~~\
                                        |~~~~|
                                        \____/
\$\endgroup\$
4
  • 3
    \$\begingroup\$ I nominate your explanation of for the longest explanation of a single byte. \$\endgroup\$ Apr 14, 2017 at 17:56
  • \$\begingroup\$ It seems to have become quite a handy atom, thought I'd give it some time in the limelight! \$\endgroup\$ Apr 14, 2017 at 17:58
  • 2
    \$\begingroup\$ I see Dennis use it a lot, this is the first time I feel like I actually understood it though; the time was not wasted! You have given me 1 unit of learn. \$\endgroup\$ Apr 14, 2017 at 17:59
  • 1
    \$\begingroup\$ Well it is one of my babies :) \$\endgroup\$ Apr 14, 2017 at 18:00
6
\$\begingroup\$

Sed, 43 characters

s:.:  __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/:

Sample run:

bash-4.3$ sed 's:.:  __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/:' <<< '★'
  __
 /★★\
/★★★★\
|★★★★|
\____/
\$\endgroup\$
1
  • \$\begingroup\$ That's exactly what I wrote, just a few seconds faster. \$\endgroup\$
    – Riley
    Apr 14, 2017 at 15:15
6
\$\begingroup\$

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+c variable assignment inside the first set of {}.
  • 2 bytes saved by using c+=c instead of s=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>

\$\endgroup\$
7
  • \$\begingroup\$ It would be a bit better if you put those input in <pre><code>s. Nice job though. \$\endgroup\$ Apr 14, 2017 at 14:59
  • \$\begingroup\$ Thanks, @SIGSEGV. Consoles preserve white space and, by default, at least, use a monospaced font, so no need to output to a pre. \$\endgroup\$
    – Shaggy
    Apr 14, 2017 at 15:03
  • 1
    \$\begingroup\$ Why not c+=c? \$\endgroup\$
    – Neil
    Apr 14, 2017 at 15:17
  • \$\begingroup\$ Thanks, @Neil, I was just editing that in myself, but I'll update again to give you a nod as well. \$\endgroup\$
    – Shaggy
    Apr 14, 2017 at 15:20
  • \$\begingroup\$ @Arnauld You don't need to count the f=\n portion for the byte count. That's only so the snippet runs. \$\endgroup\$ Apr 14, 2017 at 15:56
5
\$\begingroup\$

Alice, 53 52 bytes, non-competing

Thanks to Leo for indirectly saving 1 byte.

/o *^i}'.*[;.h~r}}~"{.[^\\
@"S .^~ y~a}~~.["{!~"}^^^

Try it online!

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.
\$\endgroup\$
2
  • \$\begingroup\$ :D it's here!! This language looks nifty \$\endgroup\$ Apr 15, 2017 at 12:37
  • \$\begingroup\$ @ConorO'Brien thank you. I've already plastered some older challenges with it in case you want to see more samples. :) \$\endgroup\$ Apr 15, 2017 at 12:49
4
\$\begingroup\$

PowerShell, 50 49 48 bytes

'  __
 /11\
/1111\
|1111|
\____/'-replace1,$args

Try it online!

Straightforward string replacement into a literal string. Not much room for golfing.

-1 byte thanks to HyperNeutrino; -1 byte thanks to wubs

\$\endgroup\$
0
4
\$\begingroup\$

SOGL V0.12, 21 18 16 bytes

0≈⁾‛≤¦¶W?5┼EB§  ‘

Try it Here!

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

\$\endgroup\$
8
  • \$\begingroup\$ You have to paint the egg. (i.e. fill the inside of the egg with characters) \$\endgroup\$ Apr 14, 2017 at 16:01
  • \$\begingroup\$ @SIGSEGV - It is explained that that is achieved by replacing the spaces with the input and replacing the dashes with spaces with the code @,ŗ -@ŗ \$\endgroup\$ Apr 14, 2017 at 16:03
  • \$\begingroup\$ Will SOGOL be at TIO any time soon? \$\endgroup\$ Apr 14, 2017 at 16:04
  • \$\begingroup\$ @JonathanAllan If someone can get it there, then yes. \$\endgroup\$
    – dzaima
    Apr 14, 2017 at 16:05
  • \$\begingroup\$ Talk to Dennis in the talk-tryitonline-net room. \$\endgroup\$ Apr 14, 2017 at 16:06
4
\$\begingroup\$

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
++++++++++[>+++>+<<<++++<+<+>>>-]
>++<
<<--<+
>>>,
>..<<<<..>>>>>.<.
<<<<<.
>>>>..<<.>>>>.
<<<<<<.>>>>....<<.>>>>.
<<<.>....<.
>>>.<<<<.<....<.
\$\endgroup\$
4
\$\begingroup\$

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).

\$\endgroup\$
3
\$\begingroup\$

05AB1E, 34 33 32 bytes

„__I244S×'/ì'\«`©¦¨'|.ø®R¹'_‡).c

Try it online!

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
\$\endgroup\$
2
  • \$\begingroup\$ •jÀňiXƒÐ[Z•6B6ôvy5ÝJ"_ |/\"¹«‡, for 32, entirely different though. This faked me out and made me think I could use palindromize... Damn the fact that ())( and /\\/ are palindromes. \$\endgroup\$ Apr 14, 2017 at 14:49
  • 1
    \$\begingroup\$ @carusocomputing: You should post it separately. It's different enough to be interesting on its own :) \$\endgroup\$
    – Emigna
    Apr 14, 2017 at 14:51
3
\$\begingroup\$

Python 3.6, 53 bytes

lambda x:fr'''  __
 /{2*x}\
/{4*x}\
|{4*x}|
\____/'''
  • Unnamed function taking the character x and 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)

\$\endgroup\$
3
\$\begingroup\$

Retina 0.8.2, 43 41 bytes

-2 bytes thanks to Kevin Cruijssen

.
$&$&
..
  __¶ /$&\¶/$&$&\¶|$&$&|¶\____/

Try it online!

\$\endgroup\$
1
2
\$\begingroup\$

05AB1E, 32 29 26 bytes (Thanks to Emigna/Adnan)

•jÀňiXƒÐ[Z•6B6ôvy5ÝJ¹"_ |/\ÿ"‡,

Try it online!

•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

Try it online 2!


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

Try it online 3!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ This is 3 bytes shorter. More similar to your answer than mine :) \$\endgroup\$
    – Emigna
    Apr 14, 2017 at 15:00
  • 1
    \$\begingroup\$ @Emigna that direct transliteration using newlines is a novel idea, I like that; this could honestly knock 5 bytes off many of my existing solutions. \$\endgroup\$ Apr 14, 2017 at 15:24
  • 2
    \$\begingroup\$ For 26 bytes. \$\endgroup\$
    – Adnan
    Apr 14, 2017 at 15:53
  • 1
    \$\begingroup\$ @adnan - sneaky sneaky... \$\endgroup\$ Apr 14, 2017 at 15:59
  • \$\begingroup\$ I feel like almost all my answers need to credit Admigna, wouldn't really know the language without both of your constant examples. \$\endgroup\$ Apr 14, 2017 at 17:48
2
\$\begingroup\$

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);
\$\endgroup\$
5
  • \$\begingroup\$ Store the value doubled; remove unnecessary space; use literal newline character: pastebin.com/EghdAYMf \$\endgroup\$
    – manatwork
    Apr 14, 2017 at 15:52
  • \$\begingroup\$ @manatwork Thank you i have not really thinking about double the input \$\endgroup\$ Apr 14, 2017 at 16:01
  • \$\begingroup\$ save 7 bytes with physical linebreaks and not escaping the backslashes (the last one needs no escaping anyway). Oh and btw: -R is not a parameter, it´s an option. \$\endgroup\$
    – Titus
    Apr 14, 2017 at 17:04
  • \$\begingroup\$ @Titus i hate physical linebreaks Done \$\endgroup\$ Apr 14, 2017 at 17:19
  • \$\begingroup\$ @Titus, right, though man php calls them parameter: “It is also possible to process the standard input line by line using either the parameter -R or -F.” \$\endgroup\$
    – manatwork
    Apr 14, 2017 at 18:32
2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ @JoKing I suggest you post that as a separate answer, because it seems very different from mine. \$\endgroup\$ Apr 16, 2018 at 19:26
2
\$\begingroup\$

brainfuck, 114 bytes

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

Try it online!

I've used BF Crunch here to find a more optimal way to generate the individual characters.

\$\endgroup\$
2
\$\begingroup\$

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));}

Try it online!

\$\endgroup\$
4
  • \$\begingroup\$ Don't declare *q just nest it right into your for-loop to save 5 bytes. char*s;f(c){for(s=" __\n /11\\\n/1111\\\n|1111|\n\\____/\n";*s;putchar(*s^49?*s:c),s++);} \$\endgroup\$ Apr 15, 2017 at 8:25
  • \$\begingroup\$ You can also save 2 more bytes ontop of that by declaring *s inside the for-loop's declaration argument: f(c){for(char*s=" __\n /11\\\n/1111\\\n|1111|\n\\____/\n";*s;putchar(*s^49?*s:c),s++);} \$\endgroup\$ Apr 15, 2017 at 8:26
  • \$\begingroup\$ You can shave 1 more byte too by checking for an ASCII character that has a numeric value of one digit. 1 is 49 in ASCII but that's 2 bytes, use something with a value from 0-9, for example the tabulation character ` ` is ASCII value 9. \$\endgroup\$ Apr 15, 2017 at 8:30
  • \$\begingroup\$ Suggest *s;f(c){for(s instead of f(c){for(int* \$\endgroup\$
    – ceilingcat
    Apr 26, 2019 at 16:46
1
\$\begingroup\$

SpecBAS - 70 bytes

1 INPUT a$:  ?"  __"'" /";a$*2;"\"'"/";a$*4;"\"'"|";a$*4;"|"'"\____/"

? is shorthand for PRINT command, and apostrophe moves cursor to next line.

\$\endgroup\$
0
1
\$\begingroup\$

Röda, 46 bytes

{a=`  __
 /-\
/--\
|--|
\____/`a~="-",_*2;[a]}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Python, 59 bytes

lambda n:r'''  __
 /a\
/aa\
|aa|
\____/'''.replace('a',n*2)
\$\endgroup\$
1
\$\begingroup\$

Lua, 66 bytes

print((([[  __
 /ee\
/eeee\
|eeee|
\____/]]):gsub("e",io.read())))

((([[#NailedIt]])))

\$\endgroup\$
1
\$\begingroup\$

Retina, 41 bytes

.
$0$0
..
  __¶ /$0\¶/$0$0\¶|$0$0|¶\____/

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Japt, 35 bytes

"  __
 /01
/001
|00|
1____/"d0U²1'\

Try it online!

41-byte solution:

[S²'_²RS'/U²'\R'/U²²'\R'|U²²'|R'\'_²²'/]q

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Nice one. My first attempt was this for 36 bytes, but it looks like using d is a byte shorter. \$\endgroup\$ Apr 15, 2017 at 14:06
1
\$\begingroup\$

[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

\$\endgroup\$
1
\$\begingroup\$

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;}
\$\endgroup\$
0
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

Try it online

\$\endgroup\$
1
\$\begingroup\$

C (gcc), 84 bytes

g(f){char e[]={f,f,f,f};printf("  __\n /%.2s\\\n/%.4s\\\n|%.4s|\n\\____/\n",e,e,e);}

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.