SHARE
TWEET

Untitled

a guest Dec 8th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const result = file
  2.   .split("\n")
  3.   .map(Number)
  4.   .reduce((acc, cur) => {
  5.     let input = cur;
  6.     let sum = 0;
  7.  
  8.     for (;;) {
  9.       const r = Math.max(Math.floor(input / 3) - 2, 0);
  10.       sum += r;
  11.       input = r;
  12.       if (input === 0) {
  13.         break;
  14.       }
  15.     }
  16.  
  17.     return acc + sum;
  18.   }, 0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top