summaryrefslogtreecommitdiff
path: root/progs/a337.py
diff options
context:
space:
mode:
Diffstat (limited to 'progs/a337.py')
-rw-r--r--progs/a337.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/progs/a337.py b/progs/a337.py
new file mode 100644
index 0000000..ca3e3bd
--- /dev/null
+++ b/progs/a337.py
@@ -0,0 +1,27 @@
+import sys
+
+def find_closet(A, B, C, p, q, r):
+ diff = sys.maxsize
+ res_i = 0
+ res_j = 0
+ res_k = 0
+ i = 0
+ j = 0
+ k = 0
+ while(i < p and j < q and k < r):
+ minimum = min(A[i], min(B[j], C[k]))
+ maximum = max(A[i], max(B[j], C[k]));
+ if maximum-minimum < diff:
+ res_i = i
+ res_j = j
+ res_k = k
+ diff = maximum - minimum;
+ if diff == 0:
+ break
+ if A[i] == minimum:
+ i = i+1
+ elif B[j] == minimum:
+ j = j+1
+ else:
+ k = k+1
+ return A[res_i],B[res_j],C[res_k] \ No newline at end of file