diff options
| author | drbaggy <js5@sanger.ac.uk> | 2021-12-23 06:52:16 +0000 |
|---|---|---|
| committer | drbaggy <js5@sanger.ac.uk> | 2021-12-23 06:52:16 +0000 |
| commit | 77c3dd4216f84bafa208dd4c67018b3f714a932f (patch) | |
| tree | 9bc87c9f3462785737d165d41f5d3939854dfd26 /challenge-030/paulo-custodio/python | |
| parent | 4a21974fd493b6f19d141c278badf706470682d1 (diff) | |
| parent | 86ddf7b64e4859fc0b00eda0cb7cb0bdb62d12ad (diff) | |
| download | perlweeklychallenge-club-77c3dd4216f84bafa208dd4c67018b3f714a932f.tar.gz perlweeklychallenge-club-77c3dd4216f84bafa208dd4c67018b3f714a932f.tar.bz2 perlweeklychallenge-club-77c3dd4216f84bafa208dd4c67018b3f714a932f.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-030/paulo-custodio/python')
| -rw-r--r-- | challenge-030/paulo-custodio/python/ch-1.py | 16 | ||||
| -rw-r--r-- | challenge-030/paulo-custodio/python/ch-2.py | 19 |
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-030/paulo-custodio/python/ch-1.py b/challenge-030/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..4f15e8d7b5 --- /dev/null +++ b/challenge-030/paulo-custodio/python/ch-1.py @@ -0,0 +1,16 @@ +#!/usr/bin/python3 + +# Challenge 030 +# +# Task #1 +# Write a script to list dates for Sunday Christmas between 2019 and 2100. For +# example, 25 Dec 2022 is Sunday. + +import datetime + +sunday_xmas = [] +for year in range(2019, 2101): + dt = datetime.date(year, 12, 25) + if dt.isoweekday()==7: + sunday_xmas.append(year) +print(*sunday_xmas, sep=", ") diff --git a/challenge-030/paulo-custodio/python/ch-2.py b/challenge-030/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..29da0ffd41 --- /dev/null +++ b/challenge-030/paulo-custodio/python/ch-2.py @@ -0,0 +1,19 @@ +#!/usr/bin/python3 + +# Challenge 030 +# +# Task #2 +# Write a script to print all possible series of 3 positive numbers, where in +# each series at least one of the number is even and sum of the three numbers +# is always 12. For example, 3,4,5. + +import sys + +S = int(sys.argv[1]) + +for i in range(1, S+1): + for j in range(i+1, S+1): + for k in range(j+1, S+1): + if sum([i, j, k]) == S: + if any([x%2==0 for x in [i, j, k]]): + print(f"{i},{j},{k}") |
