diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-12-07 21:48:26 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-07 21:48:26 +0000 |
| commit | 2bfbf295586eac9e82a1c2f42cffa5cd8e61d33a (patch) | |
| tree | 7cb082a7f63b8efc033f59ddf9ef8f866fe1d4e0 /challenge-090/roger-bell-west/python/ch-2.py | |
| parent | 2009bf53c9e1006b876bc0c6bdc23d285386e168 (diff) | |
| parent | ef909ced247550a2283c870a576f947f207e3125 (diff) | |
| download | perlweeklychallenge-club-2bfbf295586eac9e82a1c2f42cffa5cd8e61d33a.tar.gz perlweeklychallenge-club-2bfbf295586eac9e82a1c2f42cffa5cd8e61d33a.tar.bz2 perlweeklychallenge-club-2bfbf295586eac9e82a1c2f42cffa5cd8e61d33a.zip | |
Merge pull request #2943 from Firedrake/rogerbw-challenge-090
Solutions for challenge #90.
Diffstat (limited to 'challenge-090/roger-bell-west/python/ch-2.py')
| -rwxr-xr-x | challenge-090/roger-bell-west/python/ch-2.py | 22 |
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) |
