diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-12-21 21:21:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-21 21:21:55 +0000 |
| commit | 5f1b14f04d412ab7a7f0748821d4185bf3972bac (patch) | |
| tree | 25ab1f3a637bdfac9c3a421cfa7a75ca15af4387 /challenge-030/paulo-custodio/python/ch-2.py | |
| parent | 52b76b289e7244237cd28bb3e271cb783a3c6dad (diff) | |
| parent | 70596c9ffd7af483e5346bf70e33ae11b4829643 (diff) | |
| download | perlweeklychallenge-club-5f1b14f04d412ab7a7f0748821d4185bf3972bac.tar.gz perlweeklychallenge-club-5f1b14f04d412ab7a7f0748821d4185bf3972bac.tar.bz2 perlweeklychallenge-club-5f1b14f04d412ab7a7f0748821d4185bf3972bac.zip | |
Merge pull request #5401 from pauloscustodio/devel
Add Python solution to challenge 029
Diffstat (limited to 'challenge-030/paulo-custodio/python/ch-2.py')
| -rw-r--r-- | challenge-030/paulo-custodio/python/ch-2.py | 19 |
1 files changed, 19 insertions, 0 deletions
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}") |
