From 27b754215ceda985f0f8e3b64ab5c5f8e84ab826 Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Fri, 6 May 2022 15:01:38 +0200 Subject: Solved Combinational lock codeforces --- python/CombinationLock.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 python/CombinationLock.py (limited to 'python') diff --git a/python/CombinationLock.py b/python/CombinationLock.py new file mode 100644 index 0000000..0ac8b2c --- /dev/null +++ b/python/CombinationLock.py @@ -0,0 +1,12 @@ +t = int(input()) +count = 0 +n1 = input() +n2 = input() +for i in range(len(n1)): + if abs(int(n1[i]) - int(n2[i])) > 5: + count+= 10 - max(int(n1[i]),int(n2[i])) + min(int(n1[i]),int(n2[i])) + else: + count+=abs(int(n1[i]) - int(n2[i])) +print(count) + + -- cgit v1.2.3