aoc 2018 day 1

This commit is contained in:
Angad Singh
2021-07-12 21:32:22 +05:30
parent 2d8f4cfee7
commit befaadf2d5
11 changed files with 2150 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
(defun readLines [file]
(.filter
(.map
// TODO implement escape sequences in kiss string literals
(.split (.replace (File.getContent file) #|"\r"|# "") #|"\n"|#)
StringTools.trim)
(lambda [l] (< 0 l.length))))
(defun readParagraphLines [file]
(.filter
(for paragraph
(.split
(.replace (File.getContent file) #|"\r"|# "")
#|"\n\n"|#)
(.filter
(paragraph.split #|"\n"|#)
(lambda [line] (< 0 line.length))))
(lambda [lines] (< 0 lines.length))))
// TODO won't need to specify type here if last is not a quickNth
(defun :kiss.List<Int> readInts [file] (let [lines (readLines file)] (lines.map Std.parseInt)))
(defun countChar [char str]
(count (str.split "") (lambda [c] ?(= c char))))