7 kyu
How many twos?
569 of 1,586Nmistrata
Loading description...
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.
Description should be language agnostic. Here is a suggestion for a fix (reworded).
I also made the description language-agnostic using
KaTeX
in my Lua translation but feel free to use the following or another one if you prefer.preview
Task
Write a function that returns the power of
2
in the prime factorization of a positive integer (>= 1
).Examples
copy-paste
# Task
Write a function that returns the power of `2` in the prime factorization of a positive integer (`>= 1`).
# Examples
```
24 should return 3 -> 24 = 2**3 * 3
17280 should return 7 -> 17280 = 2**7 * 3**3 * 5
```
Lua translation ! made description language-agnostic + used
KaTeX
This comment has been hidden.
python updated test framework
Approved
Description should be language-agnostic
This comment has been hidden.
Your recursion is wrong, it always returns the latest
count
This comment has been hidden.
There are two types of timeouts. "Submission timed out" & "Process took longer than 6000ms".
The second one is because of slow code. The first one is usually a connection problem or codewars' servers being too busy.
I am assuming you got the first error since your solution passed when I submitted it. If you get the first error, just try refreshing the page or maybe try again later.
Yep, worked when I tried it later today! Appreciate your help.
No test for 0
"The number passed to two_count (twoCount) will always be a positive integer greater than or equal to 1."
Description explicitly states 0 doesn't need to be accounted for. Marking as resolved
Clojure translation kumited.
Issues with the C# version.
Replace the given code with:
And also replace the given tests with:
I didn't make the C# version so I am a bit confused, is there a reason the parameter has to be a long type instead of int?, none of the tests input a numbers that require more than 32 bits. If there is, should I change the input type for the initial solution, final solution, example tests, and actual tests?
Well it's actually the example
[TestCase(222222222222, Result=1)]
which requires a long. In the final tests it's been replaced with[TestCase(222222222, Result=1)]
so I guess you can just replace this one example test with the one of the final tests.But what needs changing is the given starting code:
As a void return type is clearly wrong.
replaced some code as you suggested
Marking issue as resolved.
Looks good, thank you. :-)
Cheers
C# translation kumited.
"n will always be a positive integer greater than or equal to 1." in the description isn't very clear as you never use 'n' in the description. 'n' could be the input number or the number of 2's in the factorization.
Changed that line to read, "The number passed to two_count (twoCount) will always be a positive integer greater than or equal to 1.". Thanks for the suggestion
Ruby, CoffeeScript, JavaScript and Haskell translations kumited.