diff options
Diffstat (limited to 'challenge-308/roger-bell-west/python/ch-2.py')
| -rwxr-xr-x | challenge-308/roger-bell-west/python/ch-2.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-308/roger-bell-west/python/ch-2.py b/challenge-308/roger-bell-west/python/ch-2.py new file mode 100755 index 0000000000..5ebb9fe738 --- /dev/null +++ b/challenge-308/roger-bell-west/python/ch-2.py @@ -0,0 +1,19 @@ +#! /usr/bin/python3 + +def decodexor(a, init): + out = [init] + for v in a: + out.append(out[-1] ^ v) + return out + +import unittest + +class TestDecodexor(unittest.TestCase): + + def test_ex1(self): + self.assertEqual(decodexor([1, 2, 3], 1), [1, 0, 2, 1], 'example 1') + + def test_ex2(self): + self.assertEqual(decodexor([6, 2, 7, 3], 4), [4, 2, 0, 7, 4], 'example 2') + +unittest.main() |
