Skip to content

Instantly share code, notes, and snippets.

@lukekarrys
Created August 21, 2019 00:37
Show Gist options
  • Save lukekarrys/16eb0680403e73fd0e71af62fe8db5ab to your computer and use it in GitHub Desktop.
Save lukekarrys/16eb0680403e73fd0e71af62fe8db5ab to your computer and use it in GitHub Desktop.
Get ultrasignup points based on elapsed times
const timeToSeconds = (t) => t
.split(':')
.reverse()
.reduce((acc, value, i) => acc + value * Math.pow(60, i), 0)
const timesToPoints = (...times) => Math.round(times[0] / times[1] * 1000)
const main = (...times) => {
const parsed = times.map(timeToSeconds)
if (parsed.length === 3) {
return timesToPoints(parsed[0], parsed[1]) - timesToPoints(parsed[0], parsed[2])
} else {
return timesToPoints(...parsed)
}
}
// > node index.js 4:24:00 5:26:00
// 810
// > node index.js 4:24:00 5:27:00 5:30:00
// 7
console.log(main(...process.argv.slice(2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment