Make me an Easter egg!

28

3

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.

Matthew Roh

Posted 2017-04-14T14:30:34.887

Reputation: 5 043

8Why the downvote? If you do not like this question, downvote then leave a reason please. – Matthew Roh – 2017-04-14T14:41:36.427

2One 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. – John Dvorak – 2017-04-14T14:43:36.477

17The 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. – Dada – 2017-04-14T14:53:03.710

1It's likely because this is a variation on existing challenges with nothing unique beyond the shape of the object, that being said I +1'd it because it's the first Easter themed challenge I've seen... The only non-trivial part is that /\\ is not a palindrome ._. – Magic Octopus Urn – 2017-04-14T14:53:27.620

Are trailing spaces on any of the lines allowed? – Martin Ender – 2017-04-14T15:10:01.150

@MartinEnder Yes, they are allowed. – Matthew Roh – 2017-04-14T15:11:07.653

26Upvoted because simple challenges like this are great for beginners like me to ease into golf. – Shaggy – 2017-04-14T15:40:21.663

7POOF! You're an easter egg. (Sorry, couldn't resist) – George Cummins – 2017-04-14T20:16:30.193

Answers

17

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.

Post Rock Garf Hunter

Posted 2017-04-14T14:30:34.887

Reputation: 55 382

14This is the best explanation I've ever read on here. +1 – David Conrad – 2017-04-15T07:32:23.787

12

Python 2, 62 bytes

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

print r'''  __
 /~\
/~~\
|~~|
\____/'''.replace('~',input()*2)

Dead Possum

Posted 2017-04-14T14:30:34.887

Reputation: 3 256

162 bytes – mbomb007 – 2017-04-14T14:50:22.307

@mbomb007 Good one, thanks – Dead Possum – 2017-04-14T14:58:40.087

2

You can save two bytes by using lambda function like this

– Keerthana Prabhakaran – 2017-04-16T09:59:35.153

@KeerthanaPrabhakaran I'm not sure if lambdas are OK for ascii challenges – Dead Possum – 2017-04-17T10:36:59.213

1what is the problem in using lambda in ascii challenges? how are they even related!? :o – Keerthana Prabhakaran – 2017-04-17T11:49:33.127

11

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

user41805

Posted 2017-04-14T14:30:34.887

Reputation: 16 320

←_↘ can be just ↓_ but in fact you can fill after you reflect for 16 bytes: __↗¹←↑¹↖²↓_‖M←¤S. – Neil – 2017-12-27T21:26:31.407

@Neil Thanks for introducing me to ¤ – user41805 – 2017-12-28T17:59:51.600

9

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:  __
                                         /~~\
                                        /~~~~\
                                        |~~~~|
                                        \____/

Jonathan Allan

Posted 2017-04-14T14:30:34.887

Reputation: 67 804

3I nominate your explanation of for the longest explanation of a single byte. – Magic Octopus Urn – 2017-04-14T17:56:00.903

It seems to have become quite a handy atom, thought I'd give it some time in the limelight! – Jonathan Allan – 2017-04-14T17:58:24.760

2I 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. – Magic Octopus Urn – 2017-04-14T17:59:44.400

1Well it is one of my babies :) – Jonathan Allan – 2017-04-14T18:00:20.700

6

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>

Shaggy

Posted 2017-04-14T14:30:34.887

Reputation: 24 623

It would be a bit better if you put those input in <pre><code>s. Nice job though. – Matthew Roh – 2017-04-14T14:59:55.023

Thanks, @SIGSEGV. Consoles preserve white space and, by default, at least, use a monospaced font, so no need to output to a pre. – Shaggy – 2017-04-14T15:03:45.400

1Why not c+=c? – Neil – 2017-04-14T15:17:04.347

Thanks, @Neil, I was just editing that in myself, but I'll update again to give you a nod as well. – Shaggy – 2017-04-14T15:20:53.377

@Arnauld You don't need to count the f=\n portion for the byte count. That's only so the snippet runs. – AdmBorkBork – 2017-04-14T15:56:34.927

Sorry, my bad. It's definitely 47. (I pasted it on the wrong Notepad++ page with CR+LF linebreaks rather than LF.) – Arnauld – 2017-04-14T16:04:38.233

Phew, you had me worried there, @Arnauld, thinking I'd undercounted in a few other answers on the site! I do the same thing myself, using Notepad++ – Shaggy – 2017-04-14T16:07:16.327

6

Sed, 43 characters

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

Sample run:

bash-4.3$ sed 's:.:  __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/:' <<< '★'
  __
 /★★\
/★★★★\
|★★★★|
\____/

manatwork

Posted 2017-04-14T14:30:34.887

Reputation: 17 865

That's exactly what I wrote, just a few seconds faster. – Riley – 2017-04-14T15:15:47.517

5

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.

Martin Ender

Posted 2017-04-14T14:30:34.887

Reputation: 184 808

:D it's here!! This language looks nifty – Conor O'Brien – 2017-04-15T12:37:27.980

@ConorO'Brien thank you. I've already plastered some older challenges with it in case you want to see more samples. :) – Martin Ender – 2017-04-15T12:49:50.460

4

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

AdmBorkBork

Posted 2017-04-14T14:30:34.887

Reputation: 41 581

4

Carrot, 34 bytes, non-competing

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

Non-competing because I just fixed bug with the interpreter in leading whitespace not being shown.

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

user41805

Posted 2017-04-14T14:30:34.887

Reputation: 16 320

4

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

dzaima

Posted 2017-04-14T14:30:34.887

Reputation: 19 048

You have to paint the egg. (i.e. fill the inside of the egg with characters) – Matthew Roh – 2017-04-14T16:01:27.620

@SIGSEGV - It is explained that that is achieved by replacing the spaces with the input and replacing the dashes with spaces with the code @,ŗ -@ŗ – Jonathan Allan – 2017-04-14T16:03:44.360

Will SOGOL be at TIO any time soon? – Jonathan Allan – 2017-04-14T16:04:37.233

@JonathanAllan If someone can get it there, then yes. – dzaima – 2017-04-14T16:05:53.237

Talk to Dennis in the talk-tryitonline-net room.

– Jonathan Allan – 2017-04-14T16:06:58.377

Is SOGL run with the processing-java interpreter? – user41805 – 2017-04-14T16:15:40.540

@KritixiLithos Yes, the thing that comes with the PDE download. – dzaima – 2017-04-14T16:18:41.310

@SIGSEGV you weren't the only one to misread that explanation. – Magic Octopus Urn – 2017-04-14T17:58:30.737

3

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

Emigna

Posted 2017-04-14T14:30:34.887

Reputation: 50 798

•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. – Magic Octopus Urn – 2017-04-14T14:49:34.427

1@carusocomputing: You should post it separately. It's different enough to be interesting on its own :) – Emigna – 2017-04-14T14:51:46.293

3

Retina 0.8.2, 43 41 bytes

-2 bytes thanks to Kevin Cruijssen

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

Try it online!

Riley

Posted 2017-04-14T14:30:34.887

Reputation: 11 345

I know it's been a while, but you can save 2 bytes like this.

– Kevin Cruijssen – 2019-04-19T11:23:52.543

3

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)

Jonathan Allan

Posted 2017-04-14T14:30:34.887

Reputation: 67 804

3

Brainfuck - 257 bytes 181 bytes

Golfed: Live version click here

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

I'm not a professional golfer though. This is my attempt as far as I can recall :D

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
++++++++++[>+++>+<<<++++<+<+>>>-]
>++<
<<--<+
>>>,
>..<<<<..>>>>>.<.
<<<<<.
>>>>..<<.>>>>.
<<<<<<.>>>>....<<.>>>>.
<<<.>....<.
>>>.<<<<.<....<.

Lucca Ferri

Posted 2017-04-14T14:30:34.887

Reputation: 131

2

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!

Magic Octopus Urn

Posted 2017-04-14T14:30:34.887

Reputation: 19 422

1This is 3 bytes shorter. More similar to your answer than mine :) – Emigna – 2017-04-14T15:00:41.017

1@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. – Magic Octopus Urn – 2017-04-14T15:24:53.140

2For 26 bytes. – Adnan – 2017-04-14T15:53:40.050

1@adnan - sneaky sneaky... – Magic Octopus Urn – 2017-04-14T15:59:55.913

I feel like almost all my answers need to credit Admigna, wouldn't really know the language without both of your constant examples. – Magic Octopus Urn – 2017-04-14T17:48:10.843

2

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

Jörg Hülsermann

Posted 2017-04-14T14:30:34.887

Reputation: 13 026

Store the value doubled; remove unnecessary space; use literal newline character: https://pastebin.com/EghdAYMf

– manatwork – 2017-04-14T15:52:27.647

@manatwork Thank you i have not really thinking about double the input – Jörg Hülsermann – 2017-04-14T16:01:37.883

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. – Titus – 2017-04-14T17:04:30.780

@Titus i hate physical linebreaks Done – Jörg Hülsermann – 2017-04-14T17:19:11.290

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

– manatwork – 2017-04-14T18:32:12.643

2

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!

cleblanc

Posted 2017-04-14T14:30:34.887

Reputation: 3 360

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++);} – Albert Renshaw – 2017-04-15T08:25:22.443

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++);} – Albert Renshaw – 2017-04-15T08:26:13.683

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. – Albert Renshaw – 2017-04-15T08:30:34.353

Suggest *s;f(c){for(s instead of f(c){for(int* – ceilingcat – 2019-04-26T16:46:50.327

2

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.

Esolanging Fruit

Posted 2017-04-14T14:30:34.887

Reputation: 13 542

@JoKing I suggest you post that as a separate answer, because it seems very different from mine. – Esolanging Fruit – 2018-04-16T19:26:44.107

2

brainfuck, 114 bytes

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

Try it online!

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

Jo King

Posted 2017-04-14T14:30:34.887

Reputation: 38 234

1

SpecBAS - 70 bytes

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

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

Brian

Posted 2017-04-14T14:30:34.887

Reputation: 1 209

1

Röda, 46 bytes

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

Try it online!

fergusq

Posted 2017-04-14T14:30:34.887

Reputation: 4 867

1

Python, 59 bytes

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

Rɪᴋᴇʀ

Posted 2017-04-14T14:30:34.887

Reputation: 7 410

1

Swift - 88 bytes

var f={x in"  __\n /&&\\\n/&&&&\\\n|&&&&|\n\\____/".replacingOccurrences(of:"&",with:x)}

Lambda-like function with usage: print(f("x")).

Try it out here!


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.

Mr. Xcoder

Posted 2017-04-14T14:30:34.887

Reputation: 39 774

The replacingOccurrences() really kills the score :(( – Mr. Xcoder – 2017-04-14T16:19:07.133

1

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

takintoolong

Posted 2017-04-14T14:30:34.887

Reputation: 119

1

Lua, 66 bytes

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

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

Blab

Posted 2017-04-14T14:30:34.887

Reputation: 451

1

Retina, 41 bytes

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

Try it online!

Dennis

Posted 2017-04-14T14:30:34.887

Reputation: 196 637

1

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!

Oliver

Posted 2017-04-14T14:30:34.887

Reputation: 7 160

Nice one. My first attempt was this for 36 bytes, but it looks like using d is a byte shorter.

– ETHproductions – 2017-04-15T14:06:29.180

1

[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

user11599

Posted 2017-04-14T14:30:34.887

Reputation: 191

1

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.

auhmaan

Posted 2017-04-14T14:30:34.887

Reputation: 906

1

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

Jake Reynolds

Posted 2017-04-14T14:30:34.887

Reputation: 11

1

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!

Ian M.

Posted 2017-04-14T14:30:34.887

Reputation: 21

1

Pyth, 36 bytes

jm:s@L"-/|\\_ "jCd6\-+QQ"ԈџÛƲ獩

Try it online!

Leaky Nun

Posted 2017-04-14T14:30:34.887

Reputation: 45 011

1

c(gcc) 81 78 bytes

*s;f(c){for(s=LR"(  __
 /00\
/0000\
|0000|
\____/)";*s;s++)printf(*s%6?s:&c);}

Try it online

Johan du Toit

Posted 2017-04-14T14:30:34.887

Reputation: 1 524

0

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

Neil

Posted 2017-04-14T14:30:34.887

Reputation: 95 035

0

JavaScript (ES6), 55 bytes

x=>`  __
 /0\\
/00\\
|00|
\\____/`.replace(/0/g,_=>x+x)

ETHproductions

Posted 2017-04-14T14:30:34.887

Reputation: 47 880

This wont work if x === '$', 3 more bytes are needed: .replace(/0/g,_=>x+x) – tsh – 2017-04-15T07:11:04.547

@tsh Ah dang it. I actually had it like that originally, but I thought I could remove the _=>... – ETHproductions – 2017-04-15T13:59:08.527

0

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.

Try it online!

Maxim Mikhaylov

Posted 2017-04-14T14:30:34.887

Reputation: 571

Neither I managed to reduce a pure Bash solution, but Bash + coreutils would be shorter: tr . "$1"<<<' __ /..\ /....\ |....| \____/'. – manatwork – 2017-04-15T15:45:17.647

0

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

Brian McCutchon

Posted 2017-04-14T14:30:34.887

Reputation: 503

0

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|
\____/

Adola

Posted 2017-04-14T14:30:34.887

Reputation: 131

The egg should be painted with the character given in input line. – Toto – 2017-04-16T10:08:00.167

0

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

Taylor Scott

Posted 2017-04-14T14:30:34.887

Reputation: 6 709

0

JS (ES6), 60 bytes

x=>`  __
 /~\\
/~~\\
|~~|
\\____/`.replace(/~/g,x.repeat(2))

Basically the same thing as the python answer.

user68278

Posted 2017-04-14T14:30:34.887

Reputation:

0

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:

Try it here.

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|
\____/

Kevin Cruijssen

Posted 2017-04-14T14:30:34.887

Reputation: 67 575

0

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
⎝.___.⎠

Khaled.K

Posted 2017-04-14T14:30:34.887

Reputation: 1 435

0

Aceto, 68 64 bytes, non-competing

8 by 8, so a 3rd order Hilbert curve. Marked as non-competing because I had to fix a bug in the interpreter.

/"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:

  __
 /==\
/====\
|====|
\____/

L3viathan

Posted 2017-04-14T14:30:34.887

Reputation: 3 151

0

Common Lisp, SBCL, 73 bytes

(format t"  __
 /~@?\\
/~@?~@?\\
|~@?~@?|
\\____/""~2@{~a~:*~}~@*"(read))

user65167

Posted 2017-04-14T14:30:34.887

Reputation:

0

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

Not a tree

Posted 2017-04-14T14:30:34.887

Reputation: 3 106

0

Ruby, 63 bytes

puts"  __  \n /00\\ \n/0000\\\n|0000|\n\\____/".gsub"0",$*[0]

As basic as it gets, honestly

Håvard Nygård

Posted 2017-04-14T14:30:34.887

Reputation: 341

0

05AB1E, 25 bytes

"ÿ_
\/|"•θ8Ë1Âõ]Æ°•6вèJ.c

Try it online.

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

Kevin Cruijssen

Posted 2017-04-14T14:30:34.887

Reputation: 67 575

0

Excel Formula, 54 bytes

Makes use of multi-line entry in the formula bar (Alt+Enter), where # is your chosen character to paint!

=SUBSTITUTE("  __
 /~~\
/~~~~\
|~~~~|
\____/","~","#")

i_saw_drones

Posted 2017-04-14T14:30:34.887

Reputation: 413

0

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.

Try it online.

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:

  1. Push all characters reversed to the stack, including the input-characters
    • With bytes saved using Duplicates and Copy's-of
  2. 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).

Kevin Cruijssen

Posted 2017-04-14T14:30:34.887

Reputation: 67 575

0

Haskell, 70 63 bytes

7 bytes down with great help from Laikoni

(<$>"  __\n /~~\\\n/~~~~\\\n|~~~~|\n\\____/").(?)
d?'~'=d
d?c=c

Try it online!

The function f takes a character to paint the egg with.

Max Yekhlakov

Posted 2017-04-14T14:30:34.887

Reputation: 601

You can use >'z' instead of =='~'. Flipping the arguments of ? allows for a shorter pointfree notation: (<$>" ... ").(?). Try it online!

– Laikoni – 2019-04-29T05:53:31.393

Using pattern matching for (?) is even shorter: d?'~'=d;d?c=c. Try it online!

– Laikoni – 2019-04-29T05:58:14.057

0

Scala, 56 bytes

print("""  __
 /~\
/~~\
|~~|
\____/""".replace("~",i+i))

Try it online!

pme

Posted 2017-04-14T14:30:34.887

Reputation: 111

0

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.

BradC

Posted 2017-04-14T14:30:34.887

Reputation: 6 099