Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sieve: sync with canonical data #1811

Merged
merged 2 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/sieve/example.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def sieve(limit):
def primes(limit):
prime = [True] * (limit + 1)
prime[0] = prime[1] = False
for i in range(2, int(limit ** 0.5) + 1):
Expand Down
2 changes: 1 addition & 1 deletion exercises/sieve/sieve.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def sieve(limit):
def primes(limit):
pass
12 changes: 6 additions & 6 deletions exercises/sieve/sieve_test.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import unittest

from sieve import sieve
from sieve import primes


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class SieveTest(unittest.TestCase):
def test_no_primes_under_two(self):
self.assertEqual(sieve(1), [])
self.assertEqual(primes(1), [])

def test_find_first_prime(self):
self.assertEqual(sieve(2), [2])
self.assertEqual(primes(2), [2])

def test_find_primes_up_to_10(self):
self.assertEqual(sieve(10), [2, 3, 5, 7])
self.assertEqual(primes(10), [2, 3, 5, 7])

def test_limit_is_prime(self):
self.assertEqual(sieve(13), [2, 3, 5, 7, 11, 13])
self.assertEqual(primes(13), [2, 3, 5, 7, 11, 13])

def test_find_primes_up_to_1000(self):
self.assertEqual(
sieve(1000), [
primes(1000), [
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127,
131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191,
Expand Down