about summary refs log tree commit diff
path: root/codechef/binadd.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-12-16 21:13:07 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-12-16 21:13:07 +0700
commitc1008fe39217be7f91f0ea23483e747bfbc5743e (patch)
treec4f921bccd9e8d66e3aadd9a01ede3300d73afa6 /codechef/binadd.py
parent8a9d6282fcb863c67d6623f5c883ef703721cccd (diff)
downloadcp-c1008fe39217be7f91f0ea23483e747bfbc5743e.tar.gz
The good, the bad and the ugly
Diffstat (limited to 'codechef/binadd.py')
-rwxr-xr-xcodechef/binadd.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/codechef/binadd.py b/codechef/binadd.py
new file mode 100755
index 0000000..3ab0bab
--- /dev/null
+++ b/codechef/binadd.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+for t in range(int(input())):
+    e, p = input(), input()
+    a, b = int(e, 2), int(p, 2)
+    count = 0
+    while b:
+        a, b = a^b, (a&b)<<1
+        count += 1
+    print(count)