Scoop me an icecream please

13

Make me an icecream cone please

We have a ton of great ice cream places here in New England. Most of them are closed for the winter now, so...

   .-@@-.
  (======)
 (--------)
(==========)
(__________)
 \/\/\/\/\/
  \/\/\/\/
   \/\/\/
    \/\/
     \/

GOAL Output the above icecream cone exactly. (or return it from a function)

This is code golf so shortest answer wins

cleblanc

Posted 2017-11-17T19:10:41.213

Reputation: 3 360

This seems like a strange challenge, wouldn't simply executing that as a string literal technically be a solution for some interpreted languages like JS/Python? – Jacob Persi – 2017-11-17T19:26:15.447

2@JacobPersi This is a classic [tag:kolmogorov-complexity] challenge, where the aim is to compress the given string as much as possible, hardcoding is probably not too golfy – Mr. Xcoder – 2017-11-17T19:29:11.027

Lol - my preferred 'C' family languages again have 0 chance at this. – Michael Dorgan – 2017-11-17T19:30:16.123

@dzaima yes trailing spaces and trailing new lines are fine. – cleblanc – 2017-11-17T19:43:07.797

@MichaelDorgan 146 bytes f(){puts(" .-@@-.\n (======)\n (--------)\n(==========)\n(__________)\n \\/\\/\\/\\/\\/\n \\/\\/\\/\\/\n \\/\\/\\/\n \\/\\/\n \\/");} – cleblanc – 2017-11-17T19:43:59.587

Sure - could printf() or whatever. But, strings and C won't ever compete :) Should have stated "chance at winning this." My bad – Michael Dorgan – 2017-11-17T19:46:49.703

@MichaelDorgan I'm curious if there's a golfing language with an icecream-cone build-in – cleblanc – 2017-11-17T20:00:13.140

@cleblanc Which prints this exact text? Really, really unlikely. – Erik the Outgolfer – 2017-11-17T20:06:42.800

I'd say that some of these languages feel like they were invented for code golf. I could probably create iCeCrEaMCoNe that one character prints a cone and win. – Michael Dorgan – 2017-11-17T21:37:50.800

6@MichaelDorgan many of the languages were invented for code golf, but that shouldn't discourage you from answering in production languages - here it's suggested to upvote interesting answers, and an answer in iCeCrEaMCoNe would not be one of those. This site even used to have a rule that you can't answer in a language( / use a feature) newer than the challenge, but that got replaced by "don't upvote trivial answers". After all, these golfing languages exist just for fun :) – dzaima – 2017-11-17T22:24:13.767

3Understood. I answered one recently in Arm Assembler. Obviously not going to win, but fun none the less :) – Michael Dorgan – 2017-11-17T23:51:39.013

@dzaima I missed some memos while I was gone, apparently. That rule got replaced? Do you have a link to the meta post? I'd love to read through it. – Steven H. – 2017-11-20T18:49:33.773

1

@StevenH. Here's the meta post - it's somewhat old, but many still haven't seen it

– dzaima – 2017-11-20T18:52:11.000

@dzaima Isn't using a language/feature that was created specifically for the challenge still considered a standard loophole? – KSmarts – 2017-11-28T14:51:37.850

@KSmarts I don't think it is (or should be), it's more like an implicit loophole. I have once made (a version of) one of my answers non-competing because I felt like a thing I added (that was mostly documentated) was too built-in-y for the challenge, though that built-in could very well be useful on other challenges. – dzaima – 2017-11-28T14:59:58.253

Answers

10

SOGL V0.12, 24 bytes

u%⅝⁾⁷‰┘Η:⅛6s⁹№K⌠RΝīL°‘§╬

Try it Here!

A simple compression solution:

....‘    push "@-.¶===(¶----(¶=====(¶_____(¶\/\/\¶/\/\¶\/\¶/\¶\"
     §   pad with spaces and reverse horizontally
      ╬  palindromize with 0 overlap and mirroring the characters

No compression version - way longer as SOGLs compression works nice for this

dzaima

Posted 2017-11-17T19:10:41.213

Reputation: 19 048

10

Python 2, 95 bytes

i=9;print'   .-@@-.'
while i:print['('+~i*3/4*2%22*'-=_='[i%4]+')','\/'*i][i<6].center(12);i-=1

Try it online!

Lynn

Posted 2017-11-17T19:10:41.213

Reputation: 55 648

8

PowerShell, 85 bytes

"   .-@@-.
  (======)
 (--------)
($('='*10))
($('_'*10))"
1..5|%{" "*$_+'\/'*(6-$_)}

Try it online!

OR

PowerShell, 85 bytes

"   .-@@-.
  (======)
 (--------)"
'=','_'|%{"($($_*10))"}
1..5|%{" "*$_+'\/'*(6-$_)}

Try it online!

Take your pick. In both cases, the first three lines don't have enough bytes to do any sort of compression in PowerShell.

The first case uses string multiplication to produce each of the 10-length = and _ lines, while the second uses a loop and string multiplication. In either case, the last line forms the cone, looping from 1 to 5 and each iteration outputting the appropriate number of spaces followed by the appropriate number of cone pieces.

All of those strings are left on the pipeline, and the implicit Write-Output at program completion gives us a newline between elements for free.

AdmBorkBork

Posted 2017-11-17T19:10:41.213

Reputation: 41 581

7

V, 48 46 bytes

i\/5ñ>GÄXa/\ñS³ .-@@-.
  (¶=)
 (¸-)
(±=)
(±_)

Try it online!

Hexdump:

00000000: 695c 2f1b 35f1 3e47 c458 612f 5cf1 53b3  i\/.5.>G.Xa/\.S.
00000010: 202e 2d40 402d 2e0a 2020 28b6 3d29 0a20   .-@@-..  (.=). 
00000020: 28b8 2d29 0a28 b13d 290a 28b1 5f29       (.-).(.=).(._)

James

Posted 2017-11-17T19:10:41.213

Reputation: 54 537

7

Charcoal, 29 bytes

@-.⸿E=-=⁺×ι⁺³κ)×_⁵P↙⁶)⸿‖M←¤/\

Try it online! Link is to verbose version of code. Explanation:

@-.⸿

Print the right half of the first line.

E=-=⁺×ι⁺³κ)

For each of the characters =-=, repeat 3 times for the first and an additional time for each subsequent character, then append a ), printing each result on its own line.

×_⁵

Print 5 _s.

P↙⁶

Print the edge of the cone.

)⸿

Print the final ) and position the cursor inside the cone.

‖M←

Mirror the half cone.

¤/\

Fill the body of the cone.

Neil

Posted 2017-11-17T19:10:41.213

Reputation: 95 035

7

Python 2, 86 bytes

n=10
while n:print['\/'*n,'('+35/n*2*'-=_='[n%4]+')','.-@@-.'][-2%n/4].center(12);n-=1

Try it online!

Working off Lynn's solution.

xnor

Posted 2017-11-17T19:10:41.213

Reputation: 115 687

-2%n/4 is so cool :) Do you search for expressions like that manually, or do run some sort of brute force search? – Lynn – 2017-11-18T14:11:26.237

1@Lynn I ran a brute-forcer. I also did that for 35/n*2, which it found as 5*7/n*2 since it doesn't know of multidigit numbers. – xnor – 2017-11-18T14:18:53.410

1Ohh, that’s neat. I would love to see the source code! – Lynn – 2017-11-18T14:26:34.887

5

Perl 6, 115 95 94 92 90 bytes

3 bytes saved by AlexDaniel in #perl6 on irc.freenode.net

say "   .-@@-.
  (======)
 (--------)
({"="x 10})
({"_"x 10})";say(' 'x++$,'\/'x$--+5)xx 5

Try it online!

Luke

Posted 2017-11-17T19:10:41.213

Reputation: 4 675

5

05AB1E, 42 bytes

•3[ÜAʒg‰ŽÎ<\¦•6¡εS"-.@(=_"sèJ∞}'\∞5LRׂ˜.C

Try it online!


1026344463000063444446355555 is now the Icecream Number b/c nobody else has used it.


Full program: •3[ÜAʒg‰ŽÎ<\¦•6¡εS"-.@(=_"sèJ∞}'\∞5LRׂ˜.C
current >> •  ||  stack: []
current >> 6  ||  stack: [1026344463000063444446355555]
current >> ¡  ||  stack: [1026344463000063444446355555, '6']
current >> ε  ||  stack: [['102', '3444', '30000', '344444', '355555']]
For each: S"-.@(=_"sèJ∞
Full program: S"-.@(=_"sèJ∞
current >> S  ||  stack: ['102']
current >> "  ||  stack: [['1', '0', '2']]
current >> s  ||  stack: [['1', '0', '2'], '-.@(=_']
current >> è  ||  stack: ['-.@(=_', ['1', '0', '2']]
current >> J  ||  stack: [['.', '-', '@']]
current >> ∞  ||  stack: ['.-@']
stack > ['.-@@-.']
Full program: S"-.@(=_"sèJ∞
current >> S  ||  stack: ['3444']
current >> "  ||  stack: [['3', '4', '4', '4']]
current >> s  ||  stack: [['3', '4', '4', '4'], '-.@(=_']
current >> è  ||  stack: ['-.@(=_', ['3', '4', '4', '4']]
current >> J  ||  stack: [['(', '=', '=', '=']]
current >> ∞  ||  stack: ['(===']
stack > ['(======)']
Full program: S"-.@(=_"sèJ∞
current >> S  ||  stack: ['30000']
current >> "  ||  stack: [['3', '0', '0', '0', '0']]
current >> s  ||  stack: [['3', '0', '0', '0', '0'], '-.@(=_']
current >> è  ||  stack: ['-.@(=_', ['3', '0', '0', '0', '0']]
current >> J  ||  stack: [['(', '-', '-', '-', '-']]
current >> ∞  ||  stack: ['(----']
stack > ['(--------)']
Full program: S"-.@(=_"sèJ∞
current >> S  ||  stack: ['344444']
current >> "  ||  stack: [['3', '4', '4', '4', '4', '4']]
current >> s  ||  stack: [['3', '4', '4', '4', '4', '4'], '-.@(=_']
current >> è  ||  stack: ['-.@(=_', ['3', '4', '4', '4', '4', '4']]
current >> J  ||  stack: [['(', '=', '=', '=', '=', '=']]
current >> ∞  ||  stack: ['(=====']
stack > ['(==========)']
Full program: S"-.@(=_"sèJ∞
current >> S  ||  stack: ['355555']
current >> "  ||  stack: [['3', '5', '5', '5', '5', '5']]
current >> s  ||  stack: [['3', '5', '5', '5', '5', '5'], '-.@(=_']
current >> è  ||  stack: ['-.@(=_', ['3', '5', '5', '5', '5', '5']]
current >> J  ||  stack: [['(', '_', '_', '_', '_', '_']]
current >> ∞  ||  stack: ['(_____']
stack > ['(__________)']
current >> '  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)']]
current >> ∞  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], '\\']
current >> 5  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], '\\/']
current >> L  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], '\\/', '5']
current >> R  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], '\\/', [1, 2, 3, 4, 5]]
current >> ×  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], '\\/', [5, 4, 3, 2, 1]]
current >> ‚  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], ['\\/\\/\\/\\/\\/', '\\/\\/\\/\\/', '\\/\\/\\/', '\\/\\/', '\\/']]
current >> ˜  ||  stack: [[['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)'], ['\\/\\/\\/\\/\\/', '\\/\\/\\/\\/', '\\/\\/\\/', '\\/\\/', '\\/']]]
current >> .  ||  stack: [['.-@@-.', '(======)', '(--------)', '(==========)', '(__________)', '\\/\\/\\/\\/\\/', '\\/\\/\\/\\/', '\\/\\/\\/', '\\/\\/', '\\/']]
   .-@@-.
  (======)
 (--------)
(==========)
(__________)
 \/\/\/\/\/
  \/\/\/\/
   \/\/\/
    \/\/
     \/
stack > ['   .-@@-.\n  (======)\n (--------)\n(==========)\n(__________)\n \\/\\/\\/\\/\\/\n  \\/\\/\\/\\/\n   \\/\\/\\/\n    \\/\\/\n     \\/']

•3[ÜAʒg‰ŽÎ<\¦•               | Pushes 1026344463000063444446355555 to the stack.
-----------------------------+-------------------------------------------------
6¡                           | Split on 6's.
-----------------------------+-------------------------------------------------
  ε             }            | Loop on each piece to create the top of the icecream...
   S                         | Split into single chars.
    "-.@(=_"sè               | Substitute in the correct symbol for each number.
              J∞             | Join, then mirror.
-----------------------------+-------------------------------------------------
                 '\∞         | Push \/.
                    5LR      | Push [5,4,3,2,1]
                       ×     | Multiply '\/' by each 5,4,3,2 and 1.
                        ‚˜   | Join top to bottom.
                          .C | Center w/ newlines.

Magic Octopus Urn

Posted 2017-11-17T19:10:41.213

Reputation: 19 422

3

Bubblegum, 50 bytes

00000000: 5350 50d0 d375 70d0 d5e3 5250 d0b0 0503  SPP..up...RP....
00000010: 4d2e 050d 5d28 d0e4 020b c224 34e2 e100  M...](.....$4...
00000020: a82a 461f 0681 9a91 980a 0896 0284 0161  .*F............a
00000030: 0100                                     ..

Try it online!

ovs

Posted 2017-11-17T19:10:41.213

Reputation: 21 408

3

C, 171 bytes

i;p(c,n,o){for(printf("%*c",o,i?32:40);n--;)printf(c);puts(i?"":")");}f(){p(".-@@-.",i=1,3);--i;p("=",6,3);p("-",8,2);p("=",10,1);p("_",10,1);for(i=6;--i;)p("\\/",i,6-i);}

Try it online!

C, 146 bytes

f(){puts("   .-@@-.\n  (======)\n (--------)\n(==========)\n(__________)\n \\/\\/\\/\\/\\/\n  \\/\\/\\/\\/\n   \\/\\/\\/\n    \\/\\/\n     \\/");}

Just prints the hardcoded string.

Try it online!

Steadybox

Posted 2017-11-17T19:10:41.213

Reputation: 15 798

1You can do better than this I thinks... – cleblanc – 2017-11-17T20:47:44.133

2

Python 2, 125 120 119 116 106 bytes

  • Saved three bytes thanks to AdmBorkBork; golfed in range(5,0,~0) to in[5,4,3,2,1].
print"   .-@@-.\n  (======)\n "+"(%s)\n"*3%("-"*8,"="*10,"_"*10),
for _ in 5,4,3,2,1:print" "*(6-_)+_*"\/"

Try it online!

Jonathan Frech

Posted 2017-11-17T19:10:41.213

Reputation: 6 681

2

Python 2, 104 bytes

Borrowed a trick from Jonathan Frech's answer, and thanks to him for saving me some bytes too.

print"   .-@@-.\n  (======)\n "+"(%s)\n"*3%("-"*8,"="*10,"_"*10),
i=5
while i:print(6-i)*" "+"\/"*i;i-=1

Try it online!


Python 2, 108 bytes

print"""   .-@@-.
  (======)
 (--------)
(==========)
(__________)"""
i=5
while i:print(6-i)*" "+"\/"*i;i-=1

Try it online!

Mr. Xcoder

Posted 2017-11-17T19:10:41.213

Reputation: 39 774

2

Japt, 50 bytes

5õ_ç"\\/"
c[AA8,6]£"({Xç"_=-="gY})"Ãp".-@"ê1¹w û ·

Try it online!

Justin Mariner

Posted 2017-11-17T19:10:41.213

Reputation: 4 746

2

Perl 5, 92 bytes

say'   .-@@-.
  (======)
 (--------)
(==========)
(__________)';$_='\/'x6;say while s%\\/% %

Try it online!

Xcali

Posted 2017-11-17T19:10:41.213

Reputation: 7 671

Don't you need to count the input towards the byte count? Otherwise just input the entire string... – cleblanc – 2017-11-17T21:19:18.323

There is no input. That was just a TIO leftover from something else I was doing. – Xcali – 2017-11-17T21:20:51.337

cool, got it thanks. – cleblanc – 2017-11-17T21:22:03.830

+1. You can save a couple using RLE decoding, but I couldn't get using ; as a delimiter for s/// working for some reason. On mobile so can't do anything too much! Try it online!

– Dom Hastings – 2017-11-17T22:45:51.610

2

Ruby, 97 bytes

i=-1
puts ['   .-@@-.']+123455543.digits.map{|n|(i+=1;i<4?"(#{'=-=_'[i]*n*2})":'\/'*n).center 12}

Try it online!

First time ever using Ruby, so tips are very welcome.

Justin Mariner

Posted 2017-11-17T19:10:41.213

Reputation: 4 746

1

Python 3, 202 bytes

This is pretty terrible, its more bytes than just defining the string and printing that even.

print("   .-@@-.")
print("  ("+"="*6+")")
print(" ("+"-"*8+")")
print("("+"="*10+")")
print("("+"_"*10+")")
print(" "+"\/"*5)
print("  "+"\/"*4)
print("   "+"\/"*3)
print("    "+"\/"*2)
print("     \/")

Try It Online

Ben

Posted 2017-11-17T19:10:41.213

Reputation: 47

6You can use \n instead of separate print statements – Nissa – 2017-11-17T20:08:02.457

148 bytes using this approach – Mr. Xcoder – 2017-11-17T20:26:07.477

7Welcome to PPCG! – AdmBorkBork – 2017-11-17T21:00:04.823

1

Jelly, 74 72 bytes

5RU⁾\/ẋ
5R×⁶ż¢Y
3,6,8,10,10j1ż“ “.-@@-.¶  (“=“)¶ (“-“)¶(“=“)¶(“_“)¶”P€;¢

Try it online!

Explanation:

5RU⁾\/ẋ    Link 1. Generate list of "\/"s for cone.
5RU        Range 5, reverse. Gets [5,4,3,2,1].
   ⁾\/     Literal string "\/".
      ẋ    Repeat. Gets ["\/\/\/\/\/","\/\/\/\/","\/\/\/","\/\/","\/"].

5R×⁶ż¢Y    Link 2. Generate rest of cone.
5R         Range 5. Gets [1,2,3,4,5].
  ×⁶       Repeat " " that many times. Gets [" ","  ","   ","    ","     "]
    ż¢     Zip that with the ¢ones. Gets a list of alternating space and cones.
      Y    Join with newlines. This puts it all together for the big cone.

3,6,8,10,10j1ż“ “.-@@-.¶  (“=“)¶ (“-“)¶(“=“)¶(“_“)¶”P€;¢    Link 3. Generate the top and put it on the cone.
10,10,8,6j1;1U                                                Generate list 3,1,6,1,8,1,10,1,10. Does this by joining [10,10,8,6] with ones, appending a one, and reversing.
               “   .-@@-.¶  (“=“)¶ (“-“)¶(“=“)¶(“_“)¶”        List of strings. This separates the completed parts from the non completed parts.
              ż                                               Zip 'em together. Gets [number, string, number, string, ...]
                                                      P€      Get the product of €ach. This completes the non completed strings by repeating them.
                                                        ;¢    Attach the ¢one to the end.

Comrade SparklePony

Posted 2017-11-17T19:10:41.213

Reputation: 5 784

1

Mathematica, 117 bytes

Column[Join[{".-@@-."},"("<>#<>")"&/@{"="~(T=Table)~6,"-"~T~8,"="~T~10,"_"~T~10},T[""<>T["\/",i],{i,5,1,-1}]],Center]


Outputs
enter image description here

you can test it on wolfram sandbox (although the fonts they use may destort the result a little)

J42161217

Posted 2017-11-17T19:10:41.213

Reputation: 15 931

Interestingly \/ is a special character. I couldn't find what it's used for so I asked on Mma.SE: https://mathematica.stackexchange.com/q/200673/61597

– lirtosiast – 2019-06-19T22:20:43.487

1

Pyth, 58 bytes

jm.[12@,*d"\/"@,".-@@-."j@*Vj11494 11"-=_="d"()"ndTgd6;_ST

Watch it in action!

Steven H.

Posted 2017-11-17T19:10:41.213

Reputation: 2 841

1

C, 138 bytes

f(i,j){puts("   .-@@-.\n  (======)\n (--------)\n(==========)\n(__________)");for(j=1;++j<7;i=puts(""))for(;i<7;)printf(i++<j?" ":"\\/");}

Try it online!

Colera Su

Posted 2017-11-17T19:10:41.213

Reputation: 2 291

Suggest j=6;--j;puts(""))for(i=7;--i;)printf(&L"⽜ "[i>j] instead of j=1;++j<7;i=puts(""))for(;i<7;)printf(i++<j?" ":"\\/" – ceilingcat – 2018-12-21T04:27:35.090

1

C 165 bytes

y,x,z;f(){for(puts("   .-@@-.");y++<9;)for(;x=++x%14;)z=y+3-y/4,putchar(x<13?y<5?x-7^z-1?7-x^z?abs(x-7)<z?y<4?y&1?61:45:95:32:40:41:x+y>16|y-x>3?32:x+y&1?92:47:10);}

PrincePolka

Posted 2017-11-17T19:10:41.213

Reputation: 653

1

VimL, 76 bytes

a   .-@@-.␤  ␤ ␛k6A=␛j8A-␛o␛10A=␛o␛10A_␛qaI(␛A)␛kq3@aGo ␛5A\/␛qayypxxI ␛q3@a

Animated with vimanim.py.

bodqhrohro

Posted 2017-11-17T19:10:41.213

Reputation: 583

1

C (gcc), 137 136 bytes

-1 bytes thanks to ceilingcat

main(i){for(puts("   .-@@-.\n  (======)\n (--------)\n(==========)\n(__________)");8<printf("%*c%s\n",++i,92,"/\\/\\/\\/\\/\\/"+i*2););}

Try it online!

cleblanc

Posted 2017-11-17T19:10:41.213

Reputation: 3 360

1

Cubically, 345 336 bytes

⇒@@@
RU+30f1+3-00@-2+3@+4@@-4@+2-3@-110@+31-4@@+2-4@+10f1f1-3+0@-400@+31-4@+2-4@+3-10f1f1@@-4+1@-400@+11@+10f1f1f1@-3+0@-400@+11@+4110@f1f1f1-22@-400@+31-4@+220@-43@+43@-43@+43@-43@+43@-43@+43@-43@-4000@+31-4@@+220@-43@+43@-43@+43@-43@+43@-43@-4000@+31-4f1+220@-43@+43@-43@+43@-43@-4000@+31-4f1@+220@-43@+43@-43@-4000@+31-4f1@@+220@-43@

Found via this tool and golfed via search-and-replace, with a couple custom optimizations.

Try it online!


Alternate method:

391 bytes (doesn't modify cube)

+5/1+3@@@:1/1+5@5.0+2@@5.0-2@-4@:5/1+3@@:4/1+4@:5+2/1+51@@@@@@:5/1+4@:1/1+1@:5/1+3@:4/1+4@5.05.05.05.05.05.05.05.0:5/1+4@:1/1+1@:4/1+4@:5+2/1+51@@@@@@@@@@:5/1+4@:1/1+1@:4/1+4@:5/1+55@@@@@@@@@@-51@:1/1+1@:5/1+3@:2/1+55@-5@+5@-5@+5@-5@+5@-5@+5@-5@:1/1+1@:5/1+3@@:2/1+55@-5@+5@-5@+5@-5@+5@-5@:1/1+1@:5/1+3@@@:2/1+55@-5@+5@-5@+5@-5@:1/1+1@:5/1+3@@@@:2/1+55@-5@+5@-5@:1/1+1@:5/1+3@@@@@:2/1+55@-5@

MD XF

Posted 2017-11-17T19:10:41.213

Reputation: 11 605