This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// shorten constant to fit maximum length accepted by sentry | |
const shortenConstant = (constantCaseString, maxlength = 25, separator = '_') => { | |
// no need to shorten | |
if (!constantCaseString || constantCaseString.length < maxlength) { | |
return constantCaseString; | |
} | |
// abbreviate each word to fit the max length | |
const splittedConstantCaseTokens = constantCaseString.split(separator); | |
if (splittedConstantCaseTokens.length > 1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const solve = (people, umbrellas, result = 0) => { | |
if (!people) return result; | |
const bestUmbrellaToPick = umbrellas.reduce((best, umbrella) => { | |
return umbrella > best && umbrella <= people ? umbrella : best | |
}, 0); | |
if (!bestUmbrellaToPick) return -1; | |
const quantity = parseInt(people/bestUmbrellaToPick); |