From ef909ced247550a2283c870a576f947f207e3125 Mon Sep 17 00:00:00 2001 From: Roger Bell_West Date: Mon, 7 Dec 2020 18:02:27 +0000 Subject: Solutions for challenge #90. --- challenge-090/roger-bell-west/python/ch-1.py | 15 +++++++++++++++ challenge-090/roger-bell-west/python/ch-2.py | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 challenge-090/roger-bell-west/python/ch-1.py create mode 100755 challenge-090/roger-bell-west/python/ch-2.py (limited to 'challenge-090/roger-bell-west/python') diff --git a/challenge-090/roger-bell-west/python/ch-1.py b/challenge-090/roger-bell-west/python/ch-1.py new file mode 100755 index 0000000000..64ac9905d0 --- /dev/null +++ b/challenge-090/roger-bell-west/python/ch-1.py @@ -0,0 +1,15 @@ +#! /usr/bin/python3 + +def gs(bs): + l={'A': 'T','T': 'A','C': 'G','G': 'C'} + os=''.join(l[i] for i in bs) + return [len(os),os] + +import unittest + +class TestGs(unittest.TestCase): + + def test_ex1(self): + self.assertEqual(gs('GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG'),[67,'CATTTGGGGAAAAGTAAATCTGTCTAGCTGAGGAATAGGTAAGAGTCTCTACACAACGACCAGCGGC'],'example 1') + +unittest.main() 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) -- cgit