13
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – Jacob Persi Nov 17 '17 at 19:26
  • 2
    \$\begingroup\$ @JacobPersi This is a classic kolmogorov-complexity challenge, where the aim is to compress the given string as much as possible, hardcoding is probably not too golfy \$\endgroup\$ – Mr. Xcoder Nov 17 '17 at 19:29
  • 6
    \$\begingroup\$ @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 :) \$\endgroup\$ – dzaima Nov 17 '17 at 22:24
  • 3
    \$\begingroup\$ Understood. I answered one recently in Arm Assembler. Obviously not going to win, but fun none the less :) \$\endgroup\$ – Michael Dorgan Nov 17 '17 at 23:51
  • 1
    \$\begingroup\$ @StevenH. Here's the meta post - it's somewhat old, but many still haven't seen it \$\endgroup\$ – dzaima Nov 20 '17 at 18:52

24 Answers 24

10
\$\begingroup\$

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

\$\endgroup\$
10
\$\begingroup\$

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!

\$\endgroup\$
8
\$\begingroup\$

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.

\$\endgroup\$
7
\$\begingroup\$

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       (.-).(.=).(._)
\$\endgroup\$
7
\$\begingroup\$

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.

\$\endgroup\$
7
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ -2%n/4 is so cool :) Do you search for expressions like that manually, or do run some sort of brute force search? \$\endgroup\$ – Lynn Nov 18 '17 at 14:11
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ – xnor Nov 18 '17 at 14:18
  • 1
    \$\begingroup\$ Ohh, that’s neat. I would love to see the source code! \$\endgroup\$ – Lynn Nov 18 '17 at 14:26
5
\$\begingroup\$

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!

\$\endgroup\$
5
\$\begingroup\$

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.
\$\endgroup\$
3
\$\begingroup\$

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!

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

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!

\$\endgroup\$
  • 1
    \$\begingroup\$ You can do better than this I thinks... \$\endgroup\$ – cleblanc Nov 17 '17 at 20:47
2
\$\begingroup\$

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!

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

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!

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

Japt, 50 bytes

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

Try it online!

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

Perl 5, 92 bytes

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

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Don't you need to count the input towards the byte count? Otherwise just input the entire string... \$\endgroup\$ – cleblanc Nov 17 '17 at 21:19
  • \$\begingroup\$ There is no input. That was just a TIO leftover from something else I was doing. \$\endgroup\$ – Xcali Nov 17 '17 at 21:20
  • \$\begingroup\$ cool, got it thanks. \$\endgroup\$ – cleblanc Nov 17 '17 at 21:22
  • \$\begingroup\$ +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! \$\endgroup\$ – Dom Hastings Nov 17 '17 at 22:45
2
\$\begingroup\$

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.

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

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

\$\endgroup\$
  • 6
    \$\begingroup\$ You can use \n instead of separate print statements \$\endgroup\$ – Nissa Nov 17 '17 at 20:08
  • \$\begingroup\$ 148 bytes using this approach \$\endgroup\$ – Mr. Xcoder Nov 17 '17 at 20:26
  • 7
    \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ – AdmBorkBork Nov 17 '17 at 21:00
1
\$\begingroup\$

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.
\$\endgroup\$
1
\$\begingroup\$

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)

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

Pyth, 58 bytes

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

Watch it in action!

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

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!

\$\endgroup\$
  • \$\begingroup\$ 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?" ":"\\/" \$\endgroup\$ – ceilingcat Dec 21 '18 at 4:27
1
\$\begingroup\$

VimL, 76 bytes

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

Animated with vimanim.py.

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

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

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@
\$\endgroup\$
1
\$\begingroup\$

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!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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