Skip to content

Instantly share code, notes, and snippets.

@jeremenichelli
Created December 9, 2024 11:42
Show Gist options
  • Save jeremenichelli/8f238fdf7eae5d12c82e83e1d0ee0cbd to your computer and use it in GitHub Desktop.
Save jeremenichelli/8f238fdf7eae5d12c82e83e1d0ee0cbd to your computer and use it in GitHub Desktop.
#382
// Assumes gifts width are sorted in ascending order.
function wrapGifts(gifts, len) {
let i = 0
let wrapped = 0
let paperLength = len
while (paperLength > 0) {
paperLength = paperLength - gifts[i]
if (paperLength > -1) { ++wrapped }
++i
}
return wrapped
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment