There's alternative answer for Cash Register for JavaScript Algorithms and Data Structures :)

For
checkCashRegister(3.26, 100, [[“PENNY”, 1.01], [“NICKEL”, 2.05], [“DIME”, 3.1], [“QUARTER”, 4.25], [“ONE”, 90], [“FIVE”, 55], [“TEN”, 20], [“TWENTY”, 60], [“ONE HUNDRED”, 100]])

answer: {status: “OPEN”, change: [[“TWENTY”, 60], [“TEN”, 20], [“FIVE”, 15], [“ONE”, 1], [“QUARTER”, 0.5], [“DIME”, 0.2], [“PENNY”, 0.04]]}

However there’s alternative answer for this since 60+20+15=95= 80+10+5
Therefore, the alternative answer will be:
{ status: ‘OPEN’,
change:
[ [ ‘TWENTY’, 80 ],
[ ‘TEN’, 10 ],
[ ‘FIVE’, 5 ],
[ ‘ONE’, 1 ],
[ ‘QUARTER’, 0.5 ],
[ ‘DIME’, 0.2 ],
[ ‘PENNY’, 0.04 ] ] }

Maybe I’m not reading this correctly, but the CID sent into the function has TWENTY set to 60 but your alternative answer has TWENTY set to 80. So it seems like your answer gained an unexplained 20?

Holy crap I just realize the cashier only 60 dollars for 20 :smiling_face_with_tear: :sob: sorry for the inconvenience

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.