Sha256: bc7e8181364ff1c48c6db17691d737661fae8432bb55ecf65fe4a8a356c24f4a

Contents?: true

Size: 1.03 KB

Versions: 81

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(triangle(4), ans)

    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(triangle(6), ans)

    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.assertIs(is_triangle(inp), True)

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

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

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

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


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

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
trackler-2.2.1.127 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.126 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.125 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.124 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.123 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.122 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.121 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.120 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.119 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.118 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.117 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.116 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.115 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.114 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.113 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.111 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.110 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.109 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.108 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py
trackler-2.2.1.107 tracks/python/exercises/pascals-triangle/pascals_triangle_test.py