diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-11-21 04:57:01 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-21 04:57:01 +0000 |
| commit | 054a1d856f6600be605d149f7830a7426f828fce (patch) | |
| tree | ee38a9bf6eef686793ab957d964d2c70cb4d3ee7 /challenge-191/deadmarshal/python/ch2.py | |
| parent | 7ac92a4a7fd76a307feefe75fcb666f9525e1b7b (diff) | |
| parent | 4a6109910c67852630b4d5b50d2a1bf465cfbeaa (diff) | |
| download | perlweeklychallenge-club-054a1d856f6600be605d149f7830a7426f828fce.tar.gz perlweeklychallenge-club-054a1d856f6600be605d149f7830a7426f828fce.tar.bz2 perlweeklychallenge-club-054a1d856f6600be605d149f7830a7426f828fce.zip | |
Merge pull request #7110 from deadmarshal/challenge191
Challenge191
Diffstat (limited to 'challenge-191/deadmarshal/python/ch2.py')
| -rw-r--r-- | challenge-191/deadmarshal/python/ch2.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-191/deadmarshal/python/ch2.py b/challenge-191/deadmarshal/python/ch2.py new file mode 100644 index 0000000000..30ac0b9f78 --- /dev/null +++ b/challenge-191/deadmarshal/python/ch2.py @@ -0,0 +1,15 @@ +from itertools import permutations + +def is_cute(arr): + for i in range(1,len(arr)+1): + if i % arr[i-1] != 0 and arr[i-1] % i != 0: return False + return True + +def cute_list(n): + arr = list(range(1,n+1)) + count = 0 + for perm in permutations(arr): + if is_cute(perm): count += 1 + return count + +print(cute_list(2)) |
