| Bytes | Lang | Time | Link |
|---|---|---|---|
| 057 | C64 Basic | 250716T140711Z | OSI8 |
| 011 | Vyxal 3 | 250715T143548Z | Themooni |
| 036 | Perl 5 | 250709T202337Z | Xcali |
| 007 | Vyxal j | 250707T191007Z | pacman25 |
| 063 | AWK | 250520T201913Z | xrs |
| 027 | TIBasic | 210906T171926Z | Youserna |
| 037 | Zsh | 210819T122435Z | roblogic |
| 080 | Java JDK | 210819T101011Z | mindover |
| 020 | APLDyalog Unicode | 210906T162154Z | wasif |
| 095 | SNOBOL4 CSNOBOL4 | 210823T112033Z | user1004 |
| 056 | Python 2 | 210804T133951Z | ElPedro |
| 049 | Excel | 210804T161625Z | Axuary |
| 010 | Jelly | 210804T090402Z | Unrelate |
| 040 | Perl 5 | 210806T000408Z | Kjetil S |
| 028 | PowerShell Core | 210804T221332Z | Julian |
| 009 | Vyxal j | 210805T122830Z | Aaroneou |
| 052 | Python 3 | 210804T081043Z | Jitse |
| 038 | Ruby | 210804T183715Z | Kirill L |
| 086 | PHP F | 210805T062934Z | Jaydeep |
| 037 | K oK | 210804T120329Z | wasif |
| 032 | Haskell | 210805T011126Z | lynn |
| 057 | brainfuck | 210805T003522Z | Hand-E-F |
| 035 | Haskell | 210804T194243Z | AZTECCO |
| 063 | C gcc | 210804T194642Z | AZTECCO |
| 067 | Wolfram Mathematica | 210804T182514Z | polfosol |
| 008 | Husk | 210804T092238Z | Dominic |
| 1715 | J | 210804T105314Z | xash |
| 068 | C gcc | 210804T141419Z | Noodle9 |
| 025 | Retina 0.8.2 | 210804T135534Z | Neil |
| 012 | Charcoal | 210804T101115Z | Neil |
| 008 | Stax | 210804T100325Z | Razetime |
| 088 | M4 | 210804T095258Z | user1004 |
| 010 | Vyxal jr | 210804T091351Z | wasif |
| 037 | JavaScript | 210804T090555Z | tsh |
| 011 | 05AB1E | 210804T085313Z | ovs |
| 010 | Japt | 210804T084640Z | Shaggy |
| 059 | PHP F | 210804T082729Z | Kaddath |
| 041 | Python 2 | 210804T081623Z | xnor |
Vyxal 3, 11 bytes
ƛ')×Ꮬ:-p⊖“,
ƛ')×Ꮬ:-p⊖“,
ƛ # map over implicit range 1..input
')× # ")" times that number (it's too many times but it'll get trimmed later)
Ꮬ:-p # prepend ":-"
⊖ # take the first n chars
“, # display one per line
💎
Created with the help of Luminespire.
<script type="vyxal3">
ƛ')×Ꮬ:-p⊖“,
</script>
<script>
args=[["1"],["2"],["5"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
Vyxal j, 7 bytes
‛):‹eǓ¦
using the latest and greatest vyxal 2 we can shave off another two bytes thus beating all other answers
TI-Basic, 40 35 27 bytes
Input N
Disp ":
":-
For(I,2,N
Disp Ans
Ans+")
End
-5 bytes thanks to MarcMush
-8 bytes thanks to MarcMush
Zsh, 53 39 37 bytes
a=:-;for n ({1..$1})a+=\)&&<<<$a[1,n]
Try it online!
39 bytes
53 bytes
Realised I was wasting bytes by doing 2 loops when one would suffice.
Java (JDK), 82 80 bytes
String a(int n){return(n>1?a(n-1):"")+(":-"+")".repeat(n)).substring(0,n)+"\n";}
Recursively append longer smileys. A different approach might be shorter...
-2 thanks to ceilingcat!
APL(Dyalog Unicode), 20 bytes SBCS
{,\⍵⍴':-',')'⍴⍨|⍵-2}
Monadic function
{...} monadic function, takes n on right
⍵-2 n minus 2
| abs (No. of braces, call it x)
⍨ swap x with
')' brace for
⍴ dyadic reshape to get x braces
, concat with
':-' smiley head
⍵⍴ take first n (monadic reshape)
,\ prefixes (ravel scan)
SNOBOL4 (CSNOBOL4), 109 95 bytes
n =input
b s =gt(n,1) char(10) ':-' dupl(')',n - 2) s :f(c)
n =n - 1 :(b)
c output =':' s
end
Python 2, 56 bytes
i=input()
o=':-'+')'*i
for x in range(1,i+1):print o[:x]
Without the leading newline
Python 2, 54 bytes
i=input()
o=':-'+')'*i
for x in range(i+1):print o[:x]
Never going to be a winner. Just an alternative approach.
55 bytes
lambda x:'\n'.join((':-'+')'*x)[:x]for x in range(x+1))
Another alternative using a lambda, surprisingly longer than using input(). It's that join() that's expensive.
Excel, 37 49 bytes
+12 bytes to accommodate clarification that the output should be one string
=CONCAT(LEFT(":-"&REPT(")",A1),SEQUENCE(A1))&"
")
This returns one string as opposed to the earlier version which returned multiple cells each containing a string. Due to the Excel string limit, this only works for n <= 254.
=LEFT(":-"&REPT(")",A1),SEQUENCE(A1))
Previous version that works for n <= 32767.
Jelly, 10 bytes
“:-)”ṁ«\)Y
) Map over (the range from 1 to) the input:
“:-)”ṁ Mold ":-)" to the shape of the argument, cycling its contents.
«\ Scan by minimum: replace anything to the right of ) with ).
Y Join on newlines.
Thanks to Jonathan Allan for salvaging my first attempt, ”)xⱮa⁾:-Y, for another 10-byter:
Jelly, 10 bytes
”)xa⁾:-ṁ)Y
) Map over (the range from 1 to) the input:
”)x Repeat ")" by the argument.
a⁾:- Zipwith-vectorize logical AND with ":-":
overwrite the first two characters with ":-".
ṁ Mold to the shape of the argument, trimming the extra "-" for 1.
Y Join on newlines.
PowerShell Core, 43 33 28 bytes
':-'+')'*"$args"|% *ve @args
Saved 10 bytes thanks to mazzy!
Saved 5 bytes by:
- removing gratuitous parenthesis
- using
Removeinstead ofSubstring - using splatting
Vyxal j, 9 bytes
⇩\)*‛:-p¦
Wasif said I should post my 9-byter as my own answer, but I thought it was too similar to his, so I got rid of the map lambda and the slice, just because why not. :P
Explanation:
⇩ # x = input - 2
\)* # Push a 'x' long string of ')'
‛:-p # Prepend the string ':-'
¦ # Prefixes
# 'j' flag - Join top of stack on newlines and print
PHP -F, 86 bytes
Without any predefined funcation!
for($n=0;$n<$argn;$n++){echo':';for($i=1;$i<=$n;$i++){echo$i>1?')':'-';}echo PHP_EOL;}
Thanks.
K (oK), 37 bytes
{({(":-",(x-2)#")")[!x]}'!x+1)[1+!x]}
My first non trivial K answer, a lot of room for inprovement.
brainfuck, 57 bytes
This assumes the initial memory location contains n in binary (0x05 == 5). The TIO link allows a single ASCII character as input and converts it to binary.
->>++++++++[-<+++++++>]<++.<[->-------------.----<[->.<]]
Wolfram Mathematica, 67 bytes
Column@With[{n=#},":-"<>")"~StringRepeat~n~StringTake~#&/@Range@n]&
For some reasons unbeknownst to me, TIO doesn't display the list in column form. But if you run it in Mathematica, it will generate the desired result.
Explanation:
s=":-"<>StringRepeat[")",n] (* generates the main string *)
StringTake[s,#]& /@ Range[n] (* a list of substrings up to length n *)
Husk, 11 10 9 8 bytes
Edit: -1 byte simultaneously spotted by Razetime
↑ḣ¡→":-)
":-) # the string ":-)"
¡ # construct infinite list by repeatedly appending
→ # last element of list so far;
ḣ # now make list of all prefixes,
↑ # and take number of elements equal to input
J, 17 15 bytes
-1 thanks to Jonah!
[:]\$!.'('&':-'
Reshape :- with fill ( to length n. [:[\ return each prefix.
C (gcc), 68 bytes
i;f(n){char*s=calloc(n,4);for(s[i=0]=58;n--;s[i]=i++?41:45)puts(s);}
Retina 0.8.2, 25 bytes
.+
$*)
^.
:
:.
:-
.
$`$&¶
Try it online! Explanation:
.+
$*)
Start with n chins.
^.
:
Change the first chin into eyes.
:.
:-
Change the second chin, if any, into a nose.
.
$`$&¶
Output all of the nontrivial prefixes.
Charcoal, 12 bytes
NθG↓→θ⁺:-×)θ
Try it online! Link is to verbose version of code. Explanation:
Nθ
Input n.
G↓→θ
Draw a triangle of size n.
⁺:-×)θ
Paint the triangle using a smiley with n chins.
M4, 88 bytes
Just a port of the syntax in OP.
define(g,`ifelse($1,2,,`)g(decr($1))')')define(f,`ifelse($1,1,:,`f(decr($1))
:-g($1)')')
Usage
f(number here)
05AB1E, 11 bytes
…:-).ÞI£Jη»
Or, for the same length:
')ׄ:-쨨η»
…:-) # string literal ":-)"
.Þ # cycle last character to create infinite list
I£ # take the first input characters
J # join into a string
η # take all prefixes
» # join by newlines
')× # repeat ")" input times
„:-ì # prepend ":-"
¨¨ # remove the last two characters
η» # join the prefixes by newlines
Japt, 11 10 bytes
Outputs an array of lines.
õî":-"ú')U
õî":-"ú')U :Implicit input of integer U
õ :Range [1,U]
î :For each slice the following to that length
":-" : Literal string
ú')U : Right padded with ")" to length U
PHP -F, 59 bytes
for(;$i<$argn;)echo$i++?":-".str_repeat(")",$i-2)."
":":
";
Straightforward stuff.. Probably golfable a bit more, I'll try other things later
Python 2, 41 bytes
s=':-'
exec"print s[:-1];s+=')';"*input()
42 bytes
s,c=':-'
exec"print s;s+=c;c=')';"*input()
43 bytes
s=':'
exec"print s;s+='-)'[s>':'];"*input()

