diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2020-01-02 15:04:34 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2020-01-02 15:04:34 +0100 |
| commit | 05b682fe65d547b1625af8f037753d09e27dc43b (patch) | |
| tree | f794d18bfbb06d0351fc247cd27172270d72beb1 /challenge-041 | |
| parent | 0f7227192a4022423f5ea56b67b7e5af43fe05b3 (diff) | |
| download | perlweeklychallenge-club-05b682fe65d547b1625af8f037753d09e27dc43b.tar.gz perlweeklychallenge-club-05b682fe65d547b1625af8f037753d09e27dc43b.tar.bz2 perlweeklychallenge-club-05b682fe65d547b1625af8f037753d09e27dc43b.zip | |
Challenge 1 Week 41 Python
Diffstat (limited to 'challenge-041')
| -rw-r--r-- | challenge-041/lubos-kolouch/python/ch-1.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-041/lubos-kolouch/python/ch-1.py b/challenge-041/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..e32db9a798 --- /dev/null +++ b/challenge-041/lubos-kolouch/python/ch-1.py @@ -0,0 +1,24 @@ +#!python3 + +import sys +from sympy.ntheory import factorint, isprime +import unittest + +def is_attractive(what): + factors = factorint(int(what)) + return (isprime(sum(factors.values()))) + + +# TESTS + +class PrimeTest(unittest.TestCase): + def test_20(self): + self.assertEqual(is_attractive(20),True) + def test_128(self): + self.assertEqual(is_attractive(128),True) + def test_256(self): + self.assertEqual(is_attractive(256),False) + +if __name__ == "__main__": + unittest.main() + |
