aboutsummaryrefslogtreecommitdiff
path: root/challenge-217/roger-bell-west/python/ch-1.py
blob: 0d35a4a1f4b31ce994b52d7f7d5ec47c0cc7252e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/python3

from itertools import chain

def sortedmatrix(matrix):
  n = list(chain.from_iterable(matrix))
  n.sort()
  return n[2]

import unittest

class TestSortedmatrix(unittest.TestCase):

  def test_ex1(self):
    self.assertEqual(sortedmatrix([[3, 1, 2], [5, 2, 4], [0, 1, 3]]), 1, 'example 1')

  def test_ex2(self):
    self.assertEqual(sortedmatrix([[2, 1], [4, 5]]), 4, 'example 2')

  def test_ex3(self):
    self.assertEqual(sortedmatrix([[1, 0, 3], [0, 0, 0], [1, 2, 1]]), 0, 'example 3')

unittest.main()