Пример #1
0
 def test_drop_middle(self):
     self.assertEqual([0, 2],
                      get_knapsack_contents(2, [
                          item(0, weight=1, value=2),
                          item(1, weight=1, value=1),
                          item(2, weight=1, value=3)
                      ]))
Пример #2
0
 def test_sample(self):
     self.assertEqual([1, 2, 3],
                      get_knapsack_contents(123, [
                          item(0, value=25, weight=50),
                          item(1, value=30, weight=40),
                          item(2, value=30, weight=80),
                          item(3, value=2, weight=3)
                      ]))
Пример #3
0
 def test_same_value_different_weight(self):
     self.assertEqual(
         [1],
         get_knapsack_contents(
             3, [item(0, weight=3, value=3),
                 item(1, weight=2, value=3)]))
Пример #4
0
 def test_same_value_weight(self):
     self.assertEqual(
         [0],
         get_knapsack_contents(
             1, [item(0, weight=1, value=1),
                 item(1, weight=1, value=1)]))
Пример #5
0
 def test_drop_last(self):
     self.assertEqual(
         [0, 1],
         get_knapsack_contents(
             2, [item(0, 1, 1), item(1, 1, 1),
                 item(2, 1, 1)]))
Пример #6
0
 def test_take_two(self):
     self.assertEqual([0, 1],
                      get_knapsack_contents(
                          2, [item(0, 1, 1), item(1, 1, 1)]))
Пример #7
0
 def test_take_none(self):
     self.assertEqual([], get_knapsack_contents(0, [item(0, 1, 1)]))
Пример #8
0
 def test_take_single(self):
     self.assertEqual([0], get_knapsack_contents(1, [item(0, 1, 1)]))
Пример #9
0
 def test_empty(self):
     self.assertEqual([], get_knapsack_contents(0, []))