Exemplo n.º 1
0
    def test_equal6(self):
        capacity = 10
        goldbars_weight = [1, 1, 1, 1, 1, 1]

        self.assertEqual(optimal_weight(capacity, goldbars_weight), 6)
Exemplo n.º 2
0
    def test_equal(self):
        capacity = 1
        goldbars_weight = [3, 2, 1]

        self.assertEqual(optimal_weight(capacity, goldbars_weight), 1)
Exemplo n.º 3
0
    def test_equal4(self):
        capacity = 5
        goldbars_weight = [1, 3, 4]

        self.assertEqual(optimal_weight(capacity, goldbars_weight), 5)
Exemplo n.º 4
0
    def test_equal5(self):
        capacity = 10
        goldbars_weight = [9, 7, 3]

        self.assertEqual(optimal_weight(capacity, goldbars_weight), 10)
Exemplo n.º 5
0
    def test_equal3(self):
        capacity = 2
        goldbars_weight = [1, 5, 1]

        self.assertEqual(optimal_weight(capacity, goldbars_weight), 2)
Exemplo n.º 6
0
from knapsack import optimal_weight

W = 10
w = [1, 4, 8]
print(optimal_weight(W, w))
Exemplo n.º 7
0
from knapsack import optimal_weight
from test.asserts import assert_equal

assert_equal(9, optimal_weight(10, [1, 4, 8]), "sample 1")
assert_equal(9, optimal_weight(10, [8, 4, 1]), "sample 1, reversed")
 def test_sample(self):
     self.assertEqual(9, optimal_weight(10, [1, 4, 8]))
Exemplo n.º 9
0
def test_optimal_weight(W, w, expected):
    assert optimal_weight(W, w) == expected