this post was submitted on 23 Jun 2023
9 points (100.0% liked)
Code Golf
171 readers
1 users here now
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
My JavaScript solution - ~~82~~ 103 chars:
~~a=n=>{for(s='',i=1;i<=n;i++)s+=' '.repeat(n-i)+'* '.repeat(i)+'\n';console.log(s)}~~
I'm happy I was able to beat ChatGPT, it had the same strategy but used additional for loops instead of string.repeat(), so it was 113 chars. But I suspect further improvements might be possible with array.reduce or other prototype functions I'm forgetting about.
very cool, but you forgot the trunk
Woops, can you tell my teachers were always on my case for misreading the assignment :P