Created
December 1, 2021 12:35
-
-
Save boutell/12b295aa2d9009c3b60550728280f29f to your computer and use it in GitHub Desktop.
Parse out nonempty lines from a file and convert them to integers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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