Dynamic-Programming : remove live code & console.log, leave examples as comments.

This commit is contained in:
Eric Lavault
2021-10-10 17:00:21 +02:00
parent 449ef45193
commit 29d2a84090
14 changed files with 95 additions and 124 deletions

View File

@ -20,7 +20,7 @@ const zeroOneKnapsack = (arr, n, cap, cache) => {
}
}
const main = () => {
const example = () => {
/*
Problem Statement:
You are a thief carrying a single bag with limited capacity S. The museum you stole had N artifact that you could steal. Unfortunately you might not be able to steal all the artifact because of your limited bag capacity.
@ -40,6 +40,8 @@ const main = () => {
input.shift()
const length = input.length
let output = []
let i = 0
while (i < length) {
const cap = Number(input[i].trim().split(' ')[0])
@ -62,9 +64,11 @@ const main = () => {
cache.push(temp)
}
const result = zeroOneKnapsack(newArr, currlen, cap, cache)
console.log(result)
output.push(result)
i += currlen + 1
}
return output
}
main()
export { zeroOneKnapsack, example }