Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Spit my coffee out seeing this! Amazing :)
Literally decided to do -1 lines.
Nice.
Dude! It's the first time I've seen using lambda inside a class instead of a function!
You managed to create the smallest and, somehow, easiest answer to analyse of us all!!!
Sir, you got yourself a huge fan in me!
Best practice and Clever! You got it!
I think ListNode... { this.v = value;} will allow external code to mutate the value, therefore violates the constraint of the problem. I might be wrong or there might be a better way... I ended up making a private variable so that no code can set the value after instantiation.
function ListNode(value, next) { this.getValue = function() {return value }; this.n = next; }
Feel free to add it yourself - it's open for contributors. It shouldn't be too hard to port the poly drawing part too - it just spits out some pretty basic svg.
Could you add a (very basic) python version? It would make solutions a bit less cumbersome that javascript…
Thanks!
This comment is hidden because it contains spoiler information about the solution
I think as far as "best practices" are concerned, it's what the code actually does that matters when voting, not the actual style of code employed when writing the solution.
I don't think people are marking submissions as "clever" because someone deleted whitespace/newlines and shortened 3 lines of code into 1, they're voting "clever" because what the code is doing is clever - regardless of syntax, style and other cruft. It just so happens that in a lot of cases, particularly these easier problems, "clever" solutions consist of one line. In addition a lot of people seem to be going for code golf, though there's no benefit of doing that.
In an actual codebase I think that, while most people would spread this snippet of code out, it would nonetheless be considered "best practice".
This comment is hidden because it contains spoiler information about the solution
Not that there's anything wrong with that answer, but I fail to see why it gets upvoted 7 times as best practice compared to others.
I'd rather have this one (http://www.codewars.com/kata/reviews/53952000369894e4f10007ab/groups/539823dfc729da37a4000374) which is more readable (at least in JavaScript where there's a fair amount of syntactic noise. In other more expressive languages (e.g. a ML), even a one-liner would be acceptable and best practice.
Anyways, just pointing out: while this is perfectly correct (and fine for a trivial exercise like this one), I'd rather not people consider it too "best practice" (same for http://www.codewars.com/kata/reviews/53952000369894e4f10007ab/groups/53952f8ca3ba5f5632000f95).