def test_equal6(self):
        capacity = 10
        goldbars_weight = [1, 1, 1, 1, 1, 1]

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

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

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

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

        self.assertEqual(optimal_weight(capacity, goldbars_weight), 2)
Exemple #6
0
from knapsack import optimal_weight

W = 10
w = [1, 4, 8]
print(optimal_weight(W, w))
Exemple #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]))
Exemple #9
0
def test_optimal_weight(W, w, expected):
    assert optimal_weight(W, w) == expected