6 kyu

Arithmetic Progression of Primes

84 of 93amekh2
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Nice coding challenge of the series as well, it takes a while to figure this one out.

  • ejini战神 Avatar

    Python new test framework should be used

  • ejini战神 Avatar

    Range of inputs should be specified

  • user9644768 Avatar

    Ruby 3.0 should be enabled, see this to learn how to do it

  • Voile Avatar

    Ruby random tests are raising errors by itself:

    main.rb:21:in `s0lver': private method `select' called for nil:NilClass (NoMethodError)
        from main.rb:51:in `block (2 levels) in <main>'
        from main.rb:46:in `times'
        from main.rb:46:in `block in <main>'
        from /runner/frameworks/ruby/cw-2.rb:55:in `block in describe'
        from /runner/frameworks/ruby/cw-2.rb:46:in `measure'
        from /runner/frameworks/ruby/cw-2.rb:51:in `describe'
        from main.rb:17:in `<main>'
    
  • lechevalier Avatar

    What if 2 arithmetic progression have the same start? Should we return only the first or both? And in which order? I have seen nothing in description about this.

  • KevyD Avatar

    Just a quick question - how many 'random' tests are there? I've up to 33 tests passed only for the overall to fail due it breaching the 12s boundary. Now this is my first python code snippet, but I figure if the algorithm works well enough to pass all the tests it reaches, maybe something needs to be added to the description covering the time requirements? Or is it possible that I'm getting too many random tests?

    Cheers Kevin

  • anter69 Avatar

    Ruby tanslation kumited -- please check and approve

  • anter69 Avatar

    The expected solution returns primes outside the given range (and yes, I checked, actual and expected are not swapped here):

    prime(4912, 6817):

    [[5021, 5261, 5501, 5741, 5981, 6221], [5081, 5171, 5261, 5351, 5441, 5531], [5153, 5483, 5813, 6143, 6473, 6803], [5171, 5381, 5591, 5801, 6011, 6221], [5179, 5479, 5779, 6079, 6379, 6679], [5227, 5437, 5647, 5857, 6067, 6277], [5273, 5483, 5693, 5903, 6113, 6323], [5443, 5503, 5563, 5623, 5683, 5743]]

    should equal

    [[5021, 5261, 5501, 5741, 5981, 6221], [5081, 5171, 5261, 5351, 5441, 5531], [5153, 5483, 5813, 6143, 6473, 6803], [5171, 5381, 5591, 5801, 6011, 6221], [5179, 5479, 5779, 6079, 6379, 6679], [5227, 5437, 5647, 5857, 6067, 6277], [5273, 5483, 5693, 5903, 6113, 6323], [5443, 5503, 5563, 5623, 5683, 5743], [6673, 6703, 6733, 6763, 6793, 6823]]


    prime(5082, 6657):

    [[5171, 5381, 5591, 5801, 6011, 6221], [5227, 5437, 5647, 5857, 6067, 6277], [5273, 5483, 5693, 5903, 6113, 6323], [5443, 5503, 5563, 5623, 5683, 5743]]

    should equal

    [[5081, 5171, 5261, 5351, 5441, 5531], [5171, 5381, 5591, 5801, 6011, 6221], [5227, 5437, 5647, 5857, 6067, 6277], [5273, 5483, 5693, 5903, 6113, 6323], [5443, 5503, 5563, 5623, 5683, 5743]]

  • Blind4Basics Avatar

    New one so that I'm sure you'll see it:

    Congrats! You just invalidated ALL the other solutions! ;p

    Your internal solution is currently wrong:

    prime(9250, 11025): [[10091, 10151, 10211, 10271, 10331, 10391], [10103, 10133, 10163, 10193, 10223, 10253]] should equal []
    

    seeing the requirement, with r2=10000, your list of primes has to go further so that your solution can match lists with big primes numbers. Look at mine: I use a list going up to 100 000 for the biggest primes to seek.

    PS: note that your r2 value goes upper than 10 000, for now.

  • amekh2 Avatar

    Thanks for all your comments so far, I'm updating everything! (this is the first kata I have made so I'm quite unfamiliar with everything)

  • Blind4Basics Avatar

    Seriously? The description isn't even matching what the task really is!

    Generate AN increasing arithmetic progression of six primes a,b,c,d,e,f (within a given range) for which the last term f IS AS SMALL AS possible

    => Meaning: we should generate only ONE SINGLE list. And that's absolutely NOT what is expected!

    And so we actually have to generate ALL the sequences, but you have then to tell about the order they have to be generated.

    EDIT: well, That's actually already in ZED's issue. Let say I leave it here to really emphasize it... ;)

    EDIT²: Well, lets make that post more usefull with another problem:

    What about a range where no such arithmetic progression is possible? => tell in the description that an empty list is the default ouput.

  • Blind4Basics Avatar
    • solution setup is wrong: def prime(... instead of def primes(...
    • expected and actual are swapped (both in sample tests and test cases)
  • ZED.CWT Avatar

    Needs tests with larger range (eg. 0,1000). And you need to specify

    • Are lower/upper limits inclusive or exclusive.
    • What the expected results are.

    According to your code, you are expecting to return all possible progressions. You need to clearify it in the desc.

  • ZED.CWT Avatar

    Needs Random Tests.