7 kyu

Simple Prime Number Generator

Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • HamzahTheLegend Avatar

    This comment has been hidden.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • sirapu Avatar

    I am running in a timeout when submitting my solution. I tested it for a limit of 1500 without running in a timeout. Which is the highest number use in the tests? Thx

  • erdos2n Avatar

    I highly suggest this kata moves from 7kyu to 5kyu or 6kyu for alignment. Many people may look for simple solutions, since it is 7kyu. I think putting it in 5 or 6 will allow people to properly gauge the work.

    • Raphango Avatar

      Agree... I think 6 kyu is fair enough... =)

    • erdos2n Avatar

      Same here. I'm still slightly new to codewars, but when I see 7, I assume a one to 5 liner. This was not, hahaha. Good kata and thanks for replying! I just published my first one yesterday if you wanna check it out and give feedback.

    • Blind4Basics Avatar

      6 lines. ;)

      Generating primes is actually so (much) a common task on CW that, after a few weeks/months, you will look back at this one and gently laugh at your own comment. ;) (but well... 6 kyu wouldn't have hurt, I guess, yes. ;) )

    • user5286943 Avatar

      there is a difference between a person trying to solve a 7kyu, i guess, it is not at all a 7 kyu at least needs to be 5 kyu. of course for "dan's" it might be a single line, but the complexity level should be set according to a person most likely to solve it i.e. a newbee.

  • lechevalier Avatar

    This comment has been hidden.

  • lechevalier Avatar

    Too bad, I was also hoping for a kata on generator. There is actually too much kata asking for a list of prime numbers under a number n.

    • anter69 Avatar

      not really in python... (I checked)

    • Raphango Avatar

      Sorry guys for the frustration..

    • lechevalier Avatar

      Well at least I made an half sieve for this one!

    • Blind4Basics Avatar

      Too bad, I was also hoping for a kata on generator.

      You'll have to learn a bit of Java: those ones are what you thought about ;)

    • lechevalier Avatar

      Well I'm using Java everyday for work so I tend to use only Python when solving recreative katas on CW. However if you make a translation... :-P

    • Blind4Basics Avatar

      if you help me with streams, I could do them and translate them... ;p (Java is a pin in the ass, for me ;/ ). I did not try those yet, because of that. Maybe you could tell me if there is a way to duplicate a stream? (that bothers me since a moment, this one)

      BTW, did you try those? (I'm searching for candidates, yes! ;) )

    • lechevalier Avatar

      Stream concept is that you cannot duplicate it because it computes elements on the run. Of course, you can still buffering elements in another stream elements you consume - that's how itertools.tee works. You should have a look at this answer quite useful.

      As for your katas, I will try original versions first as they are still in beta and go for yours right after!

    • Blind4Basics Avatar

      Thx for the link.

      Finally, I have the impression that those katas (about primes / at least the easier one) may do the exact same trick than the present one: use a generator, backed up by some structure. Or not... I don't know... ;)

      I will try original versions first

      Yeah sure. But be aware that the original of SG-1 is actually broken and undoable (unless you generate paths in the exact same way/order than the internal solution, despite what is said in the description. That's why I made mine) ;)

    • lechevalier Avatar

      use a generator, backed up by some structure. Or not...

      Or not ;-)

      original of SG-1 is actually broken

      Have seen that, however there is also an "improved" version made by same author, testable this time!

    • Blind4Basics Avatar

      Or not ;-)

      Damn... Any leads for me? ;o

      however there is also an "improved" version made by same author

      Errrr... That's mine, actually!!! ;-D

    • lechevalier Avatar

      Maybe! I have to test if it is optimized enough. Will continue this discussion on the concerned kata ;)

      Errrr... That's mine, actually!!! ;-D

      Oopsie!

    • Voile Avatar

      Hi!

      Since the author of this kata is not gonna be around for some time (I know him personally), and only you two have solved the kata in the Python version (I think?), can you please approve the Ruby and C# translations I just wrote for the kata? :)

  • anter69 Avatar

    Kata approved! :-)

  • anter69 Avatar

    Multiple issues:

    • you mention generators, but happily except a list (see my solution)
    • python function names should use snake_case, not camelCase (fixed)
    • need random tests (added)
    • your 'complete solution' is very ineffective (fixed)

    Furthermore, there are many prime based katas, but I don't complain about it being a duplicate, because none of them are so simple (in python).

    But if you could really turn it into a generator type kata (and test the results properly), it could be more interesting.