AOC day 1

This commit is contained in:
2022-12-01 19:03:02 +00:00
parent a3881c0748
commit e74bd134bd
7 changed files with 2303 additions and 0 deletions

View File

@@ -1189,6 +1189,7 @@ class Macros {
return b.callSymbol("haxe.Timer.measure", [b.callSymbol("lambda", [b.list([])].concat(exps))]);
};
// TODO should indexOf and lastIndexOf accept negative starting indices?
function indexOfMacro(last:Bool, wholeExp:ReaderExp, exps:Array<ReaderExp>, k:KissState) {
var funcName = if (last) "lastIndexOf" else "indexOf";
k.doc(funcName, 2, 3, '($funcName <list or string> <element or substring> <?startingIndex>)');

View File

@@ -12,6 +12,9 @@ import year2020.Solutions2020;
#if year2021
import year2021.Solutions2021;
#end
#if year2022
import year2022.Solutions2022;
#end
@:build(kiss.Kiss.build())
class Main {}

View File

@@ -6,3 +6,5 @@
(Solutions2020.run))
(year 2021
(Solutions2021.run))
(year 2022
(Solutions2022.main))

View File

@@ -0,0 +1,12 @@
(import year2022.Food)
(function :Array<Food> parseFood [file]
(for paragraph (Util.readParagraphLines file)
(paragraph.map Std.parseInt)))
(function sumFood [:Array<Food> food]
(for elf food (apply + elf)))
(let [sums (sumFood (parseFood "src/year2022/inputs/day1.txt"))]
(assert (= 71502 (apply max sums)))
(assert (= 208191 (apply + (.slice (sort sums) -3)))))

View File

@@ -0,0 +1,3 @@
package year2022;
typedef Food = Array<Int>;

View File

@@ -0,0 +1,27 @@
(load "../UtilMacros.kiss")
(import Util)
(day 1 (load "Day1.kiss"))
(dayTodo 2)
(dayTodo 3)
(dayTodo 4)
(dayTodo 5)
(dayTodo 6)
(dayTodo 7)
(dayTodo 8)
(dayTodo 9)
(dayTodo 10)
(dayTodo 11)
(dayTodo 12)
(dayTodo 13)
(dayTodo 14)
(dayTodo 15)
(dayTodo 16)
(dayTodo 17)
(dayTodo 18)
(dayTodo 19)
(dayTodo 20)
(dayTodo 21)
(dayTodo 22)
(dayTodo 23)
(dayTodo 24)
(dayTodo 25)

File diff suppressed because it is too large Load Diff