aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Manring <michael@manring>2023-11-28 23:40:10 +1100
committerMichael Manring <michael@manring>2023-11-28 23:40:10 +1100
commit89872cdb0cfba905fed4a613f78a08677cfd0032 (patch)
tree844c2f490b467c4d434bc317b61b6b77dd5b3db5
parentc21050f1f14eda7b8dca16bdeb8186cb65255260 (diff)
downloadperlweeklychallenge-club-89872cdb0cfba905fed4a613f78a08677cfd0032.tar.gz
perlweeklychallenge-club-89872cdb0cfba905fed4a613f78a08677cfd0032.tar.bz2
perlweeklychallenge-club-89872cdb0cfba905fed4a613f78a08677cfd0032.zip
pwc245_task2 - remove unneccessary loops and rename variables
-rw-r--r--challenge-245/pokgopun/python/ch-2.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/challenge-245/pokgopun/python/ch-2.py b/challenge-245/pokgopun/python/ch-2.py
index 362cb4b6d9..de7e1f9713 100644
--- a/challenge-245/pokgopun/python/ch-2.py
+++ b/challenge-245/pokgopun/python/ch-2.py
@@ -45,17 +45,15 @@ def lot(tup: tuple):
return max( ### max() can avoid an error from null permute iterator as it operates on chain.from_iterables that include default (-1,)
chain.from_iterable(
(
- ( i for i in
+ (
+ int("".join(iStrs)) for iStrs in ### concat and convert int strings to an int
(
- int("".join(j)) for j in ### concat and convert int strings to an int
+ ( str(i) for i in ints) for ints in ### int-to-string conversion for ints so we can further concat and convert them to an int
(
- ( str(z) for z in y) for y in ### int-to-string conversion for ints so we can further concat and convert them to an int
- (
- x for x in
- chain.from_iterable( ### need permutations(tup,n) loop instead of permutations(tup) alone to avoid a bug in itertools/permutations
- permutations(tup, n) for n in range(1,len(tup)+1)
- ) if sum(x) % 3 == 0 ### If a + b = c , then a ( mod N ) + b ( mod N ) ≡ c ( mod N )
- )
+ ints for ints in
+ chain.from_iterable( ### need permutations(tup,n) loop instead of permutations(tup) alone to avoid a bug in itertools/permutations
+ permutations(tup, n) for n in range(1,len(tup)+1)
+ ) if sum(ints) % 3 == 0 ### If a + b = c , then a ( mod N ) + b ( mod N ) ≡ c ( mod N )
)
)
),