6 kyu
Prime Cycles
174 of 201neuralStep
Loading description...
Puzzles
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.
Nice
When does a sequence ends ? My algorithm finds max until same number is generated second time. I pass 20 tests and then fails due my maximum is smaller than expected. Could someone please explain me when method should return maximum value :)
expected:<615043> but was:<1230086>
Most likely, you are not including the initial n value. It also happened to me :)
@jrico, i changed from
return max
toreturn Long.max(n, max)
and still my algorithm can't find the maximum value in a sequence for numbers bigger than 1_000_000I am returning maximum value when same number occurences second time in the sequence. You did the same ?
@Alexenon Yes I did. The sequence starts at n and you genenerate new values until a value is already seen in the sequence. Pick the maximum of them. This should work even for big (long) numbers.
Test cases in Python would be better if they were factorized to avoid repetitions. It's easy to create a generic function
dotest
that does the job for all tests, fixed and random. That would lighten the tests page and would be much more readable. Something like:Not that interesting to create a function just to encapsulate a call to another method although I agree on the fact that test cases in example can be inserted in a list with an explicit error message.
You should add in description that this procedure always generates a cycle.
How would you prove that it always generates a cycle?
Note that there are interesting cycles, for instance from 4668999 we get:
You can find this Math StackExchange post interesting
1/ you didn't add the tests with small numbers to the test cases part 2/ you didn't add 1 or 2 tests with big number to the sample tests part 3/ I didn't notice before, but you have to use the new test framework, for python
side note: if the test cases get run alphabetically (by their description) it's best to assure those smaller tests are run before the biger ones
I have added tests with small numbers to test cases, big numbers to sample tests, and am now using the test framework for python.
:+1:
No random tests
Why are random tests needed? And how would you even evaulate the correct answer for a random input?
damn... I thought those were random tests... (see below). They are required because otherwise a user can cheat the kata very easily without actually solving the task.
to see how to do them, look a the tests suites of katas (recent ones) you already solved.
Random tests added for both Python and Java.
Hi,
I'm not sure at all what you mean in your first point. What fixed tests? What test cases?? All the tests in the test cases use big numbers.
See above: I took the tests for random whil they are fixed ones... x/
=> you should add the sample tests with small inputs too in the "test cases" part ; you should add one or two tests with bid numebrs in the "sample tests" (might be named "example tests" in the edit panel) ; and add random tests, finally
Resolved.
.
The actual/expected values are flipped in Python.
I've resolved this.
Not clear what happens with 13: 1st prime is 2, 3rd is 5, multiple is 10. Now what? what do we do with the zero?
Sorry should have mentioned this case in the Kata - 0 means no contribution to product so 10 would just be 1st prime => 2
OK cool, add it to the description... Good luck with your 1st kata!
Added and did some rewording too. Thanks!