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.
lochas esi
This is really cool, if you want to waste your coworkers time
Yoo, so unreadable. And one more thing. You don't have a check for the input parameter to be less than zero.
This solution is 8 times slower. "For" and "if" are better.
ты лох
Why Kata test excludes negative number?
Along with already mentioned problems, negative number will break this.
Run your method with Linq implementation ten times for n=50_000_000 and you will see why :) Linq-based solutions usually call for O(n) solutions. The kata can be solved in O(1). Why run a loop
n
times when you can solve the problem witohut a loop?why shouldn't it?
...except it should not be used in this kata.
Linq is my god
This comment is hidden because it contains spoiler information about the solution
I somewhat agree although there's a solution below that just uses new lines a little more effectively with the same methods that I think is easier to read.
Great solution
The second parameter of Range is count, so the range is from 0 to n - 1
Loading more items...