aboutsummaryrefslogtreecommitdiff
path: root/challenge-078/roger-bell-west/python/ch-2.py
blob: 860ec393d6b1287013124dee694c0261c2480a0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/python

import unittest

def leftrot(a,b):
  l=len(a)
  t=list()
  map(t.append,a)
  map(t.append,a)
  o=list()
  for c in (b):
    o.append(list((t[c:c+l])))
  return o

class TestLeftrot(unittest.TestCase):

    def test_ex1(self):
        self.assertEqual(leftrot((10, 20, 30, 40, 50),(3, 4)),
                         [[40, 50, 10, 20, 30],
                          [50, 10, 20, 30, 40]],
                         'example 1')

    def test_ex2(self):
        self.assertEqual(leftrot((7, 4, 2, 6, 3),(1, 3, 4)),
                         [[4, 2, 6, 3, 7],
                          [6, 3, 7, 4, 2],
                          [3, 7, 4, 2, 6]],
                         'example 2')

unittest.main()