diff options
author | Leah Neukirchen <leah@vuxu.org> | 2020-12-08 17:40:58 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2020-12-08 17:40:58 +0100 |
commit | 994a71edcd0353bddf71008fd5599c97098a966c (patch) | |
tree | c71996a69f18455e2cdc625f4d69885c428f790a /day07.ijs | |
parent | b59e223242a940b435a8badaffe0130836459a10 (diff) | |
download | adventofcode2020-994a71edcd0353bddf71008fd5599c97098a966c.tar.gz adventofcode2020-994a71edcd0353bddf71008fd5599c97098a966c.tar.xz adventofcode2020-994a71edcd0353bddf71008fd5599c97098a966c.zip |
day07
Diffstat (limited to 'day07.ijs')
-rw-r--r-- | day07.ijs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/day07.ijs b/day07.ijs new file mode 100644 index 0000000..c0c7035 --- /dev/null +++ b/day07.ijs @@ -0,0 +1,20 @@ +load 'aoc.ijs' + +ex =: 3 : 0 +'n a b z' =. y +(".`0:@.(-:&'no') n); a,' ',b +) + +parse =: 3 : 0 +(<' 'joinstring 2 {. f),<ex"1 }. _4]\ f=.(<;._1)' ',y +) + +d =: (parse every lines 'day07'), ('other bags.'); <0 2$'' + +look =: 4 : '{. > }. y {~ ({."1 y) i. < x' + +part1 =: ([: +./ [: >@$:@> 1{"1 look&d)`1:@.(-:&'shiny gold') +<: +/part1 every {."1 d NB. 278 slow :/ + +part2 =: [: >:@(+/) (>@{. * $:&>@}.)"1 @ look&d`0:@.(-:&'other bags.') +<: part2 'shiny gold' NB. 45158 |