コード例 #1
0
 def test_multiple_items(self):
     self.assertEqual(knapsack([[3, 4], [2, 3], [4, 2], [4, 3]], 6),
                      (8, [[4, 3], [4, 2]]))
     self.assertEqual(knapsack([[3, 4], [2, 3], [4, 2], [4, 3]], 7),
                      (8, [[4, 3], [4, 2]]))
     self.assertEqual(knapsack([[3, 4], [2, 3], [4, 2], [4, 3]], 8),
                      (10, [[4, 3], [4, 2], [2, 3]]))
コード例 #2
0
 def test_single_item(self):
     self.assertEqual(knapsack([[1,1]],  10), (1,[[1,1]]))
     self.assertEqual(knapsack([[1,10]], 10), (1,[[1,10]]))
     self.assertEqual(knapsack([[1,11]], 10), (0,[]))
コード例 #3
0
 def test_empty(self):
     self.assertEqual(knapsack([], 10), (0,[]))
コード例 #4
0
 def test_multiple_items(self):
     self.assertEqual(knapsack([[3,4],[2,3],[4,2],[4,3]], 6), (8, [[4, 3], [4, 2]]))
     self.assertEqual(knapsack([[3,4],[2,3],[4,2],[4,3]], 7), (8, [[4, 3], [4, 2]]))
     self.assertEqual(knapsack([[3,4],[2,3],[4,2],[4,3]], 8), (10, [[4, 3], [4, 2], [2, 3]]))
コード例 #5
0
 def test_single_item(self):
     self.assertEqual(knapsack([[1, 1]], 10), (1, [[1, 1]]))
     self.assertEqual(knapsack([[1, 10]], 10), (1, [[1, 10]]))
     self.assertEqual(knapsack([[1, 11]], 10), (0, []))
コード例 #6
0
 def test_empty(self):
     self.assertEqual(knapsack([], 10), (0, []))