5 kyu
The Primes as a Result of the Longest Consecutive Sum I
105 of 193raulbc777
Loading description...
Performance
Algorithms
Mathematics
Data Structures
Arrays
Fundamentals
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.
Haskell translation
Thanks for the kata, I really appreciated it.
Nice kata, but passed after atleast 5/6 timeouts!! That means atleat 5 improvements in same kata, up on almost same code, but after changes it looks a lot better now.
Honestly, I think this should be a 4 kyu kata. It, but not having a performance threshold, should be a 5 kyu already. Absolutely love it, by the way. I fell in love with the idea of the problem. Very satisfied.
Ranks of approved katas cannot be changed.
Not sure what I'm doing wrong here, but the execution of the code is timing out. I've tested it on PyCharm, it works.
It may work but be too slow.
COBOL translation + description unified and slightly reworded (the current description includes blocks language specific only for Python; tried to make it clearer and more synthetic + changed name of the parameter to
n
, and nomax_val
, since it's its name in solution set ups + removed the names of the functions / procedures, there may have many different depending on the languages)..
Not sure why prime_maxlength_chain(100) = [41], ( 2 + 3 + 5 + 7 + 11 + 13 = 41 , (6 addens)) since 97 = sum([2, 3, 5, 7, 11, 13, 19, 37]) and has 8 addens.
Also has 8 elements (addens): 89 [2, 3, 5, 7, 11, 13, 17, 31] 83 [2, 3, 5, 7, 11, 13, 19, 23]
I haven't solved it yet, but maybe because they're not consecutive?
You are right!! I just read it again and notice the consecutive!! Thank you!!
Ruby version expects
[499]
forval_max = 500
, which contradicts the description and the Python version.I suggest to add this fixed test to Ruby (similar to Python):
This comment has been hidden.
Add a fixed test for
val_max < 5
(expecting[]
)wrong: these should expect [5] or [2] or [] ;)
val_max < 5
cannot expect[5]
(because it's not smaller than 5... :-)I would argue
[2]
also, because "consecutive" implies that there must be at least 2 primes (as a single number cannot be "consecutive") -- this could be clarified in the description.So the only solution left is
[]
about sum of single terms, it's effectively subject to how you take the definition of "consecutive". But imo that would make more sense to have something totally generic, so 1 term should be ok.
(edit: yeah, not [5], but [2,3] for 4, actually ;) )
My respect for all the users that have solved this kata. I'm very thankful for your time and excelent solutions. As this kata was authored some years ago staying frozen in beta mode due to a strange issue of CW system (the kata level voted was unseen but now recovered), some changes have been introduced:
In order to have best quality standards, the output is now a unique format type: an array, included the results for only one number. (Python, Javascript and Ruby)
The upper bound limit was moved up from 20.000 to 500.000 to have a more challenging version. (Python, Javascript an d Ruby)
The solutions are allowed, since now in Python 3 only. Preparing ourselves for a close future.
could you be planning on making it harder? If not, I might create an "hardcore" version
This comment has been hidden.
but don't you have a version II planned? (title of the kata)
This comment has been hidden.
ok, I'll check if existant solutions can be bashed by far enough.
Could definitley go (much) higher ;-)
damn! Raul! x) please, get rid oof this moving output type! lists and only lists, please! ;)
And it would be nice to have information about the boundaries of the tests.
note: py 2.7.6 is the default for now, but py3 (which is slower) is available. Wouldn't that be prettier to discard 2.7.6, allow 3.6 and resiqer the perf tests if needed?
Hi B4B,
Hope that you'll enjoy it. :) Cheers
did you forbid python 2, too?
EDIT: nope, you didn't. you have to do it if an algo with a not ideal time complexity can pass the tests in python 2.7 (which is faster).
Do you remember how to do it?
Noo, : )
in the preloaded part ;)
This comment has been hidden.
.
Thoroughly enjoyed this. Thanks!
Hi @KenKamau. Could you rank this kata?. Let's see if it can be approved in some days. :) Thanks.
I did. 5 kyu.
I'm not sure why the rank is not showing.
Thanks. I thought that no one ranked it. :)
Known CW issue: https://github.com/Codewars/codewars.com/issues/1208
Thanks a lot for publishing it.
Enabled python 3