Unable to load image

Advent of code day 4 :marseysad:

This is the advent of code day 4 thread for bragging about your solution and bullying people who haven't gotten it yet :marseyill:

35
Jump in the discussion.

No email address required.

import * as fs from 'fs'

console.log(
  fs.readFileSync(process.argv[2], 'utf-8').split('\n').reduce((p, l) => {
      const m = l.match(/\d+/g)?.map(s => Number(s));
      return [ 
        p[0] + (m && (m[0] <= m[2] && m[1] >= m[3] || m[2] <= m[0] && m[3] >= m[1]) ? 1 : 0),
        p[1] + (m && (m[0] <= m[2] && m[1] >= m[2] || m[2] <= m[0] && m[3] >= m[0]) ? 1 : 0)
      ]
    }, [0,0])
);
Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.