aboutsummaryrefslogtreecommitdiff
path: root/challenge-199/robert-dicicco/python/ch-2.py
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2023-01-14 22:58:41 +0000
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2023-01-14 22:58:41 +0000
commit4a4950187cdaa022b2f111637b7562b3948fac21 (patch)
tree5a6bcc007d87d3831ec5e1650fbc57c36ee8b864 /challenge-199/robert-dicicco/python/ch-2.py
parent0c676bb01724a46f4adad3b3830e7ac0eafc7407 (diff)
downloadperlweeklychallenge-club-4a4950187cdaa022b2f111637b7562b3948fac21.tar.gz
perlweeklychallenge-club-4a4950187cdaa022b2f111637b7562b3948fac21.tar.bz2
perlweeklychallenge-club-4a4950187cdaa022b2f111637b7562b3948fac21.zip
- Added solutions by Simon Green.
- Added solutions by Athanasius. - Added solutions by Bob Lied. - Added solutions by Solathian. - Added solutions by Arne Sommer. - Added solutions by Carlos Oliveira.
Diffstat (limited to 'challenge-199/robert-dicicco/python/ch-2.py')
-rw-r--r--challenge-199/robert-dicicco/python/ch-2.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/challenge-199/robert-dicicco/python/ch-2.py b/challenge-199/robert-dicicco/python/ch-2.py
new file mode 100644
index 0000000000..eacb4768ae
--- /dev/null
+++ b/challenge-199/robert-dicicco/python/ch-2.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+'''
+
+AUTHOR: Robert DiCicco
+
+DATE : 2023-01-14
+
+Challenge 199 Good Triplets ( Python )
+
+'''
+
+from itertools import combinations
+
+
+list1 = [3,0,1,1,9,7]
+
+x = 7
+
+y = 2
+
+z = 3
+
+
+seen = {}
+
+
+for res in (list(combinations(list1, 3))):
+
+ if res in seen:
+
+ continue
+
+ else:
+
+ x1 = list1.index(res[0])
+
+ x2 = list1.index(res[1])
+
+ x3 = list1.index(res[2])
+
+ if x1 > x2 or x2 > x3 or x1 > x3:
+
+ continue
+
+ else:
+
+ if abs(res[0] - res[1]) > x or abs(res[1] - res[2]) > y or abs(res[0] - res[2]) > z :
+
+ continue
+
+ else:
+
+ print(res)
+
+ seen[res] = 1
+
+       
+
+'''
+
+SAMPLE OUTPUT
+
+python .\GoodTriplets.py
+
+(3, 0, 1)
+
+(3, 1, 1)
+
+(0, 1, 1)
+
+'''