From 4a4950187cdaa022b2f111637b7562b3948fac21 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sat, 14 Jan 2023 22:58:41 +0000 Subject: - 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. --- challenge-199/robert-dicicco/python/ch-2.py | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 challenge-199/robert-dicicco/python/ch-2.py (limited to 'challenge-199/robert-dicicco/python') 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) + +''' -- cgit