|
|
|
@ -15,9 +15,9 @@ func MaxValue(capacity uint, books []Book) uint {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
book := books[0]
|
|
|
|
|
withBook := book.Value + MaxValue(capacity-book.Weight, books[1:])
|
|
|
|
|
withoutBook := MaxValue(capacity, books[1:])
|
|
|
|
|
book, rest := books[0], books[1:]
|
|
|
|
|
withBook := book.Value + MaxValue(capacity-book.Weight, rest)
|
|
|
|
|
withoutBook := MaxValue(capacity, rest)
|
|
|
|
|
if book.Weight > capacity {
|
|
|
|
|
return withoutBook
|
|
|
|
|
}
|
|
|
|
|