Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const result = file
- .split("\n")
- .map(Number)
- .reduce((acc, cur) => {
- let input = cur;
- let sum = 0;
- for (;;) {
- const r = Math.max(Math.floor(input / 3) - 2, 0);
- sum += r;
- input = r;
- if (input === 0) {
- break;
- }
- }
- return acc + sum;
- }, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement