Skip to content

Instantly share code, notes, and snippets.

@boutell
Created December 1, 2021 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boutell/12b295aa2d9009c3b60550728280f29f to your computer and use it in GitHub Desktop.
Save boutell/12b295aa2d9009c3b60550728280f29f to your computer and use it in GitHub Desktop.
Parse out nonempty lines from a file and convert them to integers
import { readFileSync as read } from 'fs';
const input:Array<number> = read('day-1.txt', { encoding: 'utf8' })
.split('\n')
.map(line => line.trim())
.filter(line => line.length > 0)
.map(line => parseInt(line));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment