Example #1
0
 def test_7(self):
     h = hailstone(7)
     hr = hailstoneRecursive(7)
     assert h == hr
     assert h == [
         7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1
     ], "False result with 7. Expected [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]. Result %s" % str(
         h)
Example #2
0
 def test_7(self):
     h = hailstone(7)
     hr = hailstoneRecursive(7)
     assert h == hr
     assert h == [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1], (
         "False result with 7. Expected [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]. Result %s"
         % str(h)
     )
Example #3
0
 def test_27(self):
     h = hailstone(27)
     hr = hailstoneRecursive(27)
     assert h == hr
     # element count
     assert len(h) == 112
     # first 4 elements
     assert h[:4] == [27, 82, 41, 124]
     # last 4 elements
     assert h[-4:] == [8, 4, 2, 1]
Example #4
0
 def test_27(self):
     h = hailstone(27)
     hr = hailstoneRecursive(27)
     assert h == hr
     # element count
     assert len(h) == 112
     # first 4 elements
     assert h[:4] == [27, 82, 41, 124]
     # last 4 elements
     assert h[-4:] == [8, 4, 2, 1]
Example #5
0
 def test_1(self):
     h = hailstone(1)
     hr = hailstoneRecursive(1)
     assert h == hr
     assert h == [1], "False result with 1. Expected [1]. Result %s" % str(h)
Example #6
0
 def test_1_neg(self):
     h = hailstone(-1)
     hr = hailstoneRecursive(-1)
     assert h == hr
     assert h == [], "False result with -1. Expected []. Result %s" % str(h)
Example #7
0
 def test_0(self):
     h = hailstone(0)
     hr = hailstoneRecursive(0)
     assert h == hr
     assert h == [], "False result with 0. Expected []. Result %s" % str(h)
Example #8
0
 def test_1(self):
     h = hailstone(1)
     hr = hailstoneRecursive(1)
     assert h == hr
     assert h == [1
                  ], "False result with 1. Expected [1]. Result %s" % str(h)
Example #9
0
 def test_1_neg(self):
     h = hailstone(-1)
     hr = hailstoneRecursive(-1)
     assert h == hr
     assert h == [], "False result with -1. Expected []. Result %s" % str(h)
Example #10
0
 def test_0(self):
     h = hailstone(0)
     hr = hailstoneRecursive(0)
     assert h == hr
     assert h == [], "False result with 0. Expected []. Result %s" % str(h)
Example #11
0
def test_two():
    assert hailstone(6) == [6, 3, 10, 5, 16, 8, 4, 2, 1]
Example #12
0
def test_one():
    assert hailstone(5) == [5, 16, 8, 4, 2, 1]
Example #13
0
def test_five():
    assert hailstone(1) == [1]
Example #14
0
def test_four():
    assert hailstone(10) == [10, 5, 16, 8, 4, 2, 1]
Example #15
0
def test_three():
    assert hailstone(200) == [
        200, 100, 50, 25, 76, 38, 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26,
        13, 40, 20, 10, 5, 16, 8, 4, 2, 1
    ]