rename cartridge to cassette
This commit is contained in:
parent
cc32bc39e8
commit
8674816d27
9 changed files with 67 additions and 66 deletions
|
|
@ -6,13 +6,13 @@ const uuid = require('uuid')
|
|||
//
|
||||
// We can either require canononical denominations for 3+, or try to expand
|
||||
// this algorithm.
|
||||
exports.makeChange = function makeChange (cartridges, amount) {
|
||||
exports.makeChange = function makeChange (cassettes, amount) {
|
||||
// Note: Everything here is converted to primitive numbers,
|
||||
// since they're all integers, well within JS number range,
|
||||
// and this is way more efficient in a tight loop.
|
||||
|
||||
const small = cartridges[0]
|
||||
const large = cartridges[1]
|
||||
const small = cassettes[0]
|
||||
const large = cassettes[1]
|
||||
|
||||
const largeDenom = large.denomination
|
||||
const smallDenom = small.denomination
|
||||
|
|
@ -28,8 +28,8 @@ exports.makeChange = function makeChange (cartridges, amount) {
|
|||
if (smallCount > small.count) continue
|
||||
|
||||
return [
|
||||
{count: smallCount, denomination: small.denomination, id: uuid.v4()},
|
||||
{count: i, denomination: largeDenom, id: uuid.v4()}
|
||||
{provisioned: smallCount, denomination: small.denomination, id: uuid.v4()},
|
||||
{provisioned: i, denomination: largeDenom, id: uuid.v4()}
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue