aboutsummaryrefslogtreecommitdiff
path: root/challenge-090/roger-bell-west/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-090/roger-bell-west/python/ch-2.py')
-rwxr-xr-xchallenge-090/roger-bell-west/python/ch-2.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-090/roger-bell-west/python/ch-2.py b/challenge-090/roger-bell-west/python/ch-2.py
new file mode 100755
index 0000000000..e63182aa61
--- /dev/null
+++ b/challenge-090/roger-bell-west/python/ch-2.py
@@ -0,0 +1,22 @@
+#! /usr/bin/python3
+
+def em(aa,bb):
+ a=aa
+ b=bb
+ s=0
+ demo=list()
+ while (a > 0):
+ line=' '.join([format(a,'5d'),format(b,'5d')])
+ if (a & 1 == 1):
+ s += b
+ line=' '.join([line,'->',format(b,'5d')])
+ a = a >> 1
+ b = b << 1
+ demo.append(line)
+ demo.append(' -----')
+ demo.append(' ' + format(s,'5d'))
+ for i in demo:
+ print(i)
+ return s
+
+em(13,238)