refactoring aoc

This commit is contained in:
2021-07-12 18:41:39 -06:00
parent 991f82f3ae
commit 22a563ae34
19 changed files with 41 additions and 62 deletions

View File

@@ -2,7 +2,6 @@ package year2020;
import haxe.Int64;
import kiss.Prelude;
import year2020.Util;
using StringTools;

View File

@@ -1,7 +1,6 @@
package year2020;
import kiss.Prelude;
import year2020.Util;
using StringTools;

View File

@@ -1,7 +1,6 @@
package year2020;
import kiss.Prelude;
import year2020.Util;
using StringTools;

View File

@@ -3,5 +3,7 @@ package year2020;
import kiss.EmbeddedScript;
import kiss.Prelude;
#if (day12 && year2020)
@:build(kiss.EmbeddedScript.build("EvasionDSL.kiss", "inputs/day12.txt"))
class EvasionScript extends EmbeddedScript {}
#end

View File

@@ -2,7 +2,6 @@ package year2020;
import kiss.Prelude;
import kiss.Operand;
import year2020.Util;
using StringTools;

View File

@@ -1,7 +1,6 @@
package year2020;
import kiss.Prelude;
import year2020.Util;
using StringTools;

View File

@@ -5,7 +5,6 @@ import haxe.Int64;
import StringTools;
import kiss.Prelude;
import kiss.Stream;
import year2020.Util;
import year2020.SummingTuples;
import year2020.Passwords;
import year2020.Toboggan;

View File

@@ -1,12 +1,6 @@
(defmacro day [num &rest body]
`(when (<= 0 (days.indexOf ,num))
(print (+ "day " (Std.string ,num)))
,@body))
(load "../UtilMacros.kiss")
(defmacro dayTodo [num]
`(day ,num (print "TODO")))
(defun run [:kiss.List<Int> days]
(defun run []
(day 1
(let [p (SummingTuples.pairWithSum 2020 [1721 979 366 299 675 1456])]
(assert (and (has p 1721) (has p 299)) "pairWithSum is broken"))

View File

@@ -1,7 +1,6 @@
package year2020;
import kiss.Prelude;
import year2020.Util;
@:build(kiss.Kiss.build())
class Toboggan {}

View File

@@ -1,9 +0,0 @@
package year2020;
import sys.io.File;
import kiss.Prelude;
using StringTools;
@:build(kiss.Kiss.build())
class Util {}

View File

@@ -1,24 +0,0 @@
(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))))