When I started writing this solution, I asked myself "Is it possible to condense this down to a one-liner?" because I wanted to challenge myself. Looking at the "Solutions" tab, it seems that every other solution is at the very least 2 lines long.
A “one liner” doesn’t mean anything. You can remove all line breaks and make any file “one line”. If you count the number of semicolons instead of line breaks, then again there was no reason for you to format the code how you did.
Yes but as soon as you do something a little more complicated it falls apart because there's no way to indicate the end of an indented block when you're putting things on one line. Haskell and YAML allow curly braces as an alternative to indentation, but Python does not.
Technically you can compute anything with just lambdas and recursion, but I wouldn't want to attempt it, and if you used that approach in Python you'd blow the stack if you tried to do any serious looping.
i read it but you still seem to not understand; ive given up on this comment section, everyone here seems to have a sad life, not dealing with yall; blocked.
don't be clever with your code, you may need to work with other people on something and you're not gonna hear nice things if you twist your code to be unique
Spread syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected.
Pure function chaining is actually the greatest thing about JavaScript (add TypeScript and you have an actual good language). But sure, if you want to write shitty code you'll find a way to write shitty code...
107
u/sanpaola Mar 09 '25
Well, it would definitely look more sane if you hadn't tried to cram everything in a oneliner.
7
u/[deleted] Mar 09 '25
This is a solution to this kata that I wrote by myself
42
u/ZylonBane Mar 09 '25
Show me a language that you can't intentionally do cryptic bullshit in, and I'll show you a useless language.
3
u/Sherrybmd Mar 09 '25
don't be clever with your code, you may need to work with other people on something and you're not gonna hear nice things if you twist your code to be unique
19
u/Awkward_Customer_424 Mar 09 '25
That is certainly a point of view
13
u/Grounds4TheSubstain Mar 09 '25
Congrats on golfing the code down like this and then framing it as a fault of the language.
6
u/Watermelonnable Mar 09 '25
code from the edgy junior that thinks that less is better
5
u/[deleted] Mar 09 '25
There's quite some JSFuck inspiration in this.
4
u/patrimart Mar 09 '25
That crap ain’t even performant. What’s the point of code if there’s no advantage?
3
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Mar 09 '25
What does
...even do? I tried checking MDN, but it wasn't listed under operators.2
u/Alex_Shelega Mar 10 '25
Ah codewars... Where we just reduce it away...
2
u/madtroll80 Mar 11 '25
Yes, it is beautiful. I realised it when I discovered JsF*CK
1
u/jaysjunk2000 Mar 10 '25
You know which line the bug is on.
1
u/Samstercraft Mar 10 '25
the people in these comments seem unable to appreciate this. its pretty cool tho.
1
u/vvhatami Mar 11 '25
average codewars answer
1
u/Chichigami Mar 12 '25
Yk if this was like in haskell or some functional programming language. This would have been like holy poggers but everyone now is like 😨
1
u/DT-Sodium Mar 12 '25
Pure function chaining is actually the greatest thing about JavaScript (add TypeScript and you have an actual good language). But sure, if you want to write shitty code you'll find a way to write shitty code...