Skip to content
Snippets Groups Projects
Commit e6e185f7 authored by tuhe's avatar tuhe
Browse files

updates

parent b2b82a49
No related branches found
No related tags found
No related merge requests found
File added
This diff is collapsed.
......@@ -6,10 +6,7 @@ from stones import maximum_stones
# A fancy helper function to generate nicer-looking titles.
def trlist(x):
s = str(list(x))
if len(s) > 30:
s = s[:30] + "...]"
return s
return s[:30] + "...]" if len(s) > 30 else s
class Stones(UTestCase):
""" Test of the Stones function """
......@@ -27,7 +24,7 @@ class Stones(UTestCase):
self.stest(4, [4]) # One stone weighing 4 kg.
def test_stones2(self):
self.stest(4, [1, 4]) # should also give 1
self.stest(4, [1, 2, 4]) # should also give 1
def test_stones3(self):
self.stest(4, [4, 1]) # should also give 1
......
This diff is collapsed.
No preview for this file type
......@@ -21,13 +21,14 @@ class Stones(UTestCase):
def test_basecase(self):
""" Test the stones-example given in the homework """
N = maximum_stones(15, [2, 5, 3, 1, 8, 4, 5, 7])
print("How many stones could we pick up?", N)
self.assertEqual(N, 5) # Test that we can collect 5 stones.
def test_stones1(self):
self.stest(4, [4]) # One stone weighing 4 kg.
def test_stones2(self):
self.stest(4, [1, 4]) # should also give 1
self.stest(4, [1, 2, 4]) # should also give 1
def test_stones3(self):
self.stest(4, [4, 1]) # should also give 1
......
This diff is collapsed.
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment