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.
It depends on what you're working on. If this function were part of a website backend counting characters in usernames or something, it doesn't really matter at all. But if this is a helper function that is responsible for comparing billions of base pairs in genetic sequencing or part of a stock trading platform where microseconds matter, then you need to rethink it.
Would it matter? I assume itll be a O(2n) vs O(n) but I'm not sure if that's a big deal.
You know that trolls starve when not fed? I do not know if the OP is a troll or not, but whenever you think you see one, just don't feed it. You reply, you lose.
what a troll lol, you're just mad you had to use a loop like a LOSER. good for you though commenting an explanation of what an odd number is, really top notch best practice stuff. Do you usually go on codewars before or after your shift at google?
Simpler, faster algorithms are more maintainable and consume fewer resources. Seems to me like you didn't notice that there was a more efficient solution than the one you created, and now you're trying to turn that into a virtue instead of trying to learn from it. OK, so you didn't optimize the algorithm as much as it can be optimized. It didn't matter for this problem. But if you want to learn to write efficient code, I think this is a really valuable lesson to learn.
in every world outside your little computer science problem. your problem is that you don't see beyond your little world of computer science and math. that's why somebody without a CS degree is signing your paycheck.
closed form solutions have limited application in the real world. the real world is non-linear. nobody gives a crap about the sum of first n-odd numbers in any real world application. in my view the purpose of the kata is to recognize the pattern in the numbers and think through how to replicate the pattern in code, and then solve the pattern. the purpose of this 7-kyu kata is to help new programmers learn list comprehension, range() and other features of the python language. newbies can't learn programming from these "clever" math tricks. i can only imagine somebody new to programming spend an hour solving this, only to be bamboolzed by the 4 character "best practices" solution.
i'm not a genius like you though, i don't pretend to know everything.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
lol, ok.
well than we would write out the code to get that anwser for the client, but when the client doesnt specify what they are looking for you cant expect the programmer to read their mind. Its like getting ice cream if you just ask for ice cream and get vanilla but you wanted mint choclate how was I supposed to know.
perfect
C#:
From the description:
The elements in the returned array (
$k_i$
) must be strictly greater than1
.However, your array does contain
1
at the end.Not a kata issue.
Rust:
From the description:
The elements in the returned vector (
$k_i$
) must be strictly greater than1
.However, your vector does contain
1
at the end.Not a kata issue.
Rust:
There is no such restriction in the description.
From the description:
The elements in the returned vector (
$k_i$
) must be strictly greater than1
.However, your vector does contain
1
at the end.Not a kata issue.
test cases are flawed. Remainder can not be greater than the largest k.
assertion failed:
(left == right)
left:
([22, 13, 10, 8, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1], 28)
,right:
([22, 13, 10, 8, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2], 199)
tests::random_tests
assertion failed:
(left == right)
left:
([29, 17, 12, 9, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 34)
,right:
([29, 17, 12, 9, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2], 349)
Loading more items...