6 kyu
Odd/Even number of divisors
143 of 1,370sergeyn
Loading description...
Mathematics
Performance
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
Great @akar-0! The random block has been updated.
Seems ok. I advice you to publish a new fork, or your changes may be lost in a future update. Just publish the changes in a new fork (with a minor change, whatever, it may be a single space added, so the fork is different from the parent) and give the link here, I (or someone else if he's faster than me) will approve it.
i find solution but it running time out. How i can fix it
You need to find a better method. Naive solutions don't pass this kata. See this if it can help: https://docs.codewars.com/training/troubleshooting/
C++ Translation
Please see issue above.
Haskell translation
Thanks :)
i found a solution to the task, but the numbers in the attemps are too big, so that the run is running out of time. D:
You need to find a different solution then...
COBOL translation (author gone).
approved
Python new test framework should be used (Refer this & this for more detail)
Ruby 3.0 should be enabled (Refer this & this for more detail)
fixed ruby
fixed python, too
Ruby version is using
Test.expect
.This comment has been hidden.
Time complexity should be tested with big input size, not big number of tests.
Set the number of tests to 200 in all languages. Adjusted input range to disallow solutions worse than
O(sqrt(n))
(which was true for Python at least).The description should mention that a linear solution won't pass.
This question should be downgraded by 1 kata.
This comment has been hidden.
@sergeyn, tnx for math kata!
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
If you were to include negative numbers, you must also include negative divisor. And if
n
is a divisor,-n
is also a divisor, so all numbers would have an even number of divisors, meaning there is no point."Divisors" of a number are usually constricted to positive integers.
Why would you suppose that accepting negative inputs means that we also have to consider negative divisors? The description of the kata says "given an integer", not a positive integer. In the examples provided, negative divisors are clearly not included. I stand by the correct solution bring one that considers the positive divisors of any integer.
This comment has been hidden.
This comment has been hidden.
Your code is too slow. The final tests use some really big values for n.
Okay, thank you for confirming that. I just wanted to be sure, I know that CodeWars was having some site issues as well, so I just wanted to identify the actual issue.
Great kata! Thanks
This comment has been hidden.
This comment has been hidden.
I've been getting this error. I'm passing 13 tests then it just stops because of this message: `each': failed to allocate memory (NoMemoryError).
Same here. I think this Kata expects an efficient solution which would probably require a mathematical trick or two.
Great kata!! This is my Java translation.
I've got minor issue while solving this kata. The thing is that code seems working and executing well but the system says: "Process was terminated. It took longer than 6000ms to complete". Is there code speed test as well ?
I assume every of the test sandboxes are having the same timeout value which is 6 seconds. This is from the docs of .Net environment: "The sandbox environment will timeout the code within 6 seconds. In the future, as Codewars expands its abilities, this limitation may be increased in order to handle more complex kata/code challenges."
Thanks for your reply. Seems like my code needs some fixes to run faster )
Nice one, Katas like this that punish brute force approaches are helping me learn better practices. Once you see the pattern, there is a very concise solution.
Translated into Python and JS, if you want to approve them :)
Also, thanks for the awesome kata: it bugged me before I went to bed yesterday night and today I got the right answer while showering: a pattern of constant thinking and mentally sperimenting that I really love ;)
This comment has been hidden.
Thank you for your input
And thanks for your kind reference to my work, sayfidz :)
@sergeyn, may I adjust the kata a bit, just to have it use .assert_equals and thus get more informative error messages?
Sure, go ahead. I am not a proper sensei yet, I guess.
This comment has been hidden.
Yes, it is indeed reversed. Embarrassing.