diff options
Diffstat (limited to 'challenge-199/robert-dicicco/python/ch-2.py')
| -rw-r--r-- | challenge-199/robert-dicicco/python/ch-2.py | 75 |
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) + +''' |
