Compare commits
No commits in common. "b93563d249cc8dcac7e645bea67d5645010804de" and "6ff7dfeb2df4a86909c6571942a2dc9e6f924d28" have entirely different histories.
b93563d249
...
6ff7dfeb2d
110
input/day10
110
input/day10
|
@ -1,110 +0,0 @@
|
|||
<<{<[<<<{<<(<({}())({}[]))[[{}[]]<{}[]>])[<[{}[]]{()()}>{((){})<<><>>}]>>[<(<<{}>>[<()()><<><>>]
|
||||
{[[[{<[(([[{(({}))([<>[]]((){}))}<<<[][]>[{}{}]>[{()[]}(()())]>][[[{<>()}[{}[]]]]]]<{{{{()[]}}}[[{[][]}{{
|
||||
([((<(<(<<([{{[][]}([]<>)}({<>{}}[[]()])]<[[()()](()[])]([[][]](<><>))>>{{<(<><>)[<>()]>([[]()])}<<[[]()]<[][
|
||||
{{{([((([({[{{()()}{<>[]}}({{}{}}([]{}))]{([{}<>])<(<><>){[]<>}}}})({{{(()())[[][]]}{<{}{}>
|
||||
{{([[((({(({({<><>}([]{}))([()()]{[]{}})}[[({}{})<(){}>]<<()<>>>]){[[[()()][<>[]]}<[{}()]{{}<>}
|
||||
{([<[[<<({[<(<()<>>(()())){<<>[]><()[]>}>[({{}<>})]][[(<()<>>{(){}})[{[]<>}[[]{}])][[(()()){[][]}]<{{}{}}<[
|
||||
[<{[((<([[([<<{}()>{{}()}>{(()[])[<>{}]}]<{[<><>]{<>{}}}>)]{[{{{()<>}[{}<>]}<<()>{{}{}}>}]({{<
|
||||
[<((<<({[{<{[[<><>](<>{})]{<()()><[]{}>}}<<[{}()]<[][]>><({}<>)>>>{<[[()<>]<{}[]>]<(<>()){<>{}}>>[{(()[])[{
|
||||
([(<<{{<[<(<<[[]{}]({}{})><[()[]]{<><>}>>[[{[]<>}[{}()]][({}{})({}())]>){(<{(){}}[{}[]]>[{[][]}<<
|
||||
([<{<<<[[<{[{({}{})[{}[]]}])[[(({}{}){()<>})<[()[]]<[][]>>]<(<()()>{()()}){(<><>)([]())}>]>]]<<{
|
||||
[{((<<{[{[<<<(()[])[[][]]>>><{<{<>[]>{[]{}}>{<<>()>[<><>]}}[{{<>{}}([]())}{({}[])[<><>]}]>][(<({<>()}[[]{}])[
|
||||
<(<[[<{(<[(<[([]())]({<>()}({}()))>[({(){}})[[[][]][<>{}]]]){{[[<><>]{{}[]}]<[(){}]<{}()>>}(<(<>{
|
||||
{{{([[(<<<{[{(<><>){<>[]}}<<[][]><()<>>>]<[[(){}][<>[]]]{{()<>}[{}()]}>}[{{({}<>)}[[{}{}]{{}[]}]}[([()()]
|
||||
{(<[{[{([({[[{<>}]{[<>{}]([][])}]{[(<>[])({}())]<{<><>}({}<>)>}}<[[(<>()){()[]}][<()()>{[]{}}]]<{[[]][[]()]
|
||||
<{(({({(<{{<{{()()}<()[]>}{[[]()](<>[])}>}<<({{}()}<[]{}>)[{[]()}]><<<<><>>[<>[]]>>>}([<[{()[]}(()()
|
||||
[[[{<({{[[<[{[(){}]<[]<>>}[[<>[]]{()<>}]]({<{}[]>[<>[]]}{({}{})<{}[]>})>{[[{[]{}}{<><>}]{(
|
||||
<([<[(([[[[([<[][]>]<([]()){<>()}>){[{[]()}([][])]<{[]<>}({}<>)>}]<[[[[]<>][<>{}]]{{{}()]{<>(
|
||||
<({{<<<{<<[[[<()<>>[()[]]]](<[{}<>]{[][]}>[{<>()}<()()>])]><{<[<()<>>[[]()]]<<[][]><()()>>>
|
||||
[[{{(([[<{[[(<[][]><<><>>}[{{}()}]]{(<<><>>({}<>))[[[][]]<[]{}>]}]<[{({}<>)[[]]}({()()}[<><>
|
||||
([<[([[<{<((<<{}()>[<>()]>)(<{{}()}>(<[]<>>{()()})))>({<<{(){}}{{}}><[<>{}]<<>{}>>>{([(){}](<>)){{()<>}({
|
||||
[{[[<((({[{[<[[]()]<{}[]>>{<{}<>>(<>[])}]<{({}{}){{}[]}}{[[]<>]([][])}>}(<{(<>)[()<>]>>(({{}()})[[{}[]]{[]}
|
||||
[{[[({<<{([{{({}())[()[]]}<[<>()]({}{})>}({[{}<>]<<><>>}{{[]<>}{()]})][<([<>()]({}[])){[{}{}](<>[])}>[((()
|
||||
{{((<[{{[[(<{({}()){()<>}}[{{}<>)({}{})]>({<(){}>[[]{}]}[[[]()]<{}>]))<<{[[]{}]({}[])}{<()>({}
|
||||
<{<({[[({<(<<<[][]>[<>[]]><(()[])>>{([[]<>]({}{}>)})((<[{}][{}<>]>{(()<>)})<<<<>[]>[(){}]>[(<>{})<<>[]>]>)>}
|
||||
[[[{[[{<{({<({{}<>}({}<>))>{[({}())]}})[<[[([][])][<{}<>><()<>>]]([[<><>]<[]()>]<({}{})(<><>
|
||||
[<({{[(<{(<<((<>)<{}[]>){{<>[]}<{}{}>}>(<(<><>)<{}<>>><{{}()}[{}()]>)>([([[]{}][{}[]])]))}>((({{
|
||||
<<{({{(<([[(<[<>()]<<><>>>(<[]()>{{}<>})){{<{}[]>[()()]}<(<>[])<()[]>]}]{({<(){}>{[]()}}[(<>
|
||||
(({<[({{[[{{[[()[]]([][])]{(<>[])<(){}>}}<<({}{})([]())><({}[])>>}<<<<{}[]>{[]{}}>(<[][]>[{}{}])>(({()<>
|
||||
{[[([<[{[{<[[({}[])<{}[]>]([<>[]]({}{}))][({()[]}(()()))]>{<<({})([]{})>{[[]()](()()]}>[(((){})(()[]))<[[]<>
|
||||
({[(<[(<({<[[[{}()]][<()()>[()[]]]]<{{<>[]}}[[[]{}]([]<>)]>>})<<{[<[()[]](()()}><(()())[<><>]>
|
||||
((<[{([[{(([([<>()][[][]])]))}]])<{(<<{{<<[]{}>({}())>}}>>[{([[{{}()}{(){}}]](((()[])[(){}])<[<><
|
||||
{(<{[{<<(<<[<<{}{}>><[[][]}{(){}}>]{{{[]<>}[[]<>]}}>{({<{}<>>({}<>)}<<[]<>>>)[(<{}<>>(<>))<[
|
||||
[<({<<({[{[<[([]<>)]{[(){}]({})}>{{((){})}[<[][]>]}]({(<{}<>>(<>())){{[]()}(()())}}(((<>{}){()()}){{[]()}<<>
|
||||
[[{{[<<[[[<<[{{}[]}<(){}>][{(){}}<{}[]>]>>(({({}{}}{<>{}}}([<>[]](()[]))))]{[[{((){})<<>()>}{{()[]}{<>()}}]<
|
||||
{(([([<({[[{{[<>[]][<>[]]}[([][])[{}()]]}[([()()][{}()])([<>{}])]]][[{[([]{}){[]()}][<(){}
|
||||
<{{[{<(((({[{<[]()>({}{})}]}))<[((<([]<>)[{}[]]>{<(){}>[[][]]}))[{<[()()][{}()]>(({}[])<<>[]>)}[((<>()){{}
|
||||
[(<[{[[<{[([{{[]()}<()>}(([]())<(){}>)][(({}{})<{}<>>)])(<({{}()}({}))<[()[]]{<>[]}>><(<{}<>><{}<>>)<({}<>
|
||||
{([({<<((({[({[][]})<{{}{}}<{}()>>]}<(<<[]()><()<>>>{{[]<>}([][])})(<{[]<>}[[]<>]>)>){([{<[]()>[<>[]]}[{<><
|
||||
[{{<<[<<<<{<({[]}[()[]]){{{}<>}[(){}]}>({([]())({}[])>)}><[[{[()<>]({}{})}<<<>{}>{()[]}>]{{[[][]]}(<<>()><
|
||||
(({({[{({[{[{([][])[[][]]}]{{{[]()}({}[])}({<>[]}(<>))}}[<<([]<>)>(<{}{}>{()})>[{[<><>][<>{}]}]]]}([{
|
||||
(({{<[{[([({([{}{}][{}<>])<<{}{}><<>()>>})]([((<[]()>[{}()])<<{}<>>((){})>)]<{[[{}<>]<[][]>]<(()[]
|
||||
{<[({<[[<[(<<({}[])[[]()]>([<>{}]{{}<>})>[<<{}[]>{<>()}><[<>{}]({}[])>])]{{{({{}{}}<[]()>)
|
||||
{<(({<[({<<[[[()[]]<{}<>>]]>><[{<{<><>}(<><>)>[[()[]]{<><>}]}[[{<><>}{{}<>}]({{}{}}[[][]])]]<<[{{}{}}<<>[]>]
|
||||
[<{({{(({([{(<{}[]>(<>{}))<[[]{}](()[])>}<{(<>{})(<>{})}>])<<<<({}<>){<>{}}>[(()()>(()())]>
|
||||
({((({[(<{{({({}())[[]<>]}([<>[]]{{}()}))<({{}()}<{}{}>)[{[]{}}({}[])]>}[([{{}<>}<{}>])[{{()[]}{{}()}}[([]{
|
||||
[<[{<{([<({<[[{}<>]{[][]}]{<<>{}><<><>>}>({[[]{}]<{}<>>}{{{}<>}(()[])})}){{{[<[]()><[][]>]
|
||||
<<{<{[[{([{<[<{}[]>{[]<>}]<<{}{}>[{}[]]>>}([([{}{}]{<><>})[{<>{}})])]){{([[<{}[]>({}[])][[<><>]
|
||||
([[(<([[[<[((([]{}){[]<>}))<{<[][]>[[]()]}[(()<>)<[]{}>]>]{[([[][]][()[]]){{(){}}[{}<>]}]}><
|
||||
<[{{<{<({{([[[[]{}]<{}()>><([]()){[]{}}>]<{<()[]>([]())}>)}<<{{((){}){[][]}}(({}<>)(()()))}([{[
|
||||
({{({[[{<({[({<>{}}[<>()])(([][]){{}{}])][({{}<>}(()[]))[<[]()><[]{}>]]}[{(<()[]><[]()>)[<{}()>{()[]}]}
|
||||
<<<{<{[([[[[(<()[]>){<[]()><[]()>}]<<([])<[]<>>><[[]<>][<>[]]>>]<<[[()()](<><>)]({()()}[<>[]])>([<[]
|
||||
((([{([({({<(<{}()>[()<>])<[{}<>]<{}[]>>>][{<[[][]]{{}()}>[({}()){[]<>}]}([{{}{}}[[]()]])])<[(({<>()}
|
||||
([<<[(<{<<[<[{()[]}{()[]}](({}[]){{}[]})>]{([{()[]}])({{<>()}(()())})}>((({{()()}(()<>)}][[(<>()){()}
|
||||
({[{[((<[<{<([[][]]{{}()})[{<>()}(<>{})]>{{{{}}}{{()}({}[])}}}>]<(<{<(<>())(()())>}>[<{[{}<>]{{
|
||||
{({[<{<[[[[<({<>{}}{()[]}){<[]()><[]()>}>([(<>())[[]()]](({}{})[()<>]))]]({([[<>{}]<{}[]>](<()()><()<>>))
|
||||
([<[<{<<<<((({<>}[<>{}])<({}())<()<>>>)[[[[]()][{}{}]]<(()<>)[<>]>]){{[({}())][([][])<()[]>]}{
|
||||
[{[({{<[{[<<[[<>()]]<([]())>><<<[][]>>{[()<>]{{}}}>>]}]{<{{{{[<>{}]({}[])}<{{}}{<>{}}>}{<({}){<>
|
||||
{<<{{({([{[([{[]<>}{<>[]}](<()[]>))[([{}]<()<>>)<<<>[]>[()<>]>]]}{[{<[()[]][{}{}]>{[[]()][{}[]]}}({[[]{
|
||||
((<(<{{<([{[{{()[]}{<><>}}{{<>}({}{})})[([(){}][[][]])[<()[]><(){}>]]}<([(<>()){[][]}][([]())([]())])[
|
||||
<<{[{{<{<[[[<<()<>>[()[]]>([()]{{}[]})]](<[(()<>)[()[]]]>{<[{}{}]>[<<><>><<><>>]})][{((<{}{}>[()
|
||||
<<<[[<[[([{[(<()><[]{}>)[(()[])[[]{}]]]{[{{}<>}[{}<>]]}}[(<<<>()><()[]>>[({}())<(){}>])[[[[][]][<
|
||||
[[<(({[(([{{<([][])[[][]]>[{{}{}}{<>[]}]}<[(<><>)](<[][]>[<>{}])>}]{{{([(){}]([]))<[{}<>](())>}([[(
|
||||
[<{[([<{({([((()>[{}[]])[(<><>){[][]}]])([{([]<>){[][]}}<(()[]){[]()}>]<((<>{}){[][]})({{}()}<()[
|
||||
((((<<<({([<{[{}()]{[]{}}}{({}[]){(){}}}>[[{()[]}[<>()]]<(()<>){(){}}>]]{[<(()())[{}[]]>(<<>()>({}
|
||||
(<({((((<{{{[{{}{}}[(){}]][{<>{}}{(){}}]}([[{}[]]{<><>}]<[[]{}]<[][]>>)}({[[{}<>]<(){}>]}<{{<>[]}}<<<>[]>
|
||||
{(<{(<{({(([{{()()}}][(({}{})<{}>)])<<(<()<>>{{}<>})(((){})[[]{}])><[[<>{})[<><>]][{()()}]>
|
||||
<{[(<[[{(<({[<{}()>{{}{}}]{(()){[]{}}}}[{{[]<>}[{}{}]}])({({[][]}{[]()})})>(<{{(()[])<<>>>[<<>[]><[]<
|
||||
([<[<[[{<[<(([<>{}]){[(){}]<()()>})<{([]{}}<{}<>>}{<{}{}><[]()>}>>(<<{<><>}(<>())>({<>}[{}{}])>(<(<><>)
|
||||
([{[[(<[(([{[{<>[]}{<>()}]<[(){}](<>{})>]<<<<>[]>>{(<><>)<[]{}>}>])){{{{<([]<>)([]{})><{{}{
|
||||
[<{({{(({<[([[()<>]{[][]}]({<>[]}(()[])))](<<({}())([][])>[{()<>}(()())]><{[<>{}]<<>()>}[[{}()]{<><>}]>)>{
|
||||
{({{{{[{{[<{{<[][]>([])}<[[]{}][{}()]>}>]{{[[<<>[]>[[][]>]<<{}<>>(()<>)>]{[[<>{}]{{}[]}]}}<[[[<><>]<<
|
||||
<({{({(({{<{{([]{}){<><>}}<(<>())({}{}]>}[{((){})(<>())}]>(({<[]()>([]{})}({{}{}}<<>()>)))}[[([<{}<>>
|
||||
[[<{<{<((<<({(<>())(<>())}{{(){}}[{}()]})<(<{}<>>{(){}})>>{{({[][]}{{}[]})<<{}<>>(()<>)>}<<<<>()>>{({}{}){()
|
||||
{[(<<<{(<{<<({<>{}}{()[]}>({<>[]}({}()))>>}>)<{(<(<({}[]){()[]}>)>((({()[]}[[][]]){<[][]><<>()>})[(([]<>)<
|
||||
<[<[{<[{[[<([<{}()>[<>]]{[[][]]<{}()>}}>({{{<>[]}{()[]}}{{()}<<><>>}}<<([])([][])>{[{}<>]((
|
||||
{[<<[[(<<{[<[[[]]({}())]([{}()][[]<>])>]}<({{(()[])<[][]>}{({})<()<>>}})([((()[])<[]<>>)<{(){}}([]())
|
||||
<{{<[[[(((<[{({}()){()()}}(<{}()>{()<>})]{{{()()}}{[[]{}]({}())}}>))<{<(((()<>)[{}[]])){[<[]<>>{{}()
|
||||
<([((<<(((({{[{}<>]<[]<>>}(<[]{}><[]{}>)}[{{<>[]}}{(<>{}){[]<>}}])<<{(()())<<>{}>}[[{}[]][{}()]]>[<[[]()
|
||||
{({{({[[({[<[<<><>)<{}{}>][<(){}>{[]{}}]>({(<>{})(<>())}<({})({})>)]})]<({[[({[]<>}{()()}){({}()
|
||||
((([[(<(<[([({{}()})[{{}()}({}{})]]{({[]()}{{}()})(<()[]><<>[]>)}){{([{}()])}}]<[(<(<><>)[()[]}>[{{}<>}])]>>[
|
||||
{(([(<[[[[<<([(){}][<>[]]){({}())[[]{}]}>>[[<{()[]}{(){}}>(<{}{}><{}{}>)]<([()[]]<{}>)(<()[]>{
|
||||
{({([(<{<[[<<[<><>]<<><>>>>[<<{}<>>[{}<>]>{[[]{}][{}<>]}]]][{{<[{}[]]({})><[()()]>}}<[<{[]<>}[[]()]>]{[
|
||||
(((<{([<[(<[{([][])<[][]>}({{}<>}[{}{}])]>[[({[]<>}{<>{}})]})[{({(()[])([][])}{<()()>[[][]
|
||||
<(<{{<([<(<{<{{}}{<>{}}>}([([]{}){(){}>]{<()<>>([])})>)<<({<[]<>>})({[()[]]}<[(){}]{{}()}>)>{[<<[][]>>({[]{
|
||||
({{(<(([[{((<<()[]><{}<>>>])}][<({<[{}[]][{}{}]><(()())([]())>})>{<(<{[]{}}{{}<>}>{{[]<>}{<><>}})>}]]{<[{[[
|
||||
{<[<([(((<[{[(())]}[(<{}()>)([[]][{}])]]{({<[]{}><()[]>}{{[]()}<{}<>>})}>){(({{<(){}>{<>[]}}(<(){}>(
|
||||
([[{<{{{({{<[<[][]><()()>>><<[<>()]>>}{[[(())]<{[]<>}<()<>>>]}})(<({[([]<>)<<>[]>]({<>()}[
|
||||
{<[<<[((<<{<{([]<>)(<><>)}([()<>][{}[]])>}<<{{[]()}(<>{})}([<><>]({}[]))>{<[()<>]<{}()>>{<()(
|
||||
{<{(<[[[<[{<[({}())<()<>>]>[{([]{})([]<>)}[<[][]>]>}][<([[()<>]{[][]}]){<[[]()](()())>({()}(()()))}>({<[()<
|
||||
[{({<<<({{<[(({}[]){{}()})[{[]{}}{<><>}]]<{<[][]>(<>())}([<>{}])>>}[(<{{<>}([][])}>{{[[]()][[][]]}{<<>()><
|
||||
<<([{{[(<[([<{[]()}<<><>>><(()())<()[]>>][{<[]()><{}()>}{<<><>>[()<>]}])(<<<<>{}][{}[]]>[{<>}({}
|
||||
((<<<<[{<[[<[{()()}<[][]>]{(()<>)}><{[[]{}]<{}{}>}>]<<{{[]<>}([])}{({}())([]{})]><[(<>())(<>{})]>>]><([<(([]
|
||||
{[[<(<[({[[[{{<>()}<()()>}]]]}[({(<[[][]]>(<{}<>>))}[<{<[]{}>(()<>)}{<{}{}>[()<>]}>])(<{([[]<>]){
|
||||
{{<<{([<{[[[(<{}{}>[[]<>])({<><>}{{}[]})]]][([([()[]])[(()<>)<[]{}>]]<{{()<>}{[]()}}<<[]{}>{
|
||||
<(([[<(({{(<{{()<>}[<>()]}[({}())[[][]]]>{{[{}<>]((){})][<<>{}><[]{}>]})<<({{}()}<<>{}>){(<>())[<>{}]}>(
|
||||
(<[(<<(((([<[<{}[]>][[()()]<<>()>]><[<{}{}>{()<>}](<()()])>][{{[{}<>]{<>()}}[<()()><{}>]}<(<{}{
|
||||
({{({[(<[{[<[((){})({}{})]([<>[]][[]()])>](<(<(){}><()()>)({<>{}}<{}()>)><{{<>()}(())}<{()()}<[]()>>
|
||||
{<([(<<{([[[[(()<>)(()())]][[([]{})({}())]<[[]<>]{()[]}>)]([[<(){}>{<>{}}]((()())[()()])])]
|
||||
(<<(((<[[{[{<[()<>]{<>{}}>([[]()][()()])}]{([<[]<>>{<>[]}]<<[][]>[{}()]>){<{[][]}[<>{}]><[<>[]]({}{}
|
||||
<([[[(<[([{((<<>()>{()[]}){(<>())([])})[{<{}[]>([][])}[({}[])[<>()]]]}[(<<<>{}><()<>>><<<>[]>{(
|
||||
[[{<[[(<<<(([(<><>)([][])](([]{}){[]{}}))[<[[]{}]>([[]()]{[][]})])>{{{[<()[]>[[]{}]][{()<>}[<>[]]]}}
|
||||
([(<{<<(<{{{[[<>[]]<(){}>]([()[]][()[]])}{((<>()))}}{<[<{}<>>(<><>)](([][])<<>()>)}}}(<<[<{}[]
|
||||
<[{{({{<[<[{(<<>[]>(<>()))<([]<>)[{}<>]>}]>{<<{<[]{}>(<>())}>([<(){}><(){}>]{[<>()]([]())})>}]>}})}}{(((
|
||||
[<(((<{<<[(<{(<>[])}>){(<<{}<>>([]<>)>{<{}()>}}[[<{}{}>{[][]}](<<>[]>{{}[]})]}]><<([<[(){}]<()>><[(){}]
|
||||
({[[(<[{(<((<[()[]]{[]<>}>){<(<>){()<>}>})(({<(){}>[{}[]]})[[(()[]){[]<>})<{[]()}>])>)<<<(<({}())(<>[])
|
||||
[{([<<<[{{([<<{}{}>>[{{}[]]]])}<<[<{{}}{<><>}>(({}{})[<>[]])]({[<><>]([][])}{(()<>)<<><>>})
|
||||
[[<(<<[{([[[[<[]{}><[]()>]][{[[][]]<()<>>}]]]{{{(<[]{}>(()<>))<(<>[])<<><>>>}]({{(()[]){{}()}}
|
||||
({<<<{[<[[[{([{}<>]{<>()})(<<><>>)}(<(<>[])<{}>))][({<{}[]>[[][]]}(([]())(()[])))<<[[]()]{<><>}>>
|
||||
[{<[[{{[<<([([<><>]([]<>))]({[()[]][{}{}]}{{()()}[[]<>]})){(<(()[])<[]()>><[[]()]<()<>>>)(<<()(
|
||||
{<({((<([<(({{[]<>}[{}<>]}[<()[]><[]{}>]){<{[][]}{<><>]>})(({({}())[()()]}{[{}()][[]<>]}))>])<(<{(<{
|
10
input/day11
10
input/day11
|
@ -1,10 +0,0 @@
|
|||
2566885432
|
||||
3857414357
|
||||
6761543247
|
||||
5477332114
|
||||
3731585385
|
||||
1716783173
|
||||
1277321612
|
||||
3371176148
|
||||
1162578285
|
||||
6144726367
|
|
@ -24,12 +24,12 @@ impl Day for Day08 {
|
|||
}
|
||||
|
||||
fn do_stuff((input, output): (Vec<String>, Vec<String>)) -> anyhow::Result<i32> {
|
||||
let out = output.iter().map(|x| get_char(&input, x)).collect::<anyhow::Result<Vec<_>>>()?.join("");
|
||||
let out = output.iter().map(|x| get_char(&input, x.clone())).collect::<anyhow::Result<Vec<_>>>()?.join("");
|
||||
|
||||
out.parse().map_err(anyhow::Error::new)
|
||||
}
|
||||
|
||||
fn get_char(input: &[String], s: &str) -> anyhow::Result<String> {
|
||||
fn get_char(input: &[String], s: String) -> anyhow::Result<String> {
|
||||
let one = input.iter().cloned().find(|x| x.len() == 2).ok_or_else(|| anyhow::Error::msg("could not find one"))?.chars().collect::<Vec<char>>();
|
||||
let four = input.iter().cloned().find(|x| x.len() == 4).ok_or_else(|| anyhow::Error::msg("could not find one"))?.chars().collect::<Vec<char>>();
|
||||
let chars = s.chars().collect::<Vec<char>>();
|
||||
|
|
|
@ -22,7 +22,7 @@ impl Day for Day09 {
|
|||
basin_edges.extend(self.neighbours(low));
|
||||
while !basin_edges.is_empty() {
|
||||
let mut new_basin_edges = HashSet::new();
|
||||
for &p in &basin_edges {
|
||||
for &p in basin_edges.iter() {
|
||||
new_basin_edges.extend(self.neighbours(p).filter(|&n| {
|
||||
!basin_points.contains(&n)
|
||||
&& !basin_edges.contains(&n)
|
||||
|
@ -67,7 +67,7 @@ impl Day09 {
|
|||
|
||||
fn low_points(&self) -> Vec<(usize, usize)> {
|
||||
let (h, w) = self.dimensions();
|
||||
(0..h).flat_map(|y| (0..w).filter(|&x| self.check((x, y))).map(|x| (x, y)).collect::<Vec<_>>()).collect()
|
||||
(0..h).map(|y| (0..w).filter(|&x| self.check((x, y))).map(|x| (x, y)).collect::<Vec<_>>()).flatten().collect()
|
||||
}
|
||||
|
||||
fn get_point(&self, (x, y): (usize, usize)) -> u32 {
|
||||
|
|
158
src/day10.rs
158
src/day10.rs
|
@ -1,158 +0,0 @@
|
|||
use std::str::FromStr;
|
||||
use crate::Day;
|
||||
|
||||
pub struct Day10(Vec<Vec<BracketType>>, Vec<(usize, Bracket)>);
|
||||
|
||||
impl Day for Day10 {
|
||||
fn init(content: String) -> anyhow::Result<Self> {
|
||||
let l = content.lines().map(|x| x.chars().map(|x| x.to_string().parse().unwrap()).collect::<Vec<BracketType>>()).collect::<Vec<_>>();
|
||||
Ok(Self(l.clone(), gather_part1(l)))
|
||||
}
|
||||
|
||||
fn part1(&self) -> anyhow::Result<String> {
|
||||
Ok(format!("{}", self.1.iter().map(|&(_, b)| {
|
||||
match b {
|
||||
Bracket::Round => 3,
|
||||
Bracket::Square => 57,
|
||||
Bracket::Curly => 1197,
|
||||
Bracket::Angle => 25137,
|
||||
}
|
||||
}).sum::<u32>()))
|
||||
}
|
||||
|
||||
fn part2(&self) -> anyhow::Result<String> {
|
||||
let mut wrongs = self.1.clone();
|
||||
let mut zz = self.0.clone();
|
||||
wrongs.sort_unstable();
|
||||
wrongs.iter().rev().for_each(|&(x, _)| std::mem::drop(zz.remove(x)));
|
||||
let mut scores = Vec::new();
|
||||
for z in zz {
|
||||
let mut stack = Vec::new();
|
||||
for bracket in z {
|
||||
match bracket {
|
||||
BracketType::Open(x) => stack.push(x),
|
||||
BracketType::Close(x) => {
|
||||
if let Some(y) = stack.pop() {
|
||||
assert_eq!(y, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stack.reverse();
|
||||
let mut score = 0_u64;
|
||||
for b in stack {
|
||||
score *= 5;
|
||||
score += match b {
|
||||
Bracket::Round => 1,
|
||||
Bracket::Square => 2,
|
||||
Bracket::Curly => 3,
|
||||
Bracket::Angle => 4,
|
||||
}
|
||||
}
|
||||
scores.push(score);
|
||||
}
|
||||
scores.sort_unstable();
|
||||
|
||||
|
||||
Ok(format!("{:?}", scores[scores.len() / 2]))
|
||||
}
|
||||
}
|
||||
|
||||
fn gather_part1(v: Vec<Vec<BracketType>>) -> Vec<(usize, Bracket)> {
|
||||
let mut wrongs = Vec::new();
|
||||
for (idx, brackets) in v.iter().enumerate() {
|
||||
let mut stack = Vec::new();
|
||||
for &bracket in brackets {
|
||||
match bracket {
|
||||
BracketType::Open(x) => stack.push(x),
|
||||
BracketType::Close(x) => {
|
||||
if let Some(y) = stack.pop() {
|
||||
if x != y {
|
||||
wrongs.push((idx, x));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
wrongs
|
||||
}
|
||||
|
||||
impl FromStr for BracketType {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"(" => Ok(BracketType::Open(Bracket::Round)),
|
||||
"[" => Ok(BracketType::Open(Bracket::Square)),
|
||||
"{" => Ok(BracketType::Open(Bracket::Curly)),
|
||||
"<" => Ok(BracketType::Open(Bracket::Angle)),
|
||||
")" => Ok(BracketType::Close(Bracket::Round)),
|
||||
"]" => Ok(BracketType::Close(Bracket::Square)),
|
||||
"}" => Ok(BracketType::Close(Bracket::Curly)),
|
||||
">" => Ok(BracketType::Close(Bracket::Angle)),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Debug)]
|
||||
pub enum BracketType {
|
||||
Open(Bracket),
|
||||
Close(Bracket),
|
||||
}
|
||||
|
||||
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Debug)]
|
||||
pub enum Bracket {
|
||||
Round,
|
||||
Square,
|
||||
Curly,
|
||||
Angle,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::Day;
|
||||
use crate::day10::Day10;
|
||||
|
||||
const INPUT: &str = r"[({(<(())[]>[[{[]{<()<>>
|
||||
[(()[<>])]({[<{<<[]>>(
|
||||
{([(<{}[<>[]}>{[]{[(<()>
|
||||
(((({<>}<{<{<>}{[]{[]{}
|
||||
[[<[([]))<([[{}[[()]]]
|
||||
[{[{({}]{}}([{[{{{}}([]
|
||||
{<[[]]>}<{[{[{[]{()[[[]
|
||||
[<(<(<(<{}))><([]([]()
|
||||
<{([([[(<>()){}]>(<<{{
|
||||
<{([{{}}[<[[[<>{}]]]>[]]";
|
||||
|
||||
#[test]
|
||||
fn part1_test() -> anyhow::Result<()> {
|
||||
let d = Day10::init(INPUT.to_string())?;
|
||||
assert_eq!("26397", d.part1()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2_test() -> anyhow::Result<()> {
|
||||
let d = Day10::init(INPUT.to_string())?;
|
||||
assert_eq!("288957", d.part2()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1_real() -> anyhow::Result<()> {
|
||||
let d = Day10::init(crate::load_input("10")?)?;
|
||||
assert_eq!("392421", d.part1()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2_real() -> anyhow::Result<()> {
|
||||
let d = Day10::init(crate::load_input("10")?)?;
|
||||
assert_eq!("2769449099", d.part2()?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
145
src/day11.rs
145
src/day11.rs
|
@ -1,145 +0,0 @@
|
|||
use std::collections::HashMap;
|
||||
use crate::Day;
|
||||
|
||||
type FlashMap = HashMap<(i32, i32), i32>;
|
||||
|
||||
pub struct Day11(FlashMap);
|
||||
|
||||
impl Day for Day11 {
|
||||
fn init(content: String) -> anyhow::Result<Self> {
|
||||
let mut map = HashMap::new();
|
||||
for (y, n) in content.lines().enumerate() {
|
||||
for (x, char) in n.chars().enumerate() {
|
||||
map.insert((x as i32, y as i32), char.to_string().parse::<i32>()?);
|
||||
}
|
||||
}
|
||||
Ok(Self(map))
|
||||
}
|
||||
|
||||
fn part1(&self) -> anyhow::Result<String> {
|
||||
let mut hm = self.0.clone();
|
||||
let mut flashes = 0;
|
||||
for _ in 0..100 {
|
||||
hm.iter_mut().for_each(|(_, x)| *x += 1);
|
||||
let mut flashing = get_flashes(&hm);
|
||||
let mut flashed = vec![];
|
||||
do_flash(&mut hm, &mut flashing, &mut flashed);
|
||||
|
||||
let flashing = get_flashes(&hm);
|
||||
for f in &flashing {
|
||||
if let Some(entry) = hm.get_mut(f) {
|
||||
*entry = 0;
|
||||
}
|
||||
}
|
||||
flashes += flashing.len();
|
||||
}
|
||||
|
||||
Ok(format!("{}", flashes))
|
||||
}
|
||||
|
||||
fn part2(&self) -> anyhow::Result<String> {
|
||||
let mut hm = self.0.clone();
|
||||
for num in 0..1000 {
|
||||
hm.iter_mut().for_each(|(_, x)| *x += 1);
|
||||
let mut flashing = get_flashes(&hm);
|
||||
let mut flashed = vec![];
|
||||
do_flash(&mut hm, &mut flashing, &mut flashed);
|
||||
if flashed.len() == 100 {
|
||||
return Ok(format!("{}", num + 1));
|
||||
}
|
||||
let flashing = get_flashes(&hm);
|
||||
for f in &flashing {
|
||||
if let Some(entry) = hm.get_mut(f) {
|
||||
*entry = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(anyhow::Error::msg("It did not flash 100 times :("))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_flashes(hm: &FlashMap) -> Vec<(i32, i32)> {
|
||||
hm.iter().filter(|(_, &x)| x > 9).map(|(&p, _)| p).collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
fn do_flash(mut hm: &mut FlashMap, mut flashing: &mut Vec<(i32, i32)>, mut flashed: &mut Vec<(i32, i32)>) {
|
||||
if let Some((x, y)) = flashing.pop() {
|
||||
flashed.push((x, y));
|
||||
for xn in (x - 1)..=(x + 1) {
|
||||
for yn in (y - 1)..=(y + 1) {
|
||||
if let Some(e) = hm.get_mut(&(xn, yn)) {
|
||||
*e += 1;
|
||||
if *e > 9 {
|
||||
if !flashed.contains(&(xn, yn)) && !flashing.contains(&(xn, yn)) {
|
||||
flashing.push((xn, yn))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
do_flash(&mut hm, &mut flashing, &mut flashed)
|
||||
}
|
||||
}
|
||||
|
||||
fn print_flashes(map: &FlashMap, x_max: i32, y_max: i32) {
|
||||
let mut v: Vec<Vec<i32>> = Vec::new();
|
||||
for y in 0..y_max {
|
||||
let mut col = Vec::new();
|
||||
for x in 0..x_max {
|
||||
col.push(*map.get(&(x, y)).unwrap());
|
||||
}
|
||||
v.push(col);
|
||||
}
|
||||
for line in v {
|
||||
for ch in line {
|
||||
print!("{}", ch)
|
||||
}
|
||||
println!()
|
||||
}
|
||||
println!()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::Day;
|
||||
use crate::day11::Day11;
|
||||
|
||||
const INPUT: &str = r"5483143223
|
||||
2745854711
|
||||
5264556173
|
||||
6141336146
|
||||
6357385478
|
||||
4167524645
|
||||
2176841721
|
||||
6882881134
|
||||
4846848554
|
||||
5283751526";
|
||||
|
||||
#[test]
|
||||
fn part1_test() -> anyhow::Result<()> {
|
||||
let d = Day11::init(INPUT.to_string())?;
|
||||
assert_eq!("1656", d.part1()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2_test() -> anyhow::Result<()> {
|
||||
let d = Day11::init(INPUT.to_string())?;
|
||||
assert_eq!("195", d.part2()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part1_real() -> anyhow::Result<()> {
|
||||
let d = Day11::init(crate::load_input("11")?)?;
|
||||
assert_eq!("1647", d.part1()?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part2_real() -> anyhow::Result<()> {
|
||||
let d = Day11::init(crate::load_input("11")?)?;
|
||||
assert_eq!("348", d.part2()?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -12,8 +12,6 @@ use crate::day::Day;
|
|||
use anyhow::Result;
|
||||
use crate::day08::Day08;
|
||||
use crate::day09::Day09;
|
||||
use crate::day10::Day10;
|
||||
use crate::day11::Day11;
|
||||
|
||||
mod day;
|
||||
mod day01;
|
||||
|
@ -25,8 +23,6 @@ mod day06;
|
|||
mod day07;
|
||||
mod day08;
|
||||
mod day09;
|
||||
mod day10;
|
||||
mod day11;
|
||||
|
||||
fn load_input(day: &str) -> Result<String> {
|
||||
read_to_string(format!("./input/day{}", day)).map_err(|x| x.into())
|
||||
|
@ -70,9 +66,7 @@ fn main() -> anyhow::Result<()> {
|
|||
Box::new(Day06::init(load_input("06")?)?),
|
||||
Box::new(Day07::init(load_input("07")?)?),
|
||||
Box::new(Day08::init(load_input("08")?)?),
|
||||
Box::new(Day09::init(load_input("09")?)?),
|
||||
Box::new(Day10::init(load_input("10")?)?),
|
||||
Box::new(Day11::init(load_input("11")?)?),];
|
||||
Box::new(Day09::init(load_input("09")?)?),];
|
||||
|
||||
let _verbosity = matches.occurrences_of("v");
|
||||
if matches.is_present("all") {
|
||||
|
|
Loading…
Reference in a new issue