Skip to content

Commit 8b10e93

Browse files
authored
Merge pull request #5 from SpecterOps/add-python
Add python
2 parents 022a04f + 51afee2 commit 8b10e93

8 files changed

Lines changed: 31 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.vscode
22
.idea
33
.DS_Store
4-
4+
__pycache__

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ you are encouraged to deviate from Eratosthenes's algorithm, modify the
1111
existing functions/methods, or anything else that might showcase your ability;
1212
provided the following requirements are satisfied.
1313

14-
You must author your work in Go, JavaScript/TypeScript, or C# - all
14+
You must author your work in Go, JavaScript/TypeScript, Python, or C# - all
1515
other language submissions will be rejected. Stub code has been provided, so
1616
please choose from one of the provided language stubs that is most
1717
relevant to your skill set and the position you are applying for.
@@ -24,6 +24,7 @@ relevant to your skill set and the position you are applying for.
2424
- Go: `go test ./...`
2525
- C#: `dotnet test Sieve.Tests`
2626
- Javascript: `npm run test`
27+
- Python: `python -m unittest test_sieve.py`
2728
- Your solution is committed to your project's `main` branch, no uncommitted changes or untracked files please
2829
- Submit the link to your public fork for review
2930

csharp/Sieve.Tests/UnitTest1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void TestNthPrime()
1616
Assert.AreEqual(17393, sieve.NthPrime(2000));
1717
Assert.AreEqual(15485867, sieve.NthPrime(1000000));
1818
Assert.AreEqual(179424691, sieve.NthPrime(10000000));
19-
//Assert.AreEqual(2038074751, sieve.NthPrime(100000000));
19+
//Assert.AreEqual(2038074751, sieve.NthPrime(100000000)); not required, just a fun challenge
2020
}
2121
}
2222
}

go/pkg/sieve/sieve_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestNthPrime(t *testing.T) {
1818
assert.Equal(t, int64(17393), sieve.NthPrime(2000))
1919
assert.Equal(t, int64(15485867), sieve.NthPrime(1000000))
2020
assert.Equal(t, int64(179424691), sieve.NthPrime(10000000))
21-
//assert.Equal(t, int64(2038074751), sieve.NthPrime(100000000))
21+
//assert.Equal(t, int64(2038074751), sieve.NthPrime(100000000)) not required, just a fun challenge
2222
}
2323

2424
func FuzzNthPrime(f *testing.F) {

javascript/Sieve/sieve.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ describe("Sieve", () => {
1111
expect(sieve.NthPrime(2000)).toBe(17393);
1212
expect(sieve.NthPrime(1000000)).toBe(15485867);
1313
expect(sieve.NthPrime(10000000)).toBe(179424691);
14-
//expect(sieve.NthPrime(100000000)).toBe(2038074751);
14+
//expect(sieve.NthPrime(100000000)).toBe(2038074751); not required, just a fun challenge
1515
});
1616
});

python/sieve/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .sieve import Sieve

python/sieve/sieve.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Sieve:
2+
def __init__(self) -> None:
3+
pass
4+
def nth_prime(self, n: int) -> int:
5+
pass

python/test_sieve.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import unittest
2+
from sieve import Sieve
3+
4+
class SieveTest(unittest.TestCase):
5+
6+
def test_sieve_nth_prime(self) -> None:
7+
sieve = Sieve()
8+
self.assertEqual(2, sieve.nth_prime(0))
9+
self.assertEqual(71, sieve.nth_prime(19))
10+
self.assertEqual(541, sieve.nth_prime(99))
11+
self.assertEqual(3581, sieve.nth_prime(500))
12+
self.assertEqual(7793, sieve.nth_prime(986))
13+
self.assertEqual(17393, sieve.nth_prime(2000))
14+
self.assertEqual(15485867, sieve.nth_prime(1000000))
15+
self.assertEqual(179424691, sieve.nth_prime(10000000))
16+
# self.assertEqual(2038074751, sieve.nth_prime(100000000)) not required, just a fun challenge
17+
18+
def test_sieve_fuzz_nth_prime(self) -> None:
19+
pass

0 commit comments

Comments
 (0)