Skip to content

Commit

Permalink
feat(2023): update solution for challenge #08
Browse files Browse the repository at this point in the history
  • Loading branch information
iswilljr committed Dec 8, 2023
1 parent 21fc3c7 commit b285ada
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 2023/challenge-08/challenge-08.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export function organizeGifts(gifts: string) {
const total = +group.slice(0, -1)
const gift = group.slice(-1)

const pallets = Math.floor(total / 50)
const boxes = Math.floor((total / 10) % 5)
const pallets = total / 50
const boxes = (total / 10) % 5
const bags = total % 10

const palletGifts = `[${gift}]`.repeat(pallets)
const boxGifts = `{${gift}}`.repeat(boxes)
const bagGifts = bags > 0 ? `(${gift.repeat(bags)})` : ''
const bagGifts = `(${gift.repeat(bags)})`.repeat(+(bags > 0))

organizedGifts += `${palletGifts}${boxGifts}${bagGifts}`
}
Expand Down

0 comments on commit b285ada

Please sign in to comment.