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 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Just for fun I asked ChatGPT and got a Python in 65 chars:
Since I'm most familiar with JavaScript I'll try that myself now
Poor ChatGPT, it's always so close but so far. This doesn't meet spec :)
It doesn't print the bottom row of ' | | ', and it misses the leading spaces.
Fixing it produces:
Which is 102 characters, so longer than before. Like I said, I tried the list comp route. You get rid of some stuff, but you add more unfortunately.
However, both me and ChatGPT made the mistake of printing spaces after, which tbh isn't necessary. That can give a bit of a boost:
Which is 90, but applying it to my og answer:
Yields 82.
Putting the loop on one line saves a couple characters though:
Gets it to 80
Oh I totally missed that the trunk was part of the spec, gotta fix my own answer too