500k recruitment challenge 03-12-2016, 11:32 PM
#1
In honour of 500,000 posts, Serenity is holding a recruitment challenge. The challenge is to create a method that finds all primes under or equal to n.
Constraints:
The following method dictates whether or not a submission passes:
and the scores for my benchmark method:
Bonus points: The method I used is (one of) the most efficient for this task. Correct identification of who devised it and the name of it is +2 points
Submission: PM me (on here or discord) with your entry to submit. If you'd prefer to do this challenge in another language, let me know, and I'll write something up.
Recruitment: The top 50% of entries will be recruited to Serenity
Constraints:
- total time for 1,000 tests under 2 seconds
- average time per test under 0.01 seconds
- get the correct number of primes (1,229 for our test case)
- same result as test method
The following method dictates whether or not a submission passes:
Code:
def benchmark(method):
"""
Used for calculating a pass/fail in Serenity's
500k recruitment challenge
constraints:
- <5 seconds total runtime
- <0.01 seconds average runtime
- correct number of primes (1229 primes <= 10000)
- correct primes (compared to sample method)
"""
time=__import__('timeit').timeit(
'%s(10000)'%method,
setup='from __main__ import '+method,
number=1000
)
res=eval(method+'(10000)')
pss=round(time,6)<5 and time/1000<0.01 and len(res)==1229 and test(10000)==res
return '\n'.join([
method+': '+('Fail','Pass')[pss]+
('',' (distinction'+'+'*(time<0.0025)+')')[time<0.00324851038689],
'Average: '+`round(time/1000,6)`,
'Total: '+`round(time,6)`,
'Score: '+`(((0,3)[pss]+round(5-time,5))*(1,(1.25,1.5)[time<0.0025])[time<0.00324851038689])*10`
])
and the scores for my benchmark method:
Code:
test: Pass
Average: 0.003354
Total: 3.354264
Score: 46.4574
Bonus points: The method I used is (one of) the most efficient for this task. Correct identification of who devised it and the name of it is +2 points
Submission: PM me (on here or discord) with your entry to submit. If you'd prefer to do this challenge in another language, let me know, and I'll write something up.
Recruitment: The top 50% of entries will be recruited to Serenity