Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 1
    D'oh! A straightforward del sieve[::item] is much better than my convoluted "set to-be-deleted items to zero and then filter". +1. Commented Mar 19, 2010 at 5:45
  • Can't believe I did not think of that! Surely shows how the simplest solution in Python is often the best/fastest. Combined with Mark Dickinson's early termination the solution I edited in in my original answer worked fine within the time limit (it scored 0.58 seconds with the test set)! Commented Mar 19, 2010 at 6:43
  • I'll just check if I can get stubbscroll's or Rex Kerr's suggestions running faster then this (this calculates all 3000 of them in 0.0104 on average on my machine) but otherwise I'll be sure to flag this as accepted answer this weekend! Commented Mar 19, 2010 at 6:47
  • @ChristopheD, Now the fun challenge is to figure out how to solve the problem 10 times faster still :) Commented Mar 19, 2010 at 6:48
  • @gnibbler: lol, very true. The fastest python 2.6.2 solution is in @ 0.04 seconds ;-) Commented Mar 19, 2010 at 7:01