예제 #1
0
    def test_equal6(self):
        capacity = 10
        goldbars_weight = [1, 1, 1, 1, 1, 1]

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

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

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

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

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

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