Sha256: d11df98bcf6425e7fb6d8543259ca05282de8d406f6a2d62d5fbbdcf2bd90ddb

Contents?: true

Size: 1.03 KB

Versions: 127

Compression:

Stored size: 1.03 KB

Contents

import unittest

from pascals_triangle import triangle, row, is_triangle


class PascalsTriangleTest(unittest.TestCase):
    def test_triangle1(self):
        ans = ['1', '1 1', '1 2 1', '1 3 3 1', '1 4 6 4 1']
        self.assertEqual(ans, triangle(4))

    def test_triangle2(self):
        ans = ['1', '1 1', '1 2 1', '1 3 3 1', '1 4 6 4 1', '1 5 10 10 5 1',
               '1 6 15 20 15 6 1']
        self.assertEqual(ans, triangle(6))

    def test_is_triangle_true(self):
        inp = ['1', '1 1', '1 2 1', '1 3 3 1', '1 4 6 4 1', '1 5 10 10 5 1']
        self.assertEqual(True, is_triangle(inp))

    def test_is_triangle_false(self):
        inp = ['1', '1 1', '1 2 1', '1 4 4 1']
        self.assertEqual(False, is_triangle(inp))

    def test_row1(self):
        ans = '1'
        self.assertEqual(ans, row(0))

    def test_row2(self):
        ans = '1 2 1'
        self.assertEqual(ans, row(2))

    def test_row3(self):
        ans = '1 7 21 35 35 21 7 1'
        self.assertEqual(ans, row(7))


if __name__ == '__main__':
    unittest.main()

Version data entries

127 entries across 127 versions & 1 rubygems

Version Path
trackler-2.0.8.27 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.26 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.24 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.23 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.22 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.21 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.20 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.19 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.18 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.17 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.16 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.15 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.14 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.13 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.12 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.11 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.10 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.9 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.8 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.0.8.7 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py