Compare commits
1 Commits
master
...
bb74658f9c
| Author | SHA1 | Date | |
|---|---|---|---|
| bb74658f9c |
13
.gitignore
vendored
13
.gitignore
vendored
@@ -1,14 +1 @@
|
|||||||
**/target/
|
**/target/
|
||||||
|
|
||||||
|
|
||||||
# Added by cargo
|
|
||||||
|
|
||||||
/target
|
|
||||||
|
|
||||||
|
|
||||||
# Added by cargo
|
|
||||||
#
|
|
||||||
# already existing elements were commented out
|
|
||||||
|
|
||||||
#/target
|
|
||||||
Cargo.lock
|
|
||||||
|
|||||||
50
2021/Cargo.lock
generated
50
2021/Cargo.lock
generated
@@ -2,27 +2,14 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "advent"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"aoc-runner",
|
|
||||||
"aoc-runner-derive",
|
|
||||||
"pretty_assertions",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "advent2021"
|
name = "advent2021"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"advent",
|
|
||||||
"ansi_term",
|
"ansi_term",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"aoc-runner",
|
"aoc-runner",
|
||||||
"aoc-runner-derive",
|
"aoc-runner-derive",
|
||||||
"pretty_assertions",
|
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -70,49 +57,12 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ctor"
|
|
||||||
version = "0.1.21"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa"
|
|
||||||
dependencies = [
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "diff"
|
|
||||||
version = "0.1.12"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "output_vt100"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9"
|
|
||||||
dependencies = [
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pretty_assertions"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ec0cfe1b2403f172ba0f234e500906ee0a3e493fb81092dac23ebefe129301cc"
|
|
||||||
dependencies = [
|
|
||||||
"ansi_term",
|
|
||||||
"ctor",
|
|
||||||
"diff",
|
|
||||||
"output_vt100",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.32"
|
version = "1.0.32"
|
||||||
|
|||||||
@@ -10,6 +10,4 @@ ansi_term = "0.12.1"
|
|||||||
anyhow = "1.0.45"
|
anyhow = "1.0.45"
|
||||||
aoc-runner = "0.3.0"
|
aoc-runner = "0.3.0"
|
||||||
aoc-runner-derive = "0.3.0"
|
aoc-runner-derive = "0.3.0"
|
||||||
pretty_assertions = "1.0.0"
|
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
advent = { path = "../" }
|
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
{<[[<<<[[{[[<<()()>>[([]<>){{}{}}]]]<(<{{}<>}{{}{}}><{<>[]}[{}{}]>)({(())}<[(){}][(){}]>)>}]<<<(<<{}
|
|
||||||
{[({({([({(((<[]()>[()<>]){[<>[]](<>[])})<<<[]()}>(<()()>)>)}[{((<{}[]>{<>()}){[<>{}]<<><>>})(({[]()}<<>()>)<
|
|
||||||
(((([{{{<{<[[<()<>><<>{}>]]{<(<>())>}>{<[([]<>)<{}{}>][[<><>][<>[]]]>[{(<>{})[<>()]}<<()[]>[[]<
|
|
||||||
<<[<([[{{{[({<<>()>}<<<>[]>([]())>){{{{}[]}<(){}>)}]{{[(()())[(){}]]<<[]{}>({}[])>}({<<><>>}<([]<>){()[]}>)}
|
|
||||||
<[(({[({<<[[[{<>{}}(<><>))<(<>[])[{}[]]>]<[([][])[(){}]]>]([<[()()](<>[])>]<(<{}()>[{}<>])({<>[
|
|
||||||
(<[[{[[[(<((<<{}{}><[]<>>><[{}<>][<>[]]>)<(<{}<>><{}{}>)[{()[]}<<>()>]>)>[(<{({}{})}[{()[]}{[]<>}]>){<(([]
|
|
||||||
(([[({{{(<([({[]{}}){{[][]]}])>)[<([[[{}]{(){}}][([]())]]([{[][]}{<>()}](({}()){<>{}})))[{({
|
|
||||||
{(<<([([(<<[{((){})([]<>)}]<{{{}{}}{{}[]}}<{(){}}{()[]})>><([<[]{}>([]<>)](<()<>>)){<([]<>
|
|
||||||
{[<<[<{{((({<[[]{}]{{}}>{<{}<>>[<>[]]}})<{[(<><>><{}<>>][{[]{}}]}[[[[][]]<<>{}>]{[[]()][[]<>]}]>)[(
|
|
||||||
({<(<([{<{<[(((){}){(){}})]>}[{{{{()()}<[]()>}{{<>()}<{}{}>}}[[{{}{}}[<><>]]{({}[]>[[]{}]}]}({{{()()
|
|
||||||
{[[{([{<<{<(<<{}()>[()]>)<{{()()}}[<[][]>(<>{})]>>{[<{<>()){()<>}>{{()()}[<>()]}][[[{}[]]]<{{}[]}<()(
|
|
||||||
{{<<<<<[[([{<[{}[]]{()<>}>{<<>()>{{}<>}}}<<{{}()}{()()}>{[()<>]({}[])]>]{[(<{}{}>)<({}[])>]<{({}<>)}{({}())
|
|
||||||
({(<<{[<<{<(<[<>()][[][]]><[{}<>]({}[])>)[[[<>[]][[]()]]<{[]{}}[{}{}]>]>{[(<[]()>{<>{}})][<{{}}<{
|
|
||||||
(<<<[[({<[[(<<[]{}>>[(()<>)[<>{}]])<{(<>[])}(<<>()>[[]{}])>]<[({[]()}{{}{}})<{{}()}<{}<>>>]>][[({<<>()>{[]()}
|
|
||||||
{{{[<[([<(<{[([][])[{}[]]]{[()()]{{}()}}}><[<([][])(<>())><{()[]}({}<>)>]<<<(){}><<><>>>((()()){
|
|
||||||
[(((([{({<(<(<[]<>>{()[]})><{(<><>){{}[]}}{(()<>)([][])}>)>})}][({{[[{<(<><>){{}()}>((<>()){<>[]
|
|
||||||
([{<{<({(<[(<({}<>)><{[]}[{}[]]>)(<[[][]]{[]{}}>{{[]}((){})})]{(((()){{}()})(([][])({}{})))[(<()[]><(
|
|
||||||
[([{{<{(<[{{((()())<[]{}>){{{}<>}<<><>>}}[<([]())>[(()[])<{}{}>]]}{[({(){}}{(){}])<<[]()>{{}()}>
|
|
||||||
(<[<{{[<<({<<{<><>}><<()[]>[<><>]>>}{[(((){}){()<>}}<<[]()>{(){}}>]{{{{}[]}[{}<>]}[{{}{}}<(){}>]}}){{({
|
|
||||||
<([([[<[({<<{{[][]}<{}[]>}<<()[]>[()<>]>>>})((<(<[[]]((){})>{([]()){<><>}})>)(<<<<[]<>>[[]()])>>([[
|
|
||||||
[<<{<(<<{{[({<<>()><{}[]>})<{[<>()](<><>)}[{{}()}{[]()}]>]}}({<[{<()<>>}[<<>>]]((<[][]>{[][
|
|
||||||
{{(<({[((<([({()<>})[{{}[]}(()<>))]{[{[]<>}][{()<>}]})([({<><>}{{}()})])>)({<(((()<>)(<><>)))>((
|
|
||||||
[(<{({[<{<[<([{}()](<>{}))>]([([[]<>]<()<>>){<()>}]{{[[]()]{{}{}}}[{[]}{{}<>}]})>}<([<[<<>[]>]{<(){}>{
|
|
||||||
[[[[<(<({<[[<{()}{{}[]}><[<><>]<()[]>>](<([]{})[{}]>)]>}<[{[[{(){}}]{(<><>)}][<<[][]>{(){}
|
|
||||||
{(({({[{{((<[([]())((){})]>){[{(<>[])}<([]{})[[]<>]>]({<()<>>[[]<>]}[<()>{<>[]}])})({<([[][]]((){}))([<>{}])
|
|
||||||
<(<(<<{[<<{<<[()[]][[]()]><([][])<{}()>>}}>[<<<<{}<>>>{[{}][{}{}]}>[<[()()]{{}[]}>[{[][]}([])]]>[[<<[][]>(
|
|
||||||
<<{{({<<(([{{([][])(()<>)}}(<<[]{}>>)])([{[(()[])]}<{{<><>}<[]<>>}[<{}<>><[]<>)]>]{{<[{}[]]
|
|
||||||
({[[[[(([[[{<({})([]())>{{<>{}}}}][[<<[]>[<>()]>]{[[[]<>][<>{}]]{[<>[]]}})][[<(<(){}>{()[]})><[[()[
|
|
||||||
(((((([{{{(<<(<>{}){<>}><(()[])<()[]>>>{[<{}<>>(<>())}<{{}()}>})((([(){}]{<>})[{[]{}}{{}[]
|
|
||||||
(([([(((<[(({[<>()]{[][]}})[{{[]()>[[]{}]}(<<>{}><{}<>>)]){[({[]}(<>[]))([()()][<>{}])]({({}
|
|
||||||
[(<({{([[<(((<<>()>[[]<>])({{}()}<()<>>))[[{[]()}<()<>>][{()()}<{}[]>]])>({(<({}{})<()[]}>[{()
|
|
||||||
{{{[([<{{{([<<<>{}>{()<>}>{<{}()><<><>>}]([{()}]))<{[<()()>{()[]}]{({}[])[<>()]}}>}}}({<(({({
|
|
||||||
[([([<[<(<[{{{<>()}{()[]}}({()[]}[{}<>])}{[{<>}]([[][]]<(){}>)}]>[[{<[<>()][{}()]>(((){}>[<>[]])}{{{<>(
|
|
||||||
{{[{{[[<{(<([[[][]]([]<>)])>)<{<<{<>()}[<>()]><((){})<<><>>>>([<<><>>(()<>)]([(){}}{[]<>}))}>}(({{{{[]}{
|
|
||||||
[[[[({[<({{[[(<><>)]{<<>[]>([]{})}]<[{[]}{()()}]([<>()]([]<>>)>}})>{{<([{<{}{}>{()}}])({<[<>()](<><>)>
|
|
||||||
{[({<[({[{[({[{}()][[]<>]}((()<>)<{}<>>))<[{{}}({}{})]>]{[<<<>[]>[[][]]>(({}[])(()[]))>{(([]{})({}[]))([
|
|
||||||
[<<([{{(<<[<[[{}[]]](<[]{}>[<>{}])>[[<{}[]>(<>[])]{([][])[()[]]}]][[{{()[]}[<>{}]}(<<>{}>[[]
|
|
||||||
<[(([{([([<{[[(){}]<<>{}>]}[[[()()]{{}<>}]]>[[{({}{})[()()]}([()()][<>[]])]{<[[]<>][[][]]>}]]{{<{[<>
|
|
||||||
[<[[[[([[{[[<[{}{}]([]<>)>[({}[])<[]<>>]][<{()()}[<>[]]>([[]]<<><>>)]]}([<{{{}[]}}{(()<>>({}[
|
|
||||||
<[<{[(<{({[<[[[][]]([][])]<([]){{}<>}>>[({<>{}}<[]>)]]([[([]{})[[]()]][[[]{}]({}{})]](<[{}<>
|
|
||||||
({[<([(<[[<([[(){}]<<>{}>])({[[]{}]<()[]>}<<[]<>>{[][]}>)>{<[<[]()><{}[]>]([<>()]({}[]))><(
|
|
||||||
({<<<{<({[[{[{<>{}}[<><>]]}{(({})[()()])<<()<>>([]{})>}]]]{<{{([[]<>](<>[]))[[{}()]({}())]}}>((<([{}<>])>{{<[
|
|
||||||
[{([{[[{{<{<[{[]()}<[]{}>]>({<{}[]>{<>[]}})}[(({{}<>}<{}<>]){[[]{}]({}[])})]>}}]({([[([<()()>{[]
|
|
||||||
<[{([([{[{<(([<>[]]{<>()})<{{}<>}>){([<><>])<(()[])<<>{}>>}><{{[{}<>]{<>}}[(())[()<>]]}<{[{}{}]{{}{}}}<{{}<>
|
|
||||||
[{<<([{{(((<{<<>()>[{}()]}>{<<<>[]><[]()>>}){[(([][])([]()))<{{}[]}[[]()]>][[{{}<>}({}{})]{({}{})(<
|
|
||||||
{({[((<([[[{{([])[()()]}({{}{}}))<(<[]<>>[()[]])>]<<([[]<>])<[<>()][[]<>]>>({[<><>]{{}[]}}({()[]
|
|
||||||
{[(<(<{[({[(<<[]>{<>{}}>[{<><>}([]())])(<[[][]]<()<>>>[(()[])])]<{[{()[]}[<>{}]]}[{<(){}>(<>{})}<<<>()>>]
|
|
||||||
(<{<[<({{{{([({}{})[[]{}]]({{}<>}<()[]}))}(<<{<>()}{()<>}>{[<>{}][()[]]}>{<<[][]>{<>()}><(<>{})<{}[]>>})}
|
|
||||||
{(<<{[({<<[(<{{}{}}<[]<>>>((<>())([]<>)))]>><<({<{[]<>}([]<>)>{[()()]}}<<{{}<>}<()()>>(<()()
|
|
||||||
<([([<(<[({[[({}()){()<>}](({}{})(<><>))][{({}<>)<{}{}>}{([]){(){}}}]})]>)<[[{<{{(()){<>[]}}({{}()}
|
|
||||||
<<<([{[({{{((<{}()>{()()})[[<>()]])[[[{}()]<{}()>]{{[]<>}{{}())}]}<<{<<>><<><>>}[{{}[]}(<><>)
|
|
||||||
<([<[<{[[[{[{[<><>][{}<>]}(<[]{}>)]}([{{<>()}<{}[]>}{([]<>)[(){}]}]<{((){})<[]()>}[<[]()><()[]>]>
|
|
||||||
[([[[[[({{[(<[{}<>]<{}()>><[<><>]{<>()}>)]}<{(<(()<>)<{}{}>>{{()<>}(()()}})}>})(<[<([<<>[]>((){})]([[]<>]<()
|
|
||||||
{(<[[{(((([[([{}()]<{}()))[({}{}){[]}]](<<<>[]>>([<>{}]))][(<({}{})<()[]>><<[]{}><{}[]>>)])(<([([][])[
|
|
||||||
({(([{{<{{{<[<<>[]>{()<>}][([][]){()<>}]>([<()>(<><>)]<{<><>}<[]>>)}<{[[<>[]][<>{}]]<{<>()}{[][]
|
|
||||||
{[([[[(([<{<{[[]<>]<<>()>}<<()()>([]{})>>[<<()[]>(<>())>[(()<>)]]}>]{{({{{{}[]}({})}<{{}<>}[[]()]>}((
|
|
||||||
[<([[<[{{{[[[<<>{}>]{<()[]>{[]<>}}]{([[]{}]({}()))}]}}}(<{<[[({}{})<()()>]]({({}<>)[[]]}{[<><>]{<>{}}})>(<[
|
|
||||||
<<(<<{{(({<[<<[]{}>{()()}}[[()[]]]]{[(<>{}){<>}]{[{}](<>)}}><{<(()())<[]<>>>[<(){}>(<>[])]
|
|
||||||
{<(<[<[(((<{((()[])([]<>))([[]<>]({}[]))}><<([<>())<[]<>>)(<{}[]>({}<>))>[[([]())]({()()}{{}<>})
|
|
||||||
[[((<[[[{{<{<{{}()}[{}()]>{{[]{}}[<><>]}}>}<{[<[(){}]<<><>>]([{}<>]<<><>>)]}(<<[{}<>]<<>{}>
|
|
||||||
<[{{[[{<[{(({[(){}]({}{})})[([{}<>][()()])[<[][]><{}<>>]])}](<({(([]<>){()[]})[([]())((){})]}{{{<>{}}<[]()>}<
|
|
||||||
<{((<([[{<<[(<{}()><{}[]>)]>[([{<>()}<()()>]<{()[]><()[]>>){<[{}[]]>[{[][]}(<><>)]}]>{{[{{{}<>}{<>}}[[(){}]<(
|
|
||||||
{<[({(<{{[([{{[]{}}((){})}[[{}[]]<{}()>]]((<[]<>>)<([]()){{}[]}>))(<<{()[]}{[]})>[[(()())]{[()<>][<>(
|
|
||||||
<<{[[[[{<({<[[{}()]]{{[]<>}{[]}}><{{{}()}({}{})}>}{([({}[])({}())](({}[])))[<{[]<>}[<>()]><<[]<>>(<>[])>]}
|
|
||||||
[(([<<[{[{<({{()[]}<<><>>})[[([]())[[]{}])(<<>{}>)]>(<{{[][]}[{}()]}([{}{}][(){}])>((<<>[]>(()
|
|
||||||
[({<<[[<{[<<({[]()}<()<>>)>]]{{<[[[]][{}<>]]>}{([[<>{}][{}{}]]<((){})(()[])>)}}}([{((<{}[]>)[<{}[]><{}()>])}
|
|
||||||
{[[((<[{<<([{<<><>>([]{})}<(<><>)<<>()>>][{[[]{}]{()()}}<({}{})([][])>])><<{({<>{}}[<>()])((
|
|
||||||
[[[<{{(<((([{<[]{}>({}<>)}[<<>()>]]<<(()[]){{}[]}>{(()<>){{}<>}}>){{{(()())[<><>]}[[[]<>]{<>[]}]}}))[
|
|
||||||
(<({[({[[({{<{<>{}}<()[]>>[{(){}}<<>[]>]}[[<[][]><()<>>]({<>{}}{[]()})]}{(([[]<>][{}[]])(<[]<>>([
|
|
||||||
{([<{[<({{{({[[][]][()()])[<<>()><[][]>])}<{{{[]()}[{}()]}{{<>()}{<>}}}((({}())<{}{}>){(<>{})[<>{}]})>}})(((
|
|
||||||
([[[[[[{(((((<<>()>[[]<>])<{()()}[()<>]>){<[()[]]<<>[]>>(<<>{}}{{}[]})}))<<[([()()][[]()])[{()[]}([]())]][<([
|
|
||||||
({{((((<{<[{[(<>{})][<()()>[[]()]]}]{({(<>())[[]()]}{<[][]><[][]>})}>}>{<<{{(({}())[<>])((()[])<[]<>>)}}[
|
|
||||||
<(<[[[<<{([<<[[]<>]{<>[]}><{()()}([]<>)>>]{<{(<>())((){})}{[{}{}]<<>{}>}>})({([[{}{}]])[(<<>()>[
|
|
||||||
{[(<{<[[{<{{(<()[]><<>{}>){[()<>]<{}<>>}}[[[<>{}][[]<>]]]}<[[({})<<>[]>]]{{<()<>><<>[]>}<{()[]}((){}
|
|
||||||
({[{(<<{[<{({[()()]{{}}}<({}{}){()()}>)}<{(({}{})[<>[]]){([]())[[][]]}}{(<[]<>)[()])[[<>()]]}>>
|
|
||||||
(({<<[<[<<<({<{}[]>({}{})}{<{}[]><{}[]>})>>(<<(<()()>{[]{}})({()<>}[()()])>[{[{}()][[]]}({<>()}}]>(
|
|
||||||
<<(<(<[{([{<[[<>{}]<{}<>>]>{<(()[])(()())><{<>[]}{()()}>}}([{({}<>){<>{}}}{{<>[]}[{}{}]}]([<[]()>((){})
|
|
||||||
{[{([({[[<<<{{[]{}}<[]{}>}[<()[]><[]<>>]>([{{}[]][[][]]]{{(){}}({}[])})>(<{[<>{}](()<>)}>{[<[]()>
|
|
||||||
([[[<(<{[({<({()()}{<>()})((<>[])<[]<>>)>}<{<<{}()><<>>>}({{{}[]}}[(()[])[()<>]])>)<[<((()())[<>{}])(
|
|
||||||
{<(((<[((((({<[]>[[]{}]}))[(<[[][]][{}{}]>){{[<>()][[]<>]}([()()](<><>))}])){(<[{[<>()][{}()]
|
|
||||||
({([{<(((<{[<[{}[]]<<>>>({{}[]}[[]()])]([<(){}>])}{<[{<>[]}{[]<>}][<<><>){<>{}}]>[<((){})([]{})>[[{}{}][()
|
|
||||||
<[{[<[{[({{<(({}<>}[[]()])>({{[][]}}<[(){}](()[])>)}})([[{{<<>()>([]{})}[<<>{}>[<><>]]}]])]
|
|
||||||
{(<{([{[[({[(<[]{}>)({{}[]}{()()}))<{(()[])}[[()()]{{}[]}]>}<{<(()<>)>{{[]{}}({}())}}({{{}[]}{<
|
|
||||||
[<<{<{<<(<([<(<>()){[]()}>[({}<>)({}<>)]][(([]{}){()[]})[{{}()}(()())]])>{([{{()[]}<<>[]>}<{<>[
|
|
||||||
{{[[(([([({([([]<>)(()())][{<>()}{(){}}])})])]([{{[<{{{}<>}(<>())>{[()()]<<>[]>}>[{(()){{}[
|
|
||||||
[({({({(({{(<[()()][{}<>]>[[{}()]{(){}}])<[<<>[]>][<{}>(<>{})]>}(((({}())({}{}))){{(()[])<[][
|
|
||||||
<(<(<[([<[{[<(()<>)<()[]>><(<>())([][])>]{<[{}<>]{{}()}>{[[]{}](<>{})}}}<[<([]{})><{{}<>}([]())>]>]>
|
|
||||||
<<<(<<[({{{<{({}<>)<()[]>}<[()<>]{(){}}>><{[[]()]<[]{}>}[({}{})<(){}>]>}(<[<<>[]>{()[]}]>)}[<{[<{}>[{}{
|
|
||||||
{(<((<[{{[[[[<{}{}]<{}()>]][{({}{})<<>{}>}[<()[]>(()())]]]{([<[]()><[]{}>](<{}()>))({<<><>>(<>())}{
|
|
||||||
{({{[[<[{<{{(<<>>)(<[]()>[()])}([({}<>)])}[[{[()<>][()[]]}]({<[]<>>{<>()}})]><<(<<{}()>{<>[]
|
|
||||||
{{{[{[<<{[[{[{{}<>}<[][]>]{(()[])<<>()>}}[<{()()}[(){}]><<()[]>>]]{<((<>{})({}()))[<(){}>([][])]>{({{}[]}<
|
|
||||||
<{{[<{({{{[<{{<>()}{{}()}}>]<{<[()[]](<><>)><[<>[]]{(){}}>}<([(){}]<{}{}>){(())}>>}[([{[[]<>][{}<>]}[{()}(
|
|
||||||
[<<[{{(({({<{{{}{}}{<>[]}}({[][]}{<>[]})>[{[{}<>][<>[]]}[({}[])[[]<>]]]})}))<(<[[<(({}()))[<<>()>{(
|
|
||||||
{<<([<{({[{{[({}[])<<>{}>]([()<>]<(){}>)}<([{}[]]({}{}))>}[<<<<>{}>[[][]]>{<<>[]><()>}>[<<<>><[][]>
|
|
||||||
[({(<({[<[{{[<<>[]>[()[]]]<<<>[]>>}}<{([{}[]](<>{}))[{<>}{{}<>}]}(<<[][]>>[{[]<>}])>]>[(<(({<>[]}{<><>}))(<
|
|
||||||
{<[[{{<<{(<(<([]<>)[[][]]>[([]{})[<>{}]])<[{<>()}{[]<>}]>>>[{(({()()}[<>[]]){({}())<[]<>>})}[(<{<>
|
|
||||||
{[[{{{<[<[{<(({}{})[{}()])[(<><>)({}())]>}{[<{[]{}}[()[]]>]<{[()()]<[]()>}<[[][]]>>}]>{{({{{()[]}{{}(
|
|
||||||
<{[<([{{[[<(<{<><>}[{}{}]><((){})>){[[()()][()[]]]{[[]<>]}}>]<<(<({}[])<{}[]>>{(<><>)<[]()>}){(<
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
7313511551
|
|
||||||
3724855867
|
|
||||||
2374331571
|
|
||||||
4438213437
|
|
||||||
6511566287
|
|
||||||
6727245532
|
|
||||||
3736868662
|
|
||||||
2348138263
|
|
||||||
2417483121
|
|
||||||
8812617112
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
zs-WO
|
|
||||||
zs-QJ
|
|
||||||
WO-zt
|
|
||||||
zs-DP
|
|
||||||
WO-end
|
|
||||||
gv-zt
|
|
||||||
iu-SK
|
|
||||||
HW-zs
|
|
||||||
iu-WO
|
|
||||||
gv-WO
|
|
||||||
gv-start
|
|
||||||
gv-DP
|
|
||||||
start-WO
|
|
||||||
HW-zt
|
|
||||||
iu-HW
|
|
||||||
gv-HW
|
|
||||||
zs-SK
|
|
||||||
HW-end
|
|
||||||
zs-end
|
|
||||||
DP-by
|
|
||||||
DP-iu
|
|
||||||
zt-start
|
|
||||||
@@ -1,910 +0,0 @@
|
|||||||
724,201
|
|
||||||
596,511
|
|
||||||
883,560
|
|
||||||
637,47
|
|
||||||
869,537
|
|
||||||
251,505
|
|
||||||
851,618
|
|
||||||
980,544
|
|
||||||
818,661
|
|
||||||
1093,390
|
|
||||||
641,95
|
|
||||||
1006,621
|
|
||||||
447,434
|
|
||||||
820,865
|
|
||||||
475,847
|
|
||||||
788,72
|
|
||||||
1066,829
|
|
||||||
1303,882
|
|
||||||
1165,696
|
|
||||||
164,229
|
|
||||||
202,333
|
|
||||||
244,485
|
|
||||||
261,840
|
|
||||||
1116,581
|
|
||||||
976,513
|
|
||||||
550,635
|
|
||||||
1151,728
|
|
||||||
1211,570
|
|
||||||
228,422
|
|
||||||
223,539
|
|
||||||
406,369
|
|
||||||
306,758
|
|
||||||
1247,894
|
|
||||||
760,859
|
|
||||||
826,737
|
|
||||||
340,637
|
|
||||||
1293,47
|
|
||||||
99,187
|
|
||||||
264,553
|
|
||||||
927,523
|
|
||||||
940,189
|
|
||||||
586,313
|
|
||||||
525,67
|
|
||||||
296,581
|
|
||||||
353,694
|
|
||||||
55,264
|
|
||||||
582,491
|
|
||||||
264,154
|
|
||||||
512,394
|
|
||||||
1101,225
|
|
||||||
555,187
|
|
||||||
1021,535
|
|
||||||
805,772
|
|
||||||
783,891
|
|
||||||
403,402
|
|
||||||
1243,94
|
|
||||||
495,593
|
|
||||||
1031,695
|
|
||||||
13,472
|
|
||||||
705,637
|
|
||||||
459,618
|
|
||||||
939,322
|
|
||||||
251,82
|
|
||||||
899,523
|
|
||||||
301,131
|
|
||||||
873,891
|
|
||||||
880,374
|
|
||||||
894,737
|
|
||||||
306,593
|
|
||||||
1257,280
|
|
||||||
88,885
|
|
||||||
621,655
|
|
||||||
38,640
|
|
||||||
514,539
|
|
||||||
1222,885
|
|
||||||
1257,135
|
|
||||||
1191,303
|
|
||||||
1034,715
|
|
||||||
649,738
|
|
||||||
719,103
|
|
||||||
1131,367
|
|
||||||
907,402
|
|
||||||
169,297
|
|
||||||
482,408
|
|
||||||
977,866
|
|
||||||
1280,432
|
|
||||||
1087,803
|
|
||||||
473,810
|
|
||||||
182,546
|
|
||||||
785,155
|
|
||||||
1257,871
|
|
||||||
1091,483
|
|
||||||
310,52
|
|
||||||
758,712
|
|
||||||
870,715
|
|
||||||
1211,772
|
|
||||||
1173,40
|
|
||||||
73,460
|
|
||||||
117,312
|
|
||||||
228,243
|
|
||||||
918,822
|
|
||||||
475,50
|
|
||||||
765,3
|
|
||||||
1113,410
|
|
||||||
127,544
|
|
||||||
880,422
|
|
||||||
291,675
|
|
||||||
1088,187
|
|
||||||
957,506
|
|
||||||
591,791
|
|
||||||
566,437
|
|
||||||
1178,593
|
|
||||||
159,728
|
|
||||||
1237,684
|
|
||||||
490,665
|
|
||||||
929,311
|
|
||||||
641,267
|
|
||||||
966,766
|
|
||||||
1081,253
|
|
||||||
735,649
|
|
||||||
857,750
|
|
||||||
999,367
|
|
||||||
989,221
|
|
||||||
0,185
|
|
||||||
445,395
|
|
||||||
108,168
|
|
||||||
586,761
|
|
||||||
1203,595
|
|
||||||
1115,89
|
|
||||||
838,665
|
|
||||||
487,301
|
|
||||||
289,647
|
|
||||||
903,133
|
|
||||||
251,53
|
|
||||||
887,800
|
|
||||||
1093,443
|
|
||||||
775,684
|
|
||||||
1026,481
|
|
||||||
601,311
|
|
||||||
661,476
|
|
||||||
1198,627
|
|
||||||
0,753
|
|
||||||
1231,786
|
|
||||||
410,821
|
|
||||||
358,742
|
|
||||||
1179,780
|
|
||||||
763,435
|
|
||||||
1077,133
|
|
||||||
927,182
|
|
||||||
681,144
|
|
||||||
497,597
|
|
||||||
1088,483
|
|
||||||
649,476
|
|
||||||
1202,415
|
|
||||||
440,583
|
|
||||||
1198,14
|
|
||||||
104,775
|
|
||||||
619,443
|
|
||||||
410,660
|
|
||||||
1034,656
|
|
||||||
115,575
|
|
||||||
601,728
|
|
||||||
338,222
|
|
||||||
84,301
|
|
||||||
1111,891
|
|
||||||
1211,122
|
|
||||||
653,614
|
|
||||||
1290,282
|
|
||||||
209,582
|
|
||||||
440,43
|
|
||||||
929,583
|
|
||||||
53,166
|
|
||||||
1004,301
|
|
||||||
263,572
|
|
||||||
818,233
|
|
||||||
1183,319
|
|
||||||
228,472
|
|
||||||
1257,166
|
|
||||||
656,329
|
|
||||||
53,135
|
|
||||||
669,267
|
|
||||||
815,593
|
|
||||||
1111,767
|
|
||||||
802,576
|
|
||||||
1226,660
|
|
||||||
1215,800
|
|
||||||
341,218
|
|
||||||
181,422
|
|
||||||
1046,565
|
|
||||||
159,280
|
|
||||||
119,303
|
|
||||||
1027,303
|
|
||||||
147,417
|
|
||||||
571,859
|
|
||||||
1173,261
|
|
||||||
1054,885
|
|
||||||
239,302
|
|
||||||
228,131
|
|
||||||
85,217
|
|
||||||
1231,226
|
|
||||||
137,709
|
|
||||||
21,131
|
|
||||||
1290,612
|
|
||||||
718,845
|
|
||||||
837,782
|
|
||||||
164,141
|
|
||||||
632,467
|
|
||||||
749,313
|
|
||||||
525,379
|
|
||||||
858,561
|
|
||||||
851,786
|
|
||||||
1228,857
|
|
||||||
33,239
|
|
||||||
868,670
|
|
||||||
1183,3
|
|
||||||
248,548
|
|
||||||
328,345
|
|
||||||
898,436
|
|
||||||
438,893
|
|
||||||
823,301
|
|
||||||
820,589
|
|
||||||
937,771
|
|
||||||
875,58
|
|
||||||
790,617
|
|
||||||
64,504
|
|
||||||
95,675
|
|
||||||
508,576
|
|
||||||
729,434
|
|
||||||
186,91
|
|
||||||
1092,392
|
|
||||||
403,166
|
|
||||||
87,514
|
|
||||||
1261,114
|
|
||||||
1141,597
|
|
||||||
217,390
|
|
||||||
689,151
|
|
||||||
457,515
|
|
||||||
585,805
|
|
||||||
1131,360
|
|
||||||
1212,472
|
|
||||||
669,464
|
|
||||||
318,682
|
|
||||||
485,73
|
|
||||||
1154,644
|
|
||||||
738,37
|
|
||||||
1297,870
|
|
||||||
361,207
|
|
||||||
932,238
|
|
||||||
880,264
|
|
||||||
376,738
|
|
||||||
87,380
|
|
||||||
174,94
|
|
||||||
411,819
|
|
||||||
845,633
|
|
||||||
1288,721
|
|
||||||
189,261
|
|
||||||
1294,374
|
|
||||||
72,267
|
|
||||||
649,642
|
|
||||||
156,644
|
|
||||||
517,406
|
|
||||||
705,562
|
|
||||||
1059,614
|
|
||||||
813,856
|
|
||||||
623,702
|
|
||||||
619,462
|
|
||||||
403,728
|
|
||||||
344,52
|
|
||||||
1178,634
|
|
||||||
1275,238
|
|
||||||
656,47
|
|
||||||
1176,169
|
|
||||||
244,821
|
|
||||||
328,121
|
|
||||||
1092,255
|
|
||||||
872,1
|
|
||||||
845,185
|
|
||||||
251,707
|
|
||||||
79,674
|
|
||||||
659,705
|
|
||||||
1048,520
|
|
||||||
1121,709
|
|
||||||
107,768
|
|
||||||
427,334
|
|
||||||
1257,311
|
|
||||||
112,14
|
|
||||||
997,351
|
|
||||||
552,429
|
|
||||||
1064,159
|
|
||||||
1114,453
|
|
||||||
398,306
|
|
||||||
1208,182
|
|
||||||
187,175
|
|
||||||
654,719
|
|
||||||
1225,665
|
|
||||||
735,245
|
|
||||||
1078,245
|
|
||||||
544,598
|
|
||||||
691,238
|
|
||||||
1168,164
|
|
||||||
264,740
|
|
||||||
855,833
|
|
||||||
1260,267
|
|
||||||
661,156
|
|
||||||
333,194
|
|
||||||
1212,870
|
|
||||||
555,803
|
|
||||||
445,11
|
|
||||||
1275,443
|
|
||||||
1067,35
|
|
||||||
783,787
|
|
||||||
785,379
|
|
||||||
162,141
|
|
||||||
661,866
|
|
||||||
873,3
|
|
||||||
321,476
|
|
||||||
1136,800
|
|
||||||
673,47
|
|
||||||
723,800
|
|
||||||
1129,84
|
|
||||||
127,891
|
|
||||||
927,371
|
|
||||||
781,647
|
|
||||||
1099,247
|
|
||||||
1275,3
|
|
||||||
691,891
|
|
||||||
218,639
|
|
||||||
731,626
|
|
||||||
1093,504
|
|
||||||
550,735
|
|
||||||
1019,880
|
|
||||||
477,142
|
|
||||||
147,508
|
|
||||||
392,822
|
|
||||||
542,432
|
|
||||||
209,235
|
|
||||||
410,234
|
|
||||||
895,113
|
|
||||||
107,798
|
|
||||||
7,23
|
|
||||||
119,591
|
|
||||||
709,364
|
|
||||||
1059,340
|
|
||||||
1198,148
|
|
||||||
179,360
|
|
||||||
226,49
|
|
||||||
43,98
|
|
||||||
195,640
|
|
||||||
452,561
|
|
||||||
49,52
|
|
||||||
359,761
|
|
||||||
1307,749
|
|
||||||
1235,392
|
|
||||||
556,355
|
|
||||||
547,58
|
|
||||||
790,725
|
|
||||||
8,683
|
|
||||||
1261,724
|
|
||||||
301,185
|
|
||||||
69,89
|
|
||||||
545,339
|
|
||||||
957,759
|
|
||||||
509,84
|
|
||||||
1235,564
|
|
||||||
663,12
|
|
||||||
1017,743
|
|
||||||
739,332
|
|
||||||
1213,392
|
|
||||||
1067,444
|
|
||||||
291,616
|
|
||||||
969,851
|
|
||||||
353,819
|
|
||||||
669,95
|
|
||||||
902,436
|
|
||||||
127,575
|
|
||||||
887,143
|
|
||||||
671,79
|
|
||||||
796,539
|
|
||||||
865,11
|
|
||||||
289,247
|
|
||||||
465,709
|
|
||||||
605,724
|
|
||||||
194,581
|
|
||||||
1223,788
|
|
||||||
810,771
|
|
||||||
932,208
|
|
||||||
333,225
|
|
||||||
1308,96
|
|
||||||
1257,23
|
|
||||||
709,311
|
|
||||||
87,123
|
|
||||||
845,807
|
|
||||||
845,574
|
|
||||||
552,630
|
|
||||||
1226,234
|
|
||||||
16,374
|
|
||||||
1247,0
|
|
||||||
381,311
|
|
||||||
957,11
|
|
||||||
393,392
|
|
||||||
545,219
|
|
||||||
523,332
|
|
||||||
820,661
|
|
||||||
472,229
|
|
||||||
1079,542
|
|
||||||
99,570
|
|
||||||
311,847
|
|
||||||
1130,500
|
|
||||||
519,135
|
|
||||||
207,434
|
|
||||||
435,235
|
|
||||||
373,499
|
|
||||||
731,368
|
|
||||||
800,348
|
|
||||||
373,771
|
|
||||||
904,861
|
|
||||||
687,192
|
|
||||||
1297,24
|
|
||||||
681,131
|
|
||||||
545,555
|
|
||||||
705,170
|
|
||||||
1009,200
|
|
||||||
63,828
|
|
||||||
1193,582
|
|
||||||
211,647
|
|
||||||
982,495
|
|
||||||
1206,159
|
|
||||||
1014,581
|
|
||||||
284,481
|
|
||||||
1294,394
|
|
||||||
5,156
|
|
||||||
641,627
|
|
||||||
744,885
|
|
||||||
900,212
|
|
||||||
557,887
|
|
||||||
908,289
|
|
||||||
786,856
|
|
||||||
785,515
|
|
||||||
527,61
|
|
||||||
73,684
|
|
||||||
698,637
|
|
||||||
522,294
|
|
||||||
79,226
|
|
||||||
843,175
|
|
||||||
754,315
|
|
||||||
798,606
|
|
||||||
25,730
|
|
||||||
790,169
|
|
||||||
947,686
|
|
||||||
509,646
|
|
||||||
157,38
|
|
||||||
994,451
|
|
||||||
31,702
|
|
||||||
622,453
|
|
||||||
390,742
|
|
||||||
256,558
|
|
||||||
1274,448
|
|
||||||
950,833
|
|
||||||
619,238
|
|
||||||
723,94
|
|
||||||
67,94
|
|
||||||
490,383
|
|
||||||
447,658
|
|
||||||
654,686
|
|
||||||
407,313
|
|
||||||
1054,9
|
|
||||||
982,175
|
|
||||||
1215,766
|
|
||||||
1198,880
|
|
||||||
1054,306
|
|
||||||
1305,156
|
|
||||||
407,245
|
|
||||||
328,208
|
|
||||||
273,787
|
|
||||||
693,807
|
|
||||||
939,751
|
|
||||||
232,245
|
|
||||||
1047,770
|
|
||||||
1063,133
|
|
||||||
87,828
|
|
||||||
1285,409
|
|
||||||
787,803
|
|
||||||
1056,715
|
|
||||||
654,701
|
|
||||||
1201,56
|
|
||||||
865,728
|
|
||||||
1000,318
|
|
||||||
546,31
|
|
||||||
671,63
|
|
||||||
490,29
|
|
||||||
863,658
|
|
||||||
234,841
|
|
||||||
940,481
|
|
||||||
7,460
|
|
||||||
1213,495
|
|
||||||
411,75
|
|
||||||
1280,856
|
|
||||||
949,599
|
|
||||||
743,106
|
|
||||||
301,435
|
|
||||||
390,497
|
|
||||||
416,157
|
|
||||||
411,523
|
|
||||||
1057,12
|
|
||||||
907,492
|
|
||||||
1138,486
|
|
||||||
132,301
|
|
||||||
383,571
|
|
||||||
833,304
|
|
||||||
271,323
|
|
||||||
788,238
|
|
||||||
726,112
|
|
||||||
30,432
|
|
||||||
1288,313
|
|
||||||
688,441
|
|
||||||
605,649
|
|
||||||
982,345
|
|
||||||
174,652
|
|
||||||
527,721
|
|
||||||
284,257
|
|
||||||
927,571
|
|
||||||
623,254
|
|
||||||
1082,243
|
|
||||||
977,669
|
|
||||||
472,665
|
|
||||||
705,724
|
|
||||||
947,768
|
|
||||||
559,800
|
|
||||||
951,133
|
|
||||||
207,460
|
|
||||||
279,247
|
|
||||||
360,833
|
|
||||||
1223,514
|
|
||||||
63,0
|
|
||||||
182,5
|
|
||||||
522,520
|
|
||||||
17,495
|
|
||||||
555,324
|
|
||||||
390,397
|
|
||||||
827,882
|
|
||||||
107,683
|
|
||||||
430,856
|
|
||||||
1150,656
|
|
||||||
579,788
|
|
||||||
769,170
|
|
||||||
164,677
|
|
||||||
1082,651
|
|
||||||
883,894
|
|
||||||
982,656
|
|
||||||
641,198
|
|
||||||
576,320
|
|
||||||
863,210
|
|
||||||
857,144
|
|
||||||
984,549
|
|
||||||
672,766
|
|
||||||
67,800
|
|
||||||
35,443
|
|
||||||
412,682
|
|
||||||
326,529
|
|
||||||
304,621
|
|
||||||
556,539
|
|
||||||
117,669
|
|
||||||
918,72
|
|
||||||
654,47
|
|
||||||
219,388
|
|
||||||
654,753
|
|
||||||
1246,56
|
|
||||||
654,641
|
|
||||||
1250,848
|
|
||||||
562,681
|
|
||||||
72,403
|
|
||||||
1228,305
|
|
||||||
641,422
|
|
||||||
758,856
|
|
||||||
1082,472
|
|
||||||
701,256
|
|
||||||
1077,761
|
|
||||||
820,511
|
|
||||||
755,324
|
|
||||||
658,509
|
|
||||||
960,733
|
|
||||||
801,10
|
|
||||||
769,378
|
|
||||||
430,38
|
|
||||||
647,12
|
|
||||||
129,291
|
|
||||||
201,750
|
|
||||||
522,374
|
|
||||||
837,422
|
|
||||||
75,564
|
|
||||||
977,225
|
|
||||||
609,256
|
|
||||||
855,350
|
|
||||||
1128,5
|
|
||||||
1245,495
|
|
||||||
1240,530
|
|
||||||
591,551
|
|
||||||
555,154
|
|
||||||
45,275
|
|
||||||
381,359
|
|
||||||
922,253
|
|
||||||
1026,257
|
|
||||||
251,280
|
|
||||||
629,798
|
|
||||||
739,371
|
|
||||||
492,708
|
|
||||||
719,551
|
|
||||||
508,318
|
|
||||||
678,427
|
|
||||||
1109,302
|
|
||||||
754,539
|
|
||||||
884,472
|
|
||||||
705,245
|
|
||||||
654,453
|
|
||||||
256,530
|
|
||||||
1184,793
|
|
||||||
79,201
|
|
||||||
731,788
|
|
||||||
1076,53
|
|
||||||
430,264
|
|
||||||
999,54
|
|
||||||
691,432
|
|
||||||
837,810
|
|
||||||
669,696
|
|
||||||
181,810
|
|
||||||
132,520
|
|
||||||
885,641
|
|
||||||
117,480
|
|
||||||
729,460
|
|
||||||
437,891
|
|
||||||
242,212
|
|
||||||
1263,507
|
|
||||||
353,75
|
|
||||||
316,787
|
|
||||||
179,24
|
|
||||||
967,815
|
|
||||||
490,305
|
|
||||||
214,583
|
|
||||||
801,646
|
|
||||||
1278,441
|
|
||||||
1163,392
|
|
||||||
485,521
|
|
||||||
845,709
|
|
||||||
104,159
|
|
||||||
276,715
|
|
||||||
85,229
|
|
||||||
522,145
|
|
||||||
214,851
|
|
||||||
377,257
|
|
||||||
490,661
|
|
||||||
1285,485
|
|
||||||
278,828
|
|
||||||
492,661
|
|
||||||
363,686
|
|
||||||
709,82
|
|
||||||
970,705
|
|
||||||
535,882
|
|
||||||
256,364
|
|
||||||
131,114
|
|
||||||
427,635
|
|
||||||
440,179
|
|
||||||
890,681
|
|
||||||
1029,571
|
|
||||||
360,61
|
|
||||||
78,413
|
|
||||||
746,179
|
|
||||||
1128,889
|
|
||||||
1288,173
|
|
||||||
1213,47
|
|
||||||
321,700
|
|
||||||
137,40
|
|
||||||
720,315
|
|
||||||
1241,89
|
|
||||||
137,807
|
|
||||||
99,539
|
|
||||||
104,287
|
|
||||||
527,891
|
|
||||||
415,116
|
|
||||||
229,253
|
|
||||||
574,605
|
|
||||||
276,686
|
|
||||||
329,838
|
|
||||||
1309,728
|
|
||||||
95,667
|
|
||||||
899,819
|
|
||||||
561,805
|
|
||||||
669,430
|
|
||||||
1206,735
|
|
||||||
1006,313
|
|
||||||
231,542
|
|
||||||
438,669
|
|
||||||
1211,355
|
|
||||||
947,880
|
|
||||||
783,168
|
|
||||||
93,581
|
|
||||||
415,302
|
|
||||||
195,254
|
|
||||||
231,784
|
|
||||||
442,670
|
|
||||||
872,225
|
|
||||||
800,98
|
|
||||||
817,58
|
|
||||||
1079,94
|
|
||||||
341,340
|
|
||||||
131,780
|
|
||||||
426,315
|
|
||||||
1211,826
|
|
||||||
1247,707
|
|
||||||
363,219
|
|
||||||
406,817
|
|
||||||
820,383
|
|
||||||
465,633
|
|
||||||
547,459
|
|
||||||
334,605
|
|
||||||
1115,254
|
|
||||||
927,164
|
|
||||||
5,866
|
|
||||||
239,778
|
|
||||||
97,847
|
|
||||||
271,730
|
|
||||||
75,392
|
|
||||||
438,225
|
|
||||||
326,686
|
|
||||||
570,301
|
|
||||||
564,179
|
|
||||||
195,192
|
|
||||||
1225,217
|
|
||||||
751,367
|
|
||||||
477,116
|
|
||||||
1116,805
|
|
||||||
801,84
|
|
||||||
247,674
|
|
||||||
189,126
|
|
||||||
1101,499
|
|
||||||
1161,570
|
|
||||||
989,418
|
|
||||||
400,491
|
|
||||||
810,123
|
|
||||||
468,397
|
|
||||||
1235,523
|
|
||||||
803,607
|
|
||||||
247,133
|
|
||||||
0,847
|
|
||||||
1146,305
|
|
||||||
884,315
|
|
||||||
164,569
|
|
||||||
913,313
|
|
||||||
412,212
|
|
||||||
112,627
|
|
||||||
209,312
|
|
||||||
711,523
|
|
||||||
427,894
|
|
||||||
1235,140
|
|
||||||
131,803
|
|
||||||
1232,413
|
|
||||||
199,891
|
|
||||||
49,724
|
|
||||||
947,14
|
|
||||||
313,351
|
|
||||||
898,10
|
|
||||||
1277,655
|
|
||||||
887,334
|
|
||||||
982,719
|
|
||||||
1230,829
|
|
||||||
316,222
|
|
||||||
209,728
|
|
||||||
592,845
|
|
||||||
1285,803
|
|
||||||
490,589
|
|
||||||
903,245
|
|
||||||
283,591
|
|
||||||
1197,516
|
|
||||||
197,827
|
|
||||||
619,451
|
|
||||||
509,884
|
|
||||||
1297,43
|
|
||||||
1141,73
|
|
||||||
1131,63
|
|
||||||
584,530
|
|
||||||
820,29
|
|
||||||
107,836
|
|
||||||
251,841
|
|
||||||
529,247
|
|
||||||
400,715
|
|
||||||
607,387
|
|
||||||
301,759
|
|
||||||
1048,374
|
|
||||||
227,707
|
|
||||||
281,771
|
|
||||||
711,607
|
|
||||||
1049,392
|
|
||||||
304,313
|
|
||||||
1235,626
|
|
||||||
209,883
|
|
||||||
452,333
|
|
||||||
30,408
|
|
||||||
403,492
|
|
||||||
510,98
|
|
||||||
933,68
|
|
||||||
161,58
|
|
||||||
1242,693
|
|
||||||
251,389
|
|
||||||
1191,322
|
|
||||||
1131,527
|
|
||||||
1213,439
|
|
||||||
586,201
|
|
||||||
904,369
|
|
||||||
783,319
|
|
||||||
929,359
|
|
||||||
838,348
|
|
||||||
878,411
|
|
||||||
109,443
|
|
||||||
1082,131
|
|
||||||
350,621
|
|
||||||
1048,889
|
|
||||||
326,208
|
|
||||||
763,96
|
|
||||||
132,593
|
|
||||||
84,350
|
|
||||||
1059,82
|
|
||||||
678,467
|
|
||||||
1091,836
|
|
||||||
1235,371
|
|
||||||
582,715
|
|
||||||
641,464
|
|
||||||
55,795
|
|
||||||
293,687
|
|
||||||
723,336
|
|
||||||
341,472
|
|
||||||
371,322
|
|
||||||
555,602
|
|
||||||
840,500
|
|
||||||
199,833
|
|
||||||
455,833
|
|
||||||
169,73
|
|
||||||
97,392
|
|
||||||
783,385
|
|
||||||
623,640
|
|
||||||
1111,840
|
|
||||||
765,891
|
|
||||||
1046,553
|
|
||||||
383,164
|
|
||||||
907,812
|
|
||||||
1131,870
|
|
||||||
1067,892
|
|
||||||
1129,472
|
|
||||||
246,436
|
|
||||||
644,670
|
|
||||||
624,38
|
|
||||||
353,135
|
|
||||||
666,227
|
|
||||||
835,399
|
|
||||||
112,148
|
|
||||||
247,859
|
|
||||||
383,99
|
|
||||||
535,684
|
|
||||||
338,555
|
|
||||||
552,805
|
|
||||||
594,17
|
|
||||||
880,472
|
|
||||||
801,436
|
|
||||||
997,472
|
|
||||||
559,667
|
|
||||||
341,676
|
|
||||||
247,35
|
|
||||||
1193,225
|
|
||||||
1,56
|
|
||||||
545,3
|
|
||||||
1149,58
|
|
||||||
455,710
|
|
||||||
753,887
|
|
||||||
687,640
|
|
||||||
1220,379
|
|
||||||
1115,724
|
|
||||||
1203,574
|
|
||||||
465,320
|
|
||||||
84,772
|
|
||||||
1273,359
|
|
||||||
873,339
|
|
||||||
783,3
|
|
||||||
199,54
|
|
||||||
1193,669
|
|
||||||
264,329
|
|
||||||
246,513
|
|
||||||
33,655
|
|
||||||
1293,495
|
|
||||||
432,187
|
|
||||||
601,871
|
|
||||||
803,47
|
|
||||||
825,373
|
|
||||||
259,110
|
|
||||||
586,245
|
|
||||||
412,436
|
|
||||||
927,347
|
|
||||||
345,775
|
|
||||||
970,257
|
|
||||||
870,311
|
|
||||||
|
|
||||||
fold along x=655
|
|
||||||
fold along y=447
|
|
||||||
fold along x=327
|
|
||||||
fold along y=223
|
|
||||||
fold along x=163
|
|
||||||
fold along y=111
|
|
||||||
fold along x=81
|
|
||||||
fold along y=55
|
|
||||||
fold along x=40
|
|
||||||
fold along y=27
|
|
||||||
fold along y=13
|
|
||||||
fold along y=6
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
VHCKBFOVCHHKOHBPNCKO
|
|
||||||
|
|
||||||
SO -> F
|
|
||||||
OP -> V
|
|
||||||
NF -> F
|
|
||||||
BO -> V
|
|
||||||
BH -> S
|
|
||||||
VB -> B
|
|
||||||
SV -> B
|
|
||||||
BK -> S
|
|
||||||
KC -> N
|
|
||||||
SP -> O
|
|
||||||
CP -> O
|
|
||||||
VN -> O
|
|
||||||
HO -> S
|
|
||||||
PC -> B
|
|
||||||
CS -> O
|
|
||||||
PO -> K
|
|
||||||
KF -> B
|
|
||||||
BP -> K
|
|
||||||
VO -> O
|
|
||||||
HB -> N
|
|
||||||
PH -> O
|
|
||||||
FF -> O
|
|
||||||
FB -> K
|
|
||||||
CC -> H
|
|
||||||
FK -> F
|
|
||||||
HV -> P
|
|
||||||
CO -> S
|
|
||||||
OC -> N
|
|
||||||
KV -> V
|
|
||||||
SS -> O
|
|
||||||
FC -> O
|
|
||||||
NP -> B
|
|
||||||
OH -> B
|
|
||||||
OF -> K
|
|
||||||
KB -> K
|
|
||||||
BN -> C
|
|
||||||
OK -> C
|
|
||||||
NC -> O
|
|
||||||
NO -> O
|
|
||||||
FS -> C
|
|
||||||
VP -> K
|
|
||||||
KP -> S
|
|
||||||
VS -> B
|
|
||||||
VV -> N
|
|
||||||
NN -> P
|
|
||||||
KH -> P
|
|
||||||
OB -> H
|
|
||||||
HP -> H
|
|
||||||
KK -> H
|
|
||||||
FH -> F
|
|
||||||
KS -> V
|
|
||||||
BS -> V
|
|
||||||
SN -> H
|
|
||||||
CB -> B
|
|
||||||
HN -> K
|
|
||||||
SB -> O
|
|
||||||
OS -> K
|
|
||||||
BC -> H
|
|
||||||
OV -> N
|
|
||||||
PN -> B
|
|
||||||
VH -> N
|
|
||||||
SK -> C
|
|
||||||
PV -> K
|
|
||||||
VC -> N
|
|
||||||
PF -> S
|
|
||||||
NB -> B
|
|
||||||
PP -> S
|
|
||||||
NS -> F
|
|
||||||
PB -> B
|
|
||||||
CV -> C
|
|
||||||
HK -> P
|
|
||||||
PK -> S
|
|
||||||
NH -> B
|
|
||||||
SH -> V
|
|
||||||
KO -> H
|
|
||||||
NV -> B
|
|
||||||
HH -> V
|
|
||||||
FO -> O
|
|
||||||
CK -> O
|
|
||||||
VK -> F
|
|
||||||
HF -> O
|
|
||||||
BF -> C
|
|
||||||
BV -> P
|
|
||||||
KN -> K
|
|
||||||
VF -> C
|
|
||||||
FN -> V
|
|
||||||
ON -> C
|
|
||||||
SF -> F
|
|
||||||
SC -> C
|
|
||||||
OO -> S
|
|
||||||
FP -> K
|
|
||||||
PS -> C
|
|
||||||
NK -> O
|
|
||||||
BB -> V
|
|
||||||
HC -> H
|
|
||||||
FV -> V
|
|
||||||
CH -> N
|
|
||||||
HS -> V
|
|
||||||
CF -> F
|
|
||||||
CN -> S
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
1377191657764644549114627284634913412287739519982496231416283824918194961929936311588211113324916282
|
|
||||||
1212297521448698359953919612341968949351139967911631956522229222119792152999899993551168415419536961
|
|
||||||
6159423311678979112521371444921299897197276181489988271511963872918146853113979656119891919929116284
|
|
||||||
4791323871358399412199298219622788641186798927938163199341117218462279651818983841791285198158689197
|
|
||||||
7974189811899763275179618283116319192597185732127393472591197762491696726534696112661928998124191441
|
|
||||||
1719457851119351145679896476439455919892412234291392849988759922872162286199995759192522267673971911
|
|
||||||
5158991981989914259268282912286934836159941437649989252868156886971224151841291227119542781714229192
|
|
||||||
8971141349643841951211794248819968548427435466191723999244827371882121325261988461388697379557117813
|
|
||||||
6984596925919191179943678951217187999979717952993237915971469193192562968292161332928141319899991618
|
|
||||||
9198522521864259381829335129227674372277199124547185988889492259941882883937916158399823156688865128
|
|
||||||
8124682618753649934148821878377819747891787181829195781346118199594997697952812114668182584998375593
|
|
||||||
9981691284313278913662888992426344931897231669692112847984979448943849148537789387936982196747899979
|
|
||||||
4612594287729384862398119828742189442883965266198489994718698924935284181865741287193312419976111121
|
|
||||||
9698161969149478565386491726144137461938929999938688185784251478539975684351897911814796415999137427
|
|
||||||
4215198687955128645232416239572133179888263876627217299182179119281398198291519743556311698595119447
|
|
||||||
4769546216536687838722946279539949718927689379457711267152121289312649499122925941999769894516538948
|
|
||||||
2995881981397899317151897695171147699149921139717478649199572991745138182938859417981979318636371733
|
|
||||||
5896265687179618976487519127375146169177832848256796867888967833698488841993835411394159986678877843
|
|
||||||
3216645889149389762597933279559298615997238172696673733899239658535753129812911379977549791117989658
|
|
||||||
3884816682163948316281466989293387989351399981758245478789465919897897823972111872243196689493592859
|
|
||||||
2147411131991983852642238326868847926889726486359749798736947597961361232791761388538288138311778889
|
|
||||||
9667691879291819996979958298917569848789574811461556979737155191582528998586729496138919417641516671
|
|
||||||
2985749275368176832969872226792613823962499974291511594718356964791163978998319397955899236233367196
|
|
||||||
9146792975371119515819629946162595322898172566118389981777412389859448518999793848789641614927396527
|
|
||||||
3837698153921119789191289266863437969919159469416859886989979288999338293364182598593531435838918299
|
|
||||||
3116635237718874995349321215895321218981134288293817795799641825791914139998851951282874988993695793
|
|
||||||
7561593471951437617129518549197936965341984929165166946255778981198999251529198369291988622121996798
|
|
||||||
5671179846637276839326113991917774391317631914135868839991981526789969485778186774513984993819918858
|
|
||||||
6829332192876499239259333179131416651652797879989678673653791799313167962195825894623277922675147419
|
|
||||||
2114199213615191896184775491411521611589987859919419942228661718872131759515219245894537581322719999
|
|
||||||
9111987791914149296428193389129811532587733939222947217392149842114232514793791618151173592229671281
|
|
||||||
6995979618889983189931395618837152991881964616562117919875424671693616994916979814989851972258726362
|
|
||||||
8173982492272918487736387139295771914721973489627891148815174139856171119417695981112277482189839214
|
|
||||||
1973523966752994411692968746997296995879577697121374597143849499591366213426378939791149178595161638
|
|
||||||
5585893988624565875416425158849421541992777828132459639548799994998964889296735678462311472353412967
|
|
||||||
7998888978481899581293841169535632193113981375899864159935724481141949931596889935158262842998335918
|
|
||||||
3628289787876715955926724188591588897816776996999489661971733199394273281174961857913237989933989451
|
|
||||||
8999891193589892228558191976973146639339899432418722147824142953482626221311856529949321934951835227
|
|
||||||
3992588951996859132652698919297445999986186384145475156862729991985721181638964313723299881446598791
|
|
||||||
8998893814179771279297296539879723788234226489159913739727989917182438292712863462491283593165387584
|
|
||||||
2225959678947915336339588711833943992739379439179861836978399199426662599832739483128822695786825928
|
|
||||||
4919938138891315978138689416887291774881364839148591162128739219164535299459734549155337432999197911
|
|
||||||
5811216519919174895539797554977936679185698239492921912567121774999488711422544391969771432876537978
|
|
||||||
5239614948192317841478695119921598999373194178187891395921768432788912522293359417821221957119946281
|
|
||||||
1988479858958131921192883481392499559613188252381615491311198981658653691389656839995274969418186999
|
|
||||||
7681966495996941919639623988649188782853795834411334478225123731129587739936417679491619562326995611
|
|
||||||
5163121511288963298982952314191859371657513679589589729491476296199145629795989556991718931869954195
|
|
||||||
5286192694799561972391914255528729388961162579826999991948753996967849341943671642439977232844987241
|
|
||||||
4428178895995144247759399167269333681679595491292381917995999298326832893137644125138231529974592499
|
|
||||||
4818747595975454796832557299789738541316991638259842799695195686599979445783273918859921299915986952
|
|
||||||
9417754891252219525194996254344713299966647874186411227972277894179442589131199217999933824814123221
|
|
||||||
4994994141179221782999435468132963989941331328924377879416667894964349919881719919273389195858632919
|
|
||||||
6976968727729789979799866987389137352126998771769996593346529935239178231461934599332849891191669783
|
|
||||||
3638279769222728924783398321639372424899579939421986797719284324742197761998188819691989998694456134
|
|
||||||
7942399772312398643212169162588662393626113494573293938992496629858316948459199523796897485999921378
|
|
||||||
1618926196928832916821317498771468433845191219257749761298211872798193673922139789349388129994864112
|
|
||||||
2744672662951116969991384387997932899791711411128942949881741539172615486131619958932849888897989682
|
|
||||||
8193685169797222169278874619231971178551717869816119199998223293869323667584378393769322171757659961
|
|
||||||
3567192399993235879219629458779937992841292566997843196897379191646481548121489984711917991295935959
|
|
||||||
9145791161291867819713918855165912963216971699817988984653272136935995972742126586832589192163991927
|
|
||||||
8712419729372896439849678162371923271999124418917611596199166288782836898567935828461556972645691618
|
|
||||||
1974943823672482569954185719922998567599896762236938717767279661182995366114432538799683897379592854
|
|
||||||
9379716279297768319753269447991272919214661239572849997471968329889977329941157596172896596534356541
|
|
||||||
6646625991776574551798145872614721797912217571335478976189691399885799159954742823589679431499683381
|
|
||||||
8989686475467621429635363139819837633819917676359955759915798412948369139162496822357488719729929699
|
|
||||||
9952575399865114983355711819388989998898752988216171812892716892892635288989999528963419618898418969
|
|
||||||
5628277482612799192913177936216253978413218756816239842196325888285889223998597986171699813494975765
|
|
||||||
8787997189686121858117929165777499728392581119799148997676831848921925893394992791762794499675789289
|
|
||||||
7568442691119995411445659817292988957454727197967556114172439626332319694755129914814595388989917393
|
|
||||||
1167946915152153284992129919799398949246947728761958125919513931223797949156627271789872543952184319
|
|
||||||
4333282313991449435292492972979115959364971739574697214551891471125231369421937456949722396783112819
|
|
||||||
7993297562943921256985797994839951414791377275818117983949117165983469235412826115996393789982931376
|
|
||||||
1298945898187917593419458849192816235299119793321858952722674788872499636859117952152983654581115748
|
|
||||||
4878958876835131628931718969837331917173664888187661244567581167587853362752963213489995238858567899
|
|
||||||
9168679699798852526937699621149596872192558861969279971951421899916958917919199222795984799115181512
|
|
||||||
8495992724128927671571265912135878347948681836489591199188311363919513913891778977157177888916936997
|
|
||||||
8999191812299999181826412647458779129464557453899711499291711727199181999313788754481739897894282299
|
|
||||||
2297358211198319622489958131157137589129796865587176999673399971359991483798893432429642581288291194
|
|
||||||
9191151249993972592269748389939197998879479776716874389424892989896918395262244556692919498634767192
|
|
||||||
3146999389982294398923279851895822879874999174675832246619395368959948618376991191857891919997189827
|
|
||||||
9252644326896871318783941879993798291951189674981419995699216498289849253481984958375343761948696962
|
|
||||||
4149366989699391314516198739739998365611211146769689837964632818199827733417982911432639733919961118
|
|
||||||
3785694943346449113313437192173297234317511989486918779179169811959978466519619814382389974795179229
|
|
||||||
8173193661981438212589321931819226834981393943686781771986927128994261912991939615971363661699439979
|
|
||||||
8479197349619477856688178917192741661541913841798699288998264161919784358998345986951361544895722194
|
|
||||||
9387823917552123692884995799334448659591539912212939191659149351819987712961219375817984328598599894
|
|
||||||
7812964315918866599999396818117119925739213839329419979879298266584522638128949596632628794899927594
|
|
||||||
2391843348716127619923835446829918293129713997618113899286695811914941791777191781188282864971628831
|
|
||||||
9869814173464627244763819721441998547833914115357196275866981483721979728829754991183494575248873899
|
|
||||||
3759525119799512972171139432761121922192889938411511154289933278983814729624198361288155121749742596
|
|
||||||
2429134344895591883761666874289213982919652654471211641928968826911633151195891488124183473783171928
|
|
||||||
8886181492349995235524939198716394499923967835658289266169965949434995834857389557293375945691237192
|
|
||||||
2153231111419541496813818582276229211229793882886697591279261494221346473438333716131521195987982819
|
|
||||||
9983399491911518719129352817678695921953245885213828259983567431899628715997395359992977155298181325
|
|
||||||
3474642518564151369499969799513918368919798899185479829989997639246197855513493872738928431872179498
|
|
||||||
2732318412186196256356897928718985284818126794829779199946899179899192919186578957838955489991999919
|
|
||||||
5174898514492714279961793617689337727531149659179437978254251988382912951529715877997391742994559149
|
|
||||||
6441191197877982527547982766164652298155632979453683329949678198587924143899618194194673133812385279
|
|
||||||
9721933192312647794494392675978994249714237519435528899779968981967867171823197399159123171497951794
|
|
||||||
9529734972179199615231232651591988769887899696743322386222999813557814511366456767451396998925196619
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
6051639005B56008C1D9BB3CC9DAD5BE97A4A9104700AE76E672DC95AAE91425EF6AD8BA5591C00F92073004AC0171007E0BC248BE0008645982B1CA680A7A0CC60096802723C94C265E5B9699E7E94D6070C016958F99AC015100760B45884600087C6E88B091C014959C83E740440209FC89C2896A50765A59CE299F3640D300827902547661964D2239180393AF92A8B28F4401BCC8ED52C01591D7E9D2591D7E9D273005A5D127C99802C095B044D5A19A73DC0E9C553004F000DE953588129E372008F2C0169FDB44FA6C9219803E00085C378891F00010E8FF1AE398803D1BE25C743005A6477801F59CC4FA1F3989F420C0149ED9CF006A000084C5386D1F4401F87310E313804D33B4095AFBED32ABF2CA28007DC9D3D713300524BCA940097CA8A4AF9F4C00F9B6D00088654867A7BC8BCA4829402F9D6895B2E4DF7E373189D9BE6BF86B200B7E3C68021331CD4AE6639A974232008E663C3FE00A4E0949124ED69087A848002749002151561F45B3007218C7A8FE600FC228D50B8C01097EEDD7001CF9DE5C0E62DEB089805330ED30CD3C0D3A3F367A40147E8023221F221531C9681100C717002100B36002A19809D15003900892601F950073630024805F400150D400A70028C00F5002C00252600698400A700326C0E44590039687B313BF669F35C9EF974396EF0A647533F2011B340151007637C46860200D43085712A7E4FE60086003E5234B5A56129C91FC93F1802F12EC01292BD754BCED27B92BD754BCED27B100264C4C40109D578CA600AC9AB5802B238E67495391D5CFC402E8B325C1E86F266F250B77ECC600BE006EE00085C7E8DF044001088E31420BCB08A003A72BF87D7A36C994CE76545030047801539F649BF4DEA52CBCA00B4EF3DE9B9CFEE379F14608
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
target area: x=88..125, y=-157..-103
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
[[2,[2,[4,0]]],[6,1]]
|
|
||||||
[[3,[4,[2,4]]],[[6,9],[6,1]]]
|
|
||||||
[7,[8,[8,[0,8]]]]
|
|
||||||
[[[[2,9],5],5],[[[0,1],8],[[7,9],5]]]
|
|
||||||
[[[[3,0],[7,0]],[[9,6],[1,9]]],4]
|
|
||||||
[[[0,[4,8]],8],[[[2,1],9],6]]
|
|
||||||
[[[5,[7,7]],[[9,6],2]],[[[5,8],8],0]]
|
|
||||||
[[0,3],[[8,2],[6,[2,2]]]]
|
|
||||||
[[[9,0],[4,[4,7]]],[7,[[9,1],9]]]
|
|
||||||
[0,[7,[1,1]]]
|
|
||||||
[[[4,[0,1]],[[1,0],8]],[[[3,9],[0,1]],[[9,1],[8,8]]]]
|
|
||||||
[[[6,0],3],2]
|
|
||||||
[[[[4,1],[2,7]],[9,[8,9]]],[[3,0],0]]
|
|
||||||
[[[[2,4],[8,7]],[9,[9,7]]],[[[2,5],6],9]]
|
|
||||||
[[7,6],[[4,[2,4]],[3,8]]]
|
|
||||||
[[7,2],[[8,8],7]]
|
|
||||||
[[[[6,0],4],[[4,7],4]],[[6,[2,7]],[[6,5],3]]]
|
|
||||||
[[[[8,8],[7,6]],4],5]
|
|
||||||
[[0,[[6,9],[7,9]]],[9,5]]
|
|
||||||
[9,[[[0,4],6],[[7,0],0]]]
|
|
||||||
[[[[4,4],0],[3,[3,9]]],[[7,5],[5,[7,2]]]]
|
|
||||||
[[[8,3],[[8,5],[4,4]]],[0,[0,3]]]
|
|
||||||
[[9,[3,[6,7]]],[[7,0],[[9,2],7]]]
|
|
||||||
[[[3,7],[[3,6],9]],7]
|
|
||||||
[[2,[2,[5,7]]],[[[6,4],5],[4,7]]]
|
|
||||||
[[[[9,0],2],[[4,4],6]],[[[3,2],[5,5]],[[5,9],7]]]
|
|
||||||
[[[[2,5],4],[8,5]],6]
|
|
||||||
[[[3,2],[[1,7],5]],[[8,1],[1,[1,2]]]]
|
|
||||||
[8,[[3,[5,4]],5]]
|
|
||||||
[[[2,[5,9]],[1,3]],[[[2,3],[8,3]],[[5,1],[8,9]]]]
|
|
||||||
[[[2,0],[[3,3],[4,7]]],[[[8,7],[7,4]],1]]
|
|
||||||
[[[[7,4],9],[3,[4,1]]],[[[8,4],5],7]]
|
|
||||||
[[[[0,2],9],3],[9,[5,3]]]
|
|
||||||
[3,4]
|
|
||||||
[[[1,[0,2]],[[9,9],[8,2]]],6]
|
|
||||||
[[[[2,9],[3,5]],9],[[9,3],[3,[6,7]]]]
|
|
||||||
[[0,[[4,6],4]],[2,[5,2]]]
|
|
||||||
[9,[[9,[6,8]],8]]
|
|
||||||
[3,[[[1,2],[0,9]],[[4,9],1]]]
|
|
||||||
[[[[8,7],[1,7]],[[2,6],[8,5]]],[3,[[8,0],[6,9]]]]
|
|
||||||
[[8,[[4,9],7]],[3,[9,4]]]
|
|
||||||
[[0,[[3,2],[2,2]]],0]
|
|
||||||
[[[2,7],[[5,7],4]],[[[6,0],[2,1]],[[4,1],[1,6]]]]
|
|
||||||
[[[[9,6],[0,3]],[[0,6],[0,4]]],[[[3,7],[6,7]],7]]
|
|
||||||
[[[[1,1],6],[[5,6],4]],[[5,[0,7]],1]]
|
|
||||||
[[[3,9],[[7,3],[1,5]]],[[[1,2],3],[0,[5,6]]]]
|
|
||||||
[[[[4,4],[0,5]],6],[[7,[2,0]],6]]
|
|
||||||
[[[[2,2],6],9],[[[9,1],2],[[8,6],8]]]
|
|
||||||
[[[[5,0],8],[[5,7],7]],[6,[5,3]]]
|
|
||||||
[[[[8,2],[8,4]],1],[[1,[7,3]],8]]
|
|
||||||
[[[[3,2],2],[[4,9],[5,4]]],[[[9,2],4],[5,[6,0]]]]
|
|
||||||
[[1,[[0,6],0]],[[[1,5],2],[[6,0],[3,7]]]]
|
|
||||||
[4,[7,[6,[3,3]]]]
|
|
||||||
[[[0,[2,5]],2],5]
|
|
||||||
[[[0,[5,7]],9],[[[2,3],[3,4]],[[0,4],9]]]
|
|
||||||
[[3,1],[[[4,1],9],[[0,5],[8,6]]]]
|
|
||||||
[[9,[2,0]],[[0,[1,7]],[9,[6,4]]]]
|
|
||||||
[[[[6,5],5],5],[5,8]]
|
|
||||||
[[[[2,8],[1,3]],[[5,4],2]],[[[0,8],[5,1]],[9,[5,6]]]]
|
|
||||||
[[[[6,9],7],[9,7]],2]
|
|
||||||
[[[[1,7],8],[8,7]],[[[3,5],4],8]]
|
|
||||||
[[[[1,8],[1,0]],0],[[7,1],5]]
|
|
||||||
[[[9,[6,8]],3],[[5,1],[4,[8,2]]]]
|
|
||||||
[[[0,[2,1]],1],[3,[9,[5,5]]]]
|
|
||||||
[[2,5],[2,5]]
|
|
||||||
[[[[1,1],[8,3]],[[1,9],[4,9]]],[[5,[4,8]],[[5,0],0]]]
|
|
||||||
[[[0,7],[[3,4],1]],[[[1,2],[2,9]],[[2,0],9]]]
|
|
||||||
[3,2]
|
|
||||||
[[[9,[8,2]],[7,3]],7]
|
|
||||||
[[[[6,9],9],[3,2]],0]
|
|
||||||
[[3,[[6,1],8]],6]
|
|
||||||
[[[[5,9],9],[[4,4],7]],[7,5]]
|
|
||||||
[1,[[2,8],0]]
|
|
||||||
[[2,[0,6]],[[[3,3],[0,4]],8]]
|
|
||||||
[[[[4,8],9],[0,[3,0]]],[[0,[3,1]],[8,[7,4]]]]
|
|
||||||
[[[6,[8,0]],[0,[8,9]]],[3,8]]
|
|
||||||
[[[[0,8],[9,4]],[1,[2,0]]],1]
|
|
||||||
[[7,6],[[[0,2],9],3]]
|
|
||||||
[[[[1,0],3],2],1]
|
|
||||||
[[[[1,2],8],5],7]
|
|
||||||
[0,[[3,0],7]]
|
|
||||||
[[7,[[0,9],[8,4]]],[[2,0],[[2,8],1]]]
|
|
||||||
[[[1,8],[[8,1],1]],[3,[8,9]]]
|
|
||||||
[4,[[3,7],[[5,2],9]]]
|
|
||||||
[[[[3,8],[2,9]],[3,9]],[[[3,7],[6,9]],[[1,7],2]]]
|
|
||||||
[9,[[[3,7],9],[[4,9],[8,6]]]]
|
|
||||||
[[7,[3,9]],[0,7]]
|
|
||||||
[[[1,6],0],[[7,[8,1]],[6,3]]]
|
|
||||||
[[[[3,9],3],[[2,6],[8,0]]],[[3,3],9]]
|
|
||||||
[[[1,2],[1,6]],[[1,[4,2]],0]]
|
|
||||||
[[[0,[3,0]],2],[[7,[9,4]],[6,8]]]
|
|
||||||
[6,[[[3,1],1],5]]
|
|
||||||
[[[3,4],[[5,9],[1,1]]],[[2,[0,1]],3]]
|
|
||||||
[[2,[[1,5],7]],[0,2]]
|
|
||||||
[[1,[[6,7],7]],4]
|
|
||||||
[6,[5,[[3,2],[6,8]]]]
|
|
||||||
[[[3,9],[[4,0],6]],[8,[3,[5,2]]]]
|
|
||||||
[[5,[[7,3],[2,2]]],[[7,7],7]]
|
|
||||||
[[[1,2],[[2,4],[6,1]]],[[0,[4,2]],[[5,7],[2,3]]]]
|
|
||||||
[[[8,7],8],[[7,[3,6]],[[1,0],4]]]
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,102 +0,0 @@
|
|||||||
#.#.#...###..#.##...######..###..#...#.#.#.##.##.#.#.#..##..#..###...#..#.#.#.#.#....##.##..#....##...#..#.###.###.##...####...##....#..#..#.#.###...#.#..##..#.#.......#...###..####..##..##.##.###..#.#...##...#.###.#..##..####.#.......###...####.#.#....#.#.#.#.##.##.####..#..#..##..#......##.....#..#.#..#..#.##.########.........#.###.#####...##.#...####.#..#.#..#....#.##...##.##.#.##.##......####.###.#..##.#..###.##..###.#.###...######.#######...#..##...#.......###..#.####.#.####.#.#......#.#.#.#...#..###..
|
|
||||||
|
|
||||||
##.##...#..#....##.####.####..##..#..###.#..##.#...##....##.##..#....##.#.#..........##...####.#.#..
|
|
||||||
#.....#.#..##.##..#...#..#...####.##..#....#.##.#...####...##...###.#.####.##.#..#.#.....#..#..#.#.#
|
|
||||||
###.###......#.##...#.##.###.##.#.##..#.#...##.##.#......#...#..####.###.#####.####....#.###.#.#.#.#
|
|
||||||
..##..###..#...##.##.##.....#.###...##.#.##.####.#...#...##.#..##.##..#.....####..#.#.#.....#.#.#.##
|
|
||||||
..##.#..##.##....##.#.#.#######...#...#..#....####......##....#..##.##..#.#.####....#...##...#..#.##
|
|
||||||
###..##.##.#...#.#..##.....#.##.#.#.##.#..#..#.##.#.####.#.....##..#.#..#..##.##.####...####.###..#.
|
|
||||||
..#..#.###.####.#...###.#..###.#.......#.##.##.........###..#.#########.......#####..#######..#..###
|
|
||||||
#####.###..##.###.##.....##......##.##..###.##.#.#.#.#####.......####.#.##.#.####.###.#.###..##.####
|
|
||||||
#...####.##..#.#####.#.###.####.#..#.##..#.##..##..###.#.##.###...#...#.#..#.#.#.###.###.#####.#.#..
|
|
||||||
..#########.##.#.##.#.###..####.##...####.#...#..#.#.#.#.##.....##.#.###.####.....#...####...#####.#
|
|
||||||
....####...###.#..#.####...#....#####.##.##..#...###...##.#######..#.#....#..##.#..#.#.#........#..#
|
|
||||||
..##.#.##.#..#.#..####.#.......#..##...#......#..#.#...##.######.#...#.######.####.###.####.###.#.##
|
|
||||||
...#.###..####...###########.##.#.#.####.##....#..#...###.#.#######..###.#.###.##..#####.#...#.#.##.
|
|
||||||
###..##.#.....##.#...##..#.#...##..#...#..#.##....#.#####.#.##..#...##.....#..#...##.....##.#..##..#
|
|
||||||
..##....#######.##.#..##.#..#..#.#.#....##.####.#..##.#####....##...#..######..####.##.#####....#.##
|
|
||||||
....#.####.###...#..#.#.##.##.#...#.####.#.##...#..##...#####.#.#....#.####.#..#.#.#.#.#..#..##..#.#
|
|
||||||
.###.#.##.#####.##.###...#...##.###......#.#.###.##.###.####..##......#...#####.......######.#.#.##.
|
|
||||||
...#..#..##.#..##.######.....#......#......##..#.##...##.#...#.##########.#.###.####.##..##.......#.
|
|
||||||
.##.....###.####...##.#....##.##.#.#.##..#..##..##...##...#.##..#..#.#.#.###.#..##...##...####.#..##
|
|
||||||
##..#.....##..#####.....#....#..#.#####.#..##.#####.#..##...###.####..##..##...#####.#.....#....#.##
|
|
||||||
...#....####.#.....##.#.#..#..#.#.#.#......#####.#.#.##...#..###.##..#...#.#.###...####.#.##.####.#.
|
|
||||||
.###.#...##.##....##.#####..##.##.#.#.#..#..#.########...#..####.....#####.####.#.....#..#.#.#..##..
|
|
||||||
.#..###...##.##......#.##....#...#...#.##...###...#.#..#..#.##.##...##.#..#.#.#.#.##..#.....###.#.##
|
|
||||||
.#.#...#######..##.##.##......#.#.#..#.#####.#..#.#.##.#...#..#.##.#.###..#.#..###...##.#.#.##..#...
|
|
||||||
.##...#....####.#...##.#....#.....##.#...#.##....#.#..##..###.#.###.#.#.##.##.#.#####.###....##.##.#
|
|
||||||
...##...###.#.#.#....#.##.##.###.#.#..#.##.##....#.#.....#......#...##.##.#....##..#...#....#.#..##.
|
|
||||||
.##..#.#...####.#..####.#.....##.#...#.#...####.......#....#.####.#...#..##..#...##..##.####.#.####.
|
|
||||||
.#...###....#.#...##....##.##.##.##.###.##.##.###...##.##...#.###.##...#...#...#..####.###..#.#..#..
|
|
||||||
.##.#..#..#.#####...#.#.#..##...##.####.......######.#.#.#####....####....##.###.##..#.........#.##.
|
|
||||||
#.###...#.##...###....##.....#...##.#..##.##..##.#...#..#..#.#.###..#.#...#.......#.####..#...###..#
|
|
||||||
#.###...#.####..#.##....##.#########..#......##.###...#.##.###.#.#.#..####......#####.###..#.#....#.
|
|
||||||
#.#.....####.#..###..#.....#....#....#####.#.#...#.##..#####.##..#.#####....####.#..#######.##.#..##
|
|
||||||
##.#..##..##.###...##.###.....#...##....#..#.####.###....##....##.##...###.#.#......####.#..#...####
|
|
||||||
...#####.#.#....#.#..#..#......###.##.##.##.#....#......#..#.#.##..##.#....##.#.#....#.#.#...#####.#
|
|
||||||
#....#.#..#.##..#..#.#.##....#..#.##..#..##.#.###.#.###..##..#..#..###.##.....##.#.#....#####.#..#.#
|
|
||||||
#.#.##.#...#..###.##....#.#...#.#....######....##...#.###..##..#....##.#####..##.#.##.###...##.#.#.#
|
|
||||||
.##..##.##.####..##.#.#..#.#.###..#.#..#.#.##...#####.##.#.....#.....##....###..#.###.##...#...#...#
|
|
||||||
###.#.###..##...####.#.#...#.##..#.##.#..#..########.###.###.#.#.###.####.#.#..#..#...#.###....##...
|
|
||||||
##.##....#....#.##.##.#.#.##.#....##.####.#..##.##.#.##..#.#.##..##.####..#.#.##...#.##...#...#..##.
|
|
||||||
#.##.##..#......##.#.#.#..#...#.##...#.#..###..#.#.#....##.#...#...###.#..#.###..#.######...######..
|
|
||||||
#.#......###.#.#..#.......##.#...###.#..###.#.#.###.#.##.....######.##.#.#...#.####...###.#.....####
|
|
||||||
#######.#.#.##.#.##...#...##..####..#.###....#..#.#...##.#......#..#.........##.#..#.##.#####.#####.
|
|
||||||
##.###....###.###.####.#......#.#.##.###..#####.###...######....#...#...###.#..#..#.###..#..#.###...
|
|
||||||
.#.#...#..###.#.###.#..#.#.#####..#.....####.#..##...####..#..#.#....##.##...####...#..##.##...#####
|
|
||||||
#.###.####.######.....##..##..#.#...#.#####.#..###.#.#.....#.#.#####.....#.#..####..##..####.#.#...#
|
|
||||||
#...###.####.#.....##.#.###.....#..#..#..#.#.....##...#.#.####..#.#.#.#####..#..#.##...#...##....###
|
|
||||||
#.#..#####...####.#.#...#.#####.#..#.###..##......##..#....##...#.####...###.###..#..#..#.#.#####...
|
|
||||||
.##..#.####.###.###..####..###.###.....###..#..##.#..#.###.##..........#.#..#.##..#.###.##...####.#.
|
|
||||||
#.#.##....#..###..##.#..#......#.#.#.#.#####....####.....#.####..###.#.#.#...####.###..#####.....##.
|
|
||||||
##....#...#....###.#.###.#..##...#.#..#..##......#.#.##.##..###...#..##.##...#.##..#.######.#..#.#.#
|
|
||||||
.###..#...###...####..###.#.###.#..####...##.##.#....##.#..#.####....##.####......##.#.#..#..#.#.##.
|
|
||||||
.###..##...##..#.##......#.#..#.#..#.#..##.#######.###..####...###.####.##.###.#####....##..###.##.#
|
|
||||||
##..#.#...#####..##..#.###.#..#..##.#...####....#...##.#.##..#.#..#.##.###.#.######..##.#.#.#..###..
|
|
||||||
..##.##.##......#..#..#.##....##.#.#.###.#..#.#...#.#.#.##.#..##.#.#####.#.#.......#.#....####.#....
|
|
||||||
....##....#######......##.#..#..#..#...##..##..#..##.#.#.#.##...#######.####.#..###..#.####.####....
|
|
||||||
#..##....###.##....##.##.#####.######.######.#.#####.#..#....#....#.##..##..##.#...##..##..#.#.#..##
|
|
||||||
##.##..##.#..#...####.#..##.##...#....#...#.##...#.##..#....##....#..####..##....#..##.####......#.#
|
|
||||||
.#.##....#######.....#.##.##..####.#.#.##...##..#.#..##...#..##...#.##......####...#...#...#...#...#
|
|
||||||
..#..#.###..#.#.##.#.#.#.#...###..#.##.##...#.##.....###.#......####........#####..#....#####...#.#.
|
|
||||||
.###..##..#.##.###.##..###....#.###.#...#.###.####.#..#....##......#.#...#.##...#.##.#.#.####....##.
|
|
||||||
#..###.#..#...###.##.###..########.##..#...#..##.#..##.##.##..#...#.####..###.#.####.###..##..####..
|
|
||||||
...#.###..##..#.##.#.#######.###.##.#.###.###...#..#.##..#######.#.#####....#..##.###.###...##..#.#.
|
|
||||||
####..#.#.######..###...#..#...##.#.#..##.#....##.##.#.#...#....##....####.###.#...#.#...########.#.
|
|
||||||
...#####..#.#.####.#.#.#..##....#######.##..###.###.##...#.#.###...##.####.#..##..#.#..####.#####...
|
|
||||||
..###.##.##.##.###.##.#.#.#.##..##..#.#.#.##..#####.##..##.##.##.#.....#.####.#..##.#.####.#........
|
|
||||||
##.###....###..###..#.#..##..#..###..#.###...#.#.....#.#...#.#..#.#.#....##...#....##.##......#.....
|
|
||||||
.....##.#.####.######..####..#..####.####.#.#.#.#..#..#.#.#.##.#.##...##..#.##.##.#.#..#.####...#...
|
|
||||||
#..##.#..##.#####.#.#..#..#.#.#..##..#..##.#.#..##.#.#.#..####.##.#.###...######...##....###.#.#..##
|
|
||||||
##.#..##.#.#####.##..###.##.##......#####...#.....#..#..#####...#....##.###.....#....###..###.##.#.#
|
|
||||||
.#.###........##..##.####...###.#.####..#.#.....###..#..#..#..###..#.#.#.####..####.##.....##.###.##
|
|
||||||
#..####.#..#.#.##..#.....#.####..#.##.#.#...##...#..#..#.#.#.#...####.###.##....#.####.##..###.#.##.
|
|
||||||
.#...#..#..#####..#....##.#........##..#..#..##.########..#...####.#..#..#..###...##.##...#.........
|
|
||||||
.####....#.#.#.#..#.#..#.######...#..##.......#..#.##....#.#.#.###.#.##.###..#.#..##.####.#...#..#..
|
|
||||||
...#.######.###.#.##.#.######.##..##.......#..#.###..#####..#.###..##.##...###...#..#.#..##...#.#..#
|
|
||||||
#....##.#.#...#.#.##.##.#####.....##..#..##.##...#..#####.#.###...#######...#...#..##.#.###.......##
|
|
||||||
#.###......#.##.##.#..######.#.##...#.##...#.###...##...#..##....#..###.#.###.#..##..####.##.##.....
|
|
||||||
..#.#...#.#.####..#.#.#...#..##..##.....#..#..##.#...###....#.#.####...#.##....##...#..#####....##..
|
|
||||||
####.##...###...#..#.###.#..#.#......##...####.#####..##...##.###.##.##.##..#####.#.###....#...###.#
|
|
||||||
#.#...###.....#.....#.#.....####.##.#..#..#.#.#.#..###.##...#.#..##.#..##.###.#.#.###....#####.##...
|
|
||||||
...##.#.####.##..###..###.#...##..##.#.#.#.##.#.##.#.##.#....#...##...####.###..#.##..#..##..##.##.#
|
|
||||||
###...#...#..#..#..##..#.#..##...#..###....#..#.##.###..#####.#..###..#......##.####..#.#.#....#####
|
|
||||||
#.#..#.####.##..#......###..#.###....#.#....#..#..#.#.#.....#.##...#..##...##..#..##..#...####...#..
|
|
||||||
.#.....#.###..##.#.##..##.##..#..#.#..##.#......#.#.#....#####.####....###..###.###...####.#.....###
|
|
||||||
..##.##...##.#.##.#....##.#.#.....########.##########........#.###..#..#.#.....#.###..#.#.###.###.#.
|
|
||||||
####.#..##.#..##..#####.#.....###....#.#..#.#..##..#..#....#..####.#.....#..##.#..#.#.###.#.#.##.##.
|
|
||||||
.##.##....##..#..#.#....###....#.#...##..#..#..##.#..##..##.#..######.#.##..##.#.######..#.#.###..##
|
|
||||||
###..#..#####.#....#..###.###.##.##..####..#.#....##........#.##..#####...######.##.#...#.#####...#.
|
|
||||||
.#.#..##.......#..##....#...#.########.#...###.##.#.##.##.##.#.#.#....###..###..#...#...#.#.###...##
|
|
||||||
.##..######.#.#..#......#...##....#.###.#.##..#.....#...#.##.#..#.#.#..#####.#####.##......##..#.##.
|
|
||||||
##.#.###....###.##..#.#..####.......######.#...###.#.#.##.#.....####....#......##...###.##.#.#####..
|
|
||||||
#.###.#.##.##..##..#..#..##...##.#..###.#.#.....####..####..#...#.#.##.###.#..#..#.##...#..##.#.###.
|
|
||||||
..##.##....##...###..#######..#...##....###.#..###..###....###..##....##.#..##..##..##.#.###.#.#..##
|
|
||||||
..#.#..#.####.#.#.#..###.###.........#.#.####.##.#.##....##..#.#.#...#.###.#.##.##.#....#.#.#.#..#..
|
|
||||||
...##....###.##.##.##.##...#.##.....#.###..##....#..#.##...#..#..##..#...#..###.##.##..#.#.#######..
|
|
||||||
..#.#.#..##.#.#..##.##.##..#...#.##.#..#.#..####..##....#.#.#....###...#..##...##.#..##.##....##...#
|
|
||||||
...###.########....##...##..#.####..#######.#..####...###......##....#..#....###..###..#...####.##..
|
|
||||||
.##..###.....#.###.....##.###.####.######.##.#..#.#.###.###.#.#...#.##..#..###.#.#....##.#####....#.
|
|
||||||
###..##.####.##.####.#.##.#...#.##.#..##.###.#.###..########.#.#..#.###...##.###.....#..#####.#..##.
|
|
||||||
...##.##.###..#.#####..#.#.#.#..#..#...#...##.....#.##...###.#.#.####...#.....####.##.####...#..###.
|
|
||||||
#.###..###..###..####..#..##..#########..#...##..#........#..#..#####.###..###..#...#..#..###.#.##..
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
Player 1 starting position: 4
|
|
||||||
Player 2 starting position: 5
|
|
||||||
@@ -1,420 +0,0 @@
|
|||||||
on x=-46..2,y=-26..20,z=-39..5
|
|
||||||
on x=0..44,y=-44..0,z=-19..32
|
|
||||||
on x=-44..10,y=-20..28,z=4..48
|
|
||||||
on x=-12..39,y=-35..9,z=-12..36
|
|
||||||
on x=-20..31,y=-15..36,z=-44..2
|
|
||||||
on x=-18..36,y=-43..8,z=-12..41
|
|
||||||
on x=-24..27,y=-5..39,z=-30..24
|
|
||||||
on x=-40..4,y=-20..28,z=-33..14
|
|
||||||
on x=-16..30,y=-16..31,z=-12..32
|
|
||||||
on x=-3..48,y=-27..18,z=-5..39
|
|
||||||
off x=-37..-22,y=24..41,z=20..38
|
|
||||||
on x=-33..16,y=2..49,z=-46..4
|
|
||||||
off x=-9..2,y=29..41,z=-45..-32
|
|
||||||
on x=-7..44,y=-27..22,z=-40..6
|
|
||||||
off x=-43..-30,y=17..27,z=-43..-34
|
|
||||||
on x=-13..35,y=-19..25,z=-45..2
|
|
||||||
off x=31..45,y=36..49,z=12..28
|
|
||||||
on x=-16..33,y=-20..27,z=-34..16
|
|
||||||
off x=-43..-30,y=-1..17,z=2..13
|
|
||||||
on x=-7..47,y=-8..39,z=-2..44
|
|
||||||
on x=-51481..-16686,y=-55882..-41735,z=31858..57273
|
|
||||||
on x=62605..83371,y=-20326..7404,z=721..31101
|
|
||||||
on x=52622..66892,y=-53993..-42390,z=-32377..-15062
|
|
||||||
on x=32723..65065,y=-77593..-55363,z=-14922..15024
|
|
||||||
on x=-19522..-12277,y=-93093..-59799,z=23811..37917
|
|
||||||
on x=71595..92156,y=-44022..-19835,z=16005..34327
|
|
||||||
on x=-3586..34080,y=2703..21691,z=-92268..-61619
|
|
||||||
on x=-15386..715,y=73535..97744,z=-8553..16939
|
|
||||||
on x=-36770..-25752,y=71882..77753,z=-22483..5934
|
|
||||||
on x=-87151..-59512,y=-52304..-38677,z=-6844..14195
|
|
||||||
on x=-49843..-11520,y=-59097..-36023,z=-68112..-44642
|
|
||||||
on x=-54750..-35235,y=-65545..-48408,z=8090..44796
|
|
||||||
on x=-94375..-72818,y=9788..29493,z=-9581..832
|
|
||||||
on x=7678..15728,y=-72950..-37506,z=43639..74189
|
|
||||||
on x=-2150..1370,y=-47547..-22907,z=67903..86640
|
|
||||||
on x=30996..54239,y=58993..70521,z=10200..33219
|
|
||||||
on x=11010..19912,y=-82111..-52326,z=-59754..-28912
|
|
||||||
on x=21482..32440,y=-86476..-62698,z=14238..24595
|
|
||||||
on x=75846..79807,y=-34167..-20170,z=-5351..13100
|
|
||||||
on x=-57020..-37686,y=43544..67110,z=-37496..-30899
|
|
||||||
on x=14662..49584,y=-58025..-40735,z=-47292..-41465
|
|
||||||
on x=-63346..-55137,y=21250..38290,z=33568..51615
|
|
||||||
on x=-85269..-67041,y=-25194..571,z=-52696..-14325
|
|
||||||
on x=-54438..-31138,y=-25222..3408,z=-74478..-51576
|
|
||||||
on x=-55260..-36337,y=-36146..-21397,z=52332..57160
|
|
||||||
on x=-65984..-51756,y=-1513..8161,z=46328..64968
|
|
||||||
on x=28910..41579,y=-63016..-52977,z=-61128..-33613
|
|
||||||
on x=-46241..-27998,y=52847..77588,z=6053..16826
|
|
||||||
on x=-58382..-31024,y=-25378..11770,z=62336..77861
|
|
||||||
on x=14836..43351,y=43097..66395,z=26797..52340
|
|
||||||
on x=-2107..15942,y=-94637..-77185,z=-12264..-1486
|
|
||||||
on x=52176..62331,y=-18190..8633,z=40476..60619
|
|
||||||
on x=57517..70517,y=-13924..4531,z=46436..67802
|
|
||||||
on x=-21645..-1991,y=-50529..-11513,z=59680..91420
|
|
||||||
on x=-60101..-36307,y=11413..32936,z=-79198..-42467
|
|
||||||
on x=-27245..-11982,y=12680..44262,z=61571..82539
|
|
||||||
on x=62043..80570,y=-16742..15490,z=41267..54928
|
|
||||||
on x=-48117..-37581,y=34828..44610,z=-59598..-49709
|
|
||||||
on x=59522..87726,y=-16741..-1638,z=-37838..-7715
|
|
||||||
on x=-40860..-21613,y=-63238..-50545,z=38865..68651
|
|
||||||
on x=-53664..-45002,y=43993..64127,z=-50526..-32706
|
|
||||||
on x=-71250..-45260,y=-45511..-32954,z=23030..44098
|
|
||||||
on x=-50714..-25029,y=10683..33392,z=58357..85044
|
|
||||||
on x=40647..68356,y=40530..46549,z=21996..38584
|
|
||||||
on x=-63640..-36211,y=46146..49642,z=-56306..-41971
|
|
||||||
on x=21790..44008,y=-41519..-38626,z=46575..60879
|
|
||||||
on x=29993..40615,y=-74802..-65958,z=-10835..3294
|
|
||||||
on x=63509..72412,y=33988..60123,z=17699..27626
|
|
||||||
on x=-75402..-51635,y=-41551..-19817,z=-28290..-15067
|
|
||||||
on x=-24611..-7664,y=-76920..-49198,z=-69901..-36628
|
|
||||||
on x=-55000..-37217,y=-65084..-44457,z=33862..49998
|
|
||||||
on x=-83578..-56334,y=3079..36144,z=30213..52349
|
|
||||||
on x=-78623..-56475,y=45055..61546,z=-7798..15403
|
|
||||||
on x=31042..53339,y=-48138..-27455,z=-74296..-40132
|
|
||||||
on x=-16338..3820,y=-85143..-57755,z=-35857..-14502
|
|
||||||
on x=1..30237,y=63222..92071,z=14406..27979
|
|
||||||
on x=-50768..-29497,y=-62276..-42537,z=31270..66285
|
|
||||||
on x=14750..33888,y=25707..41545,z=60136..71374
|
|
||||||
on x=-73804..-51260,y=34623..68995,z=11793..27887
|
|
||||||
on x=-22099..3107,y=29817..55030,z=-86473..-71182
|
|
||||||
on x=44846..63690,y=-39204..-30200,z=-70048..-31226
|
|
||||||
on x=12735..25519,y=-50839..-27301,z=-85035..-52999
|
|
||||||
on x=-79843..-67300,y=6320..19153,z=-16078..5129
|
|
||||||
on x=-25488..3381,y=-81495..-59824,z=-51236..-39103
|
|
||||||
on x=29516..52668,y=-91122..-64377,z=-7299..8614
|
|
||||||
on x=-45309..-34530,y=59207..85364,z=-5722..17346
|
|
||||||
on x=-75869..-48145,y=-36278..-31560,z=-48241..-14556
|
|
||||||
on x=5416..33979,y=71734..85654,z=-6354..17686
|
|
||||||
on x=-38328..-6825,y=33508..60073,z=-73314..-49127
|
|
||||||
on x=-16455..5840,y=-90011..-56004,z=12046..34429
|
|
||||||
on x=19942..40435,y=-38063..-14227,z=-72406..-60179
|
|
||||||
on x=-71208..-36468,y=-51769..-39093,z=-39553..-32066
|
|
||||||
on x=-30611..-15238,y=-74996..-51621,z=41626..60792
|
|
||||||
on x=-26266..-6821,y=-76803..-54508,z=26326..49720
|
|
||||||
on x=5554..23770,y=60181..92306,z=-3903..22337
|
|
||||||
on x=35188..60913,y=405..13616,z=-68688..-53839
|
|
||||||
on x=-84198..-52574,y=-51383..-21298,z=959..28430
|
|
||||||
on x=-32433..-12722,y=-58750..-50875,z=33399..60295
|
|
||||||
on x=-42283..-20916,y=60934..71844,z=-48024..-17122
|
|
||||||
on x=45510..69038,y=-22876..-7766,z=41312..55989
|
|
||||||
on x=4077..26087,y=-87438..-67786,z=-6454..9574
|
|
||||||
on x=60630..91396,y=2047..28989,z=8771..31412
|
|
||||||
on x=-14685..3138,y=34908..62560,z=-66694..-42144
|
|
||||||
on x=44452..66566,y=-63825..-31278,z=-33877..-24172
|
|
||||||
on x=36589..53960,y=43341..55297,z=16299..30540
|
|
||||||
on x=-50464..-33544,y=745..34345,z=-72288..-52398
|
|
||||||
on x=21307..54983,y=-62869..-43283,z=41406..72552
|
|
||||||
on x=44587..71433,y=1841..17317,z=-57698..-42925
|
|
||||||
on x=58150..68363,y=28852..55677,z=17960..29455
|
|
||||||
on x=-7196..19282,y=-89129..-71321,z=13723..41169
|
|
||||||
on x=-68501..-46903,y=-26290..-15637,z=35391..42746
|
|
||||||
on x=3892..29864,y=64133..84173,z=-8782..5299
|
|
||||||
on x=-43516..-30450,y=26793..49391,z=53089..61207
|
|
||||||
on x=-53171..-30883,y=-48101..-43726,z=44797..67740
|
|
||||||
on x=68286..92818,y=-9936..15488,z=-6245..6271
|
|
||||||
on x=-69288..-35805,y=-18686..12501,z=-63926..-46763
|
|
||||||
on x=-13676..10358,y=29729..48962,z=-82290..-61499
|
|
||||||
on x=-91342..-58913,y=5804..18438,z=-10738..20089
|
|
||||||
on x=-2086..15635,y=62442..80850,z=11045..35648
|
|
||||||
on x=-75732..-51506,y=-5835..28683,z=-57038..-22560
|
|
||||||
on x=33708..52638,y=40215..48167,z=-64930..-42437
|
|
||||||
on x=42559..66539,y=-46203..-29630,z=38529..49019
|
|
||||||
on x=-49526..-43357,y=-61139..-43371,z=-59437..-20443
|
|
||||||
on x=8103..28088,y=66204..85143,z=-25951..-13527
|
|
||||||
on x=-72345..-62556,y=-63706..-38173,z=-17152..-1145
|
|
||||||
on x=54774..91997,y=-37670..-12831,z=-30161..-17865
|
|
||||||
on x=6148..25487,y=46052..71759,z=33247..65381
|
|
||||||
on x=-57328..-49224,y=26458..36097,z=45759..52150
|
|
||||||
on x=-39304..-28724,y=-39127..-23995,z=50978..73051
|
|
||||||
on x=-64985..-61846,y=31392..53299,z=25687..50050
|
|
||||||
on x=63677..86665,y=21170..35031,z=-17997..-9002
|
|
||||||
on x=-2035..9063,y=-91127..-59256,z=-41298..-26586
|
|
||||||
on x=-42966..-13481,y=-63752..-52787,z=39934..42013
|
|
||||||
on x=-4052..16276,y=4300..33419,z=-97023..-69495
|
|
||||||
on x=28754..55492,y=-63861..-30281,z=-57610..-42673
|
|
||||||
on x=-75541..-66845,y=-16327..9136,z=-47999..-37146
|
|
||||||
on x=-95243..-67165,y=8035..18049,z=-8895..24816
|
|
||||||
on x=-67563..-50842,y=-47960..-21085,z=-60573..-40893
|
|
||||||
on x=-41648..-12477,y=-20284..2911,z=-81827..-69369
|
|
||||||
on x=-28144..-17284,y=-34620..-6183,z=-89244..-54720
|
|
||||||
on x=65922..92404,y=-1466..6914,z=16157..39291
|
|
||||||
on x=14668..24690,y=-77921..-61312,z=-30488..-1115
|
|
||||||
on x=36923..56302,y=46079..74765,z=-15871..4979
|
|
||||||
on x=-46591..-23525,y=-76935..-44182,z=-43573..-20271
|
|
||||||
on x=29721..45936,y=6887..30073,z=59075..67521
|
|
||||||
on x=-890..30663,y=23754..47276,z=-82425..-63230
|
|
||||||
on x=4752..19784,y=-83727..-61899,z=33506..54760
|
|
||||||
on x=-94526..-71296,y=-14265..-4610,z=11418..33014
|
|
||||||
on x=58300..97221,y=-16175..4231,z=-21919..-2358
|
|
||||||
on x=-57482..-45486,y=-67406..-47228,z=20248..37478
|
|
||||||
on x=31402..48989,y=-62481..-50137,z=22060..47161
|
|
||||||
on x=40599..50616,y=10759..15911,z=46121..76734
|
|
||||||
on x=48057..61128,y=35427..62674,z=-21549..-9614
|
|
||||||
on x=-28135..-20962,y=59633..89312,z=-13540..5340
|
|
||||||
on x=47549..71482,y=17382..53520,z=17716..45082
|
|
||||||
on x=78070..81154,y=-13655..13343,z=-168..16596
|
|
||||||
on x=20673..45758,y=65526..76695,z=-13497..-36
|
|
||||||
on x=-4786..2818,y=-4837..5549,z=-93451..-76191
|
|
||||||
on x=14302..49076,y=61818..81437,z=-14176..9531
|
|
||||||
on x=-68602..-53393,y=16455..38152,z=25132..43913
|
|
||||||
on x=-24130..-13936,y=-7644..-4498,z=-85828..-59036
|
|
||||||
on x=-11717..16687,y=10353..30087,z=-80942..-58069
|
|
||||||
on x=12682..32617,y=58507..76138,z=20849..32759
|
|
||||||
on x=49088..65243,y=53393..74520,z=-14943..321
|
|
||||||
on x=-63756..-46629,y=-69037..-41666,z=-15234..-9712
|
|
||||||
on x=44240..46104,y=1468..21751,z=46542..79291
|
|
||||||
on x=-80700..-60977,y=24543..33596,z=-6372..11056
|
|
||||||
on x=-72072..-64358,y=-6985..13991,z=-65594..-35346
|
|
||||||
on x=-54425..-32669,y=-51345..-34855,z=29309..52921
|
|
||||||
on x=57189..87162,y=14470..19132,z=-51139..-22474
|
|
||||||
on x=76017..80222,y=-8175..18033,z=4083..27696
|
|
||||||
on x=-42368..-31460,y=-50798..-22007,z=-66532..-47444
|
|
||||||
on x=9223..15360,y=-54293..-43392,z=43665..64825
|
|
||||||
on x=-50450..-28738,y=-67485..-46021,z=25963..50292
|
|
||||||
on x=49773..57601,y=40208..61258,z=10697..36254
|
|
||||||
on x=-87157..-62119,y=-46554..-23602,z=-33740..-21462
|
|
||||||
on x=24144..48485,y=30406..55581,z=-63251..-41224
|
|
||||||
on x=-57059..-28465,y=36514..59020,z=-62118..-39872
|
|
||||||
on x=51418..73395,y=-33294..-7934,z=-55359..-46837
|
|
||||||
on x=35051..53350,y=48381..69938,z=30992..50675
|
|
||||||
on x=-49838..-13680,y=52337..71756,z=19703..47005
|
|
||||||
on x=-37895..-13199,y=17817..26885,z=-85792..-66246
|
|
||||||
on x=25443..49007,y=55523..83334,z=-38543..-8471
|
|
||||||
on x=-83264..-53691,y=-50838..-28415,z=-45433..-11937
|
|
||||||
on x=18129..44224,y=56025..71419,z=25496..28014
|
|
||||||
on x=64401..91096,y=-9626..9767,z=-19328..-16234
|
|
||||||
on x=40564..60820,y=21806..27545,z=-63583..-55689
|
|
||||||
on x=59287..82435,y=-49803..-36598,z=-19736..10678
|
|
||||||
on x=-61406..-31848,y=29090..48153,z=49953..68273
|
|
||||||
on x=-80129..-63495,y=32758..49898,z=15420..28891
|
|
||||||
on x=-71918..-59088,y=-8042..4070,z=-61979..-32744
|
|
||||||
on x=18507..32332,y=37492..69230,z=-61212..-48361
|
|
||||||
on x=18232..24748,y=-47573..-19392,z=-77084..-69812
|
|
||||||
on x=3538..29122,y=49351..68476,z=-77426..-58306
|
|
||||||
on x=14899..28875,y=33798..52962,z=-74740..-47031
|
|
||||||
on x=-33805..-9226,y=-4797..32978,z=-87103..-57644
|
|
||||||
on x=64283..84636,y=22189..47622,z=952..13372
|
|
||||||
on x=48891..68906,y=11825..36343,z=34507..53080
|
|
||||||
on x=8785..32809,y=-61933..-45683,z=42536..64070
|
|
||||||
on x=-23386..12584,y=60365..94330,z=-35407..-19640
|
|
||||||
on x=-69295..-63793,y=39194..55998,z=-29323..2775
|
|
||||||
on x=-69311..-40624,y=-11655..12445,z=52893..65442
|
|
||||||
on x=63480..66888,y=13195..36768,z=-40754..-23113
|
|
||||||
on x=-71702..-44882,y=-34923..3115,z=36891..68959
|
|
||||||
on x=1227..20599,y=3304..38907,z=-87371..-69194
|
|
||||||
on x=-38051..-5608,y=66679..76678,z=-22327..-17200
|
|
||||||
on x=-71086..-50108,y=-43265..-21453,z=45617..65108
|
|
||||||
on x=-75499..-48938,y=-22961..2638,z=-62154..-39253
|
|
||||||
on x=-58844..-35498,y=-73497..-60885,z=-3349..4528
|
|
||||||
on x=-80442..-65527,y=-51151..-25462,z=14193..28272
|
|
||||||
on x=-36446..-15525,y=2899..19438,z=54499..93589
|
|
||||||
on x=21122..41146,y=-34781..-12126,z=-81333..-47863
|
|
||||||
on x=40057..68736,y=12318..42116,z=-62457..-51443
|
|
||||||
on x=14076..29019,y=44823..82163,z=29271..59964
|
|
||||||
on x=-49251..-25009,y=47681..66203,z=-41367..-27670
|
|
||||||
on x=-62329..-39224,y=-34111..-4674,z=-65314..-57930
|
|
||||||
on x=-61408..-31233,y=22748..44986,z=41804..72595
|
|
||||||
on x=-21267..231,y=-85144..-60581,z=-14979..-6323
|
|
||||||
on x=-74958..-66383,y=-16735..2794,z=34735..59977
|
|
||||||
on x=-23282..-12409,y=69175..83534,z=313..21732
|
|
||||||
off x=59267..85411,y=514..23328,z=-4846..14301
|
|
||||||
on x=-17178..9607,y=-64979..-33229,z=57298..68101
|
|
||||||
on x=-7419..15896,y=-89840..-63418,z=-31002..-8653
|
|
||||||
off x=-73365..-57136,y=7908..35149,z=-59465..-32345
|
|
||||||
on x=63815..89172,y=6116..28592,z=11336..49089
|
|
||||||
on x=13237..36417,y=-44604..-18476,z=58867..71392
|
|
||||||
on x=-31835..-2018,y=48122..51530,z=-79384..-51387
|
|
||||||
on x=-93617..-71409,y=-6592..18534,z=-3366..22689
|
|
||||||
off x=29296..37825,y=29193..53548,z=-76978..-56558
|
|
||||||
on x=10940..21199,y=-70736..-49011,z=23206..53098
|
|
||||||
off x=46366..51784,y=-73666..-55961,z=-12714..5969
|
|
||||||
on x=-54335..-22852,y=-7983..25369,z=-79636..-67406
|
|
||||||
off x=-24260..2762,y=-64478..-41674,z=-64474..-45494
|
|
||||||
on x=22187..41667,y=15612..28847,z=58068..87450
|
|
||||||
on x=63150..83396,y=1346..33053,z=27298..45814
|
|
||||||
off x=59837..81917,y=-17191..8875,z=5474..24724
|
|
||||||
off x=19093..34648,y=-93372..-66153,z=-2175..27526
|
|
||||||
off x=30666..50683,y=52749..78100,z=-17491..10648
|
|
||||||
on x=26870..45665,y=56112..77327,z=-43808..-31865
|
|
||||||
off x=11864..18598,y=-1684..25669,z=-97875..-71735
|
|
||||||
on x=53157..75832,y=-29574..-16764,z=12318..43107
|
|
||||||
on x=43719..77079,y=-55045..-20872,z=15413..38119
|
|
||||||
off x=14623..37763,y=-89983..-54806,z=13234..35206
|
|
||||||
off x=-20732..-6457,y=4017..28816,z=71076..89286
|
|
||||||
on x=-20590..-14094,y=50358..65175,z=47899..66858
|
|
||||||
on x=62320..69077,y=23748..44841,z=-7970..22293
|
|
||||||
off x=21884..39495,y=67007..78871,z=-6077..14897
|
|
||||||
off x=62186..75230,y=-50181..-16289,z=-14388..7026
|
|
||||||
off x=-38405..-22937,y=-5429..28417,z=55944..88446
|
|
||||||
on x=662..26305,y=-87554..-58836,z=-17299..2266
|
|
||||||
on x=72718..77163,y=-1163..18561,z=-44259..-28618
|
|
||||||
off x=22260..41297,y=-44311..-19228,z=47468..84313
|
|
||||||
off x=-40602..-18738,y=-34574..-133,z=64944..85128
|
|
||||||
on x=-29694..-18496,y=54923..65374,z=38879..55584
|
|
||||||
off x=72863..81078,y=-14522..-3236,z=-33189..-20138
|
|
||||||
off x=-42230..-18771,y=69691..87669,z=14085..23774
|
|
||||||
off x=-9126..9929,y=68147..99240,z=-12694..-3519
|
|
||||||
off x=-26468..-7104,y=64299..76065,z=-36099..-15599
|
|
||||||
on x=67973..84722,y=-21303..7452,z=-18666..2678
|
|
||||||
on x=4102..21407,y=15532..19634,z=58771..86790
|
|
||||||
on x=37549..65086,y=-7487..-2758,z=55748..74491
|
|
||||||
on x=-14811..4584,y=-74652..-68275,z=-38615..-8763
|
|
||||||
off x=37106..50803,y=-53386..-44103,z=-58613..-40526
|
|
||||||
off x=-74450..-40998,y=43771..58392,z=1444..19278
|
|
||||||
on x=-50536..-28522,y=310..5308,z=58703..88882
|
|
||||||
on x=-20939..3950,y=-19820..-18182,z=-93492..-57274
|
|
||||||
off x=-73988..-70744,y=-53683..-27500,z=2877..9737
|
|
||||||
on x=-7526..22863,y=-8072..17539,z=73403..87835
|
|
||||||
off x=-48736..-25834,y=-83795..-55637,z=-14055..-1592
|
|
||||||
on x=46004..70445,y=11832..29476,z=43772..50920
|
|
||||||
off x=62244..84049,y=13880..25447,z=33699..42878
|
|
||||||
off x=-65300..-54528,y=47126..50687,z=7884..28591
|
|
||||||
on x=-55956..-47412,y=-68950..-31938,z=-33567..-21955
|
|
||||||
off x=27523..54204,y=53311..66537,z=-41809..-5196
|
|
||||||
on x=-95373..-75620,y=-27024..1838,z=3422..7457
|
|
||||||
off x=-41424..-13493,y=-93359..-55448,z=-26642..-13733
|
|
||||||
off x=45093..70424,y=51183..64547,z=-28549..-12261
|
|
||||||
off x=32082..52590,y=-68034..-42190,z=24265..40002
|
|
||||||
off x=-83441..-70495,y=2611..23905,z=-3669..20088
|
|
||||||
off x=-5850..22395,y=11248..36413,z=-78880..-56272
|
|
||||||
on x=78982..83822,y=-14121..143,z=-15875..5994
|
|
||||||
off x=39610..65471,y=39412..61214,z=17938..53604
|
|
||||||
on x=-73170..-48249,y=-48894..-33070,z=26483..60838
|
|
||||||
on x=-68144..-52978,y=-23980..-6621,z=-59936..-34090
|
|
||||||
on x=41115..53204,y=26168..46031,z=-63732..-34602
|
|
||||||
off x=-47255..-20253,y=5004..35879,z=49163..83111
|
|
||||||
off x=-63225..-49222,y=-62533..-36601,z=-935..13732
|
|
||||||
off x=-53817..-39048,y=-81526..-62330,z=-25691..-2500
|
|
||||||
off x=-76260..-62299,y=-29061..-19304,z=39220..48501
|
|
||||||
off x=-80241..-49003,y=-52126..-30868,z=-9247..6617
|
|
||||||
off x=6227..11948,y=-32268..-17660,z=-85825..-59021
|
|
||||||
on x=-36533..-26269,y=-79451..-60932,z=1614..7881
|
|
||||||
on x=589..25506,y=-12202..3560,z=-85890..-74851
|
|
||||||
on x=5360..19575,y=-62141..-51745,z=45034..63905
|
|
||||||
off x=-39349..-23146,y=23975..44390,z=48709..77537
|
|
||||||
on x=28342..46781,y=-29976..-8233,z=57734..69595
|
|
||||||
off x=-77303..-50182,y=8314..15684,z=-60271..-36934
|
|
||||||
on x=15565..23346,y=-24515..5163,z=-77856..-68954
|
|
||||||
on x=-38928..-18718,y=-26186..-6428,z=63840..76872
|
|
||||||
off x=9997..35709,y=-60625..-56365,z=-68727..-47677
|
|
||||||
on x=-6312..17890,y=-10921..5064,z=-91584..-67839
|
|
||||||
off x=12562..23601,y=-59006..-25156,z=-67383..-62614
|
|
||||||
off x=56511..85396,y=-9472..21355,z=-49007..-13930
|
|
||||||
on x=48654..68194,y=2363..22687,z=-54149..-39844
|
|
||||||
on x=-70180..-49056,y=-43968..-29640,z=21331..49497
|
|
||||||
on x=375..26280,y=53582..64641,z=45975..73486
|
|
||||||
off x=-50286..-39551,y=-69893..-49626,z=18452..52094
|
|
||||||
off x=-55882..-33331,y=344..18448,z=-80801..-51551
|
|
||||||
off x=57268..84471,y=-48138..-39865,z=-23525..6531
|
|
||||||
off x=-5837..2735,y=-73830..-52479,z=41854..58096
|
|
||||||
on x=-27554..-4489,y=53367..83205,z=31562..49332
|
|
||||||
off x=-20742..5467,y=-65244..-27510,z=53341..76842
|
|
||||||
off x=17914..42871,y=-53623..-33086,z=-77085..-47173
|
|
||||||
off x=36492..49968,y=35632..41326,z=-74714..-40178
|
|
||||||
off x=12446..45639,y=61743..75034,z=-40513..-27030
|
|
||||||
off x=16145..43992,y=-26882..-8326,z=-82954..-59935
|
|
||||||
on x=-23775..-7690,y=45368..50716,z=-64252..-49534
|
|
||||||
off x=-78791..-60343,y=11003..36392,z=-58207..-42229
|
|
||||||
on x=50675..70130,y=-21834..11787,z=34188..56587
|
|
||||||
on x=-34986..-11593,y=71125..86822,z=-11765..10487
|
|
||||||
off x=26121..54204,y=57376..70480,z=-44536..-14084
|
|
||||||
off x=47869..65894,y=33992..53419,z=-56863..-28538
|
|
||||||
off x=-24334..-8612,y=28640..61652,z=-78408..-43374
|
|
||||||
on x=27154..47449,y=43628..62103,z=-48166..-37361
|
|
||||||
on x=15338..32128,y=66233..90008,z=15361..36731
|
|
||||||
on x=-48061..-32730,y=7101..33292,z=51441..75575
|
|
||||||
off x=29688..55006,y=53948..61368,z=31296..38879
|
|
||||||
off x=59479..82841,y=27639..46701,z=-27632..-16641
|
|
||||||
on x=33822..55847,y=-60451..-48526,z=19976..54898
|
|
||||||
on x=-46685..-18938,y=-76878..-56088,z=23616..39907
|
|
||||||
off x=-74144..-59325,y=11439..22058,z=-39530..-17804
|
|
||||||
on x=60278..85196,y=-53386..-26378,z=-7422..6296
|
|
||||||
on x=11602..38478,y=47634..59849,z=-60457..-41436
|
|
||||||
on x=-67981..-51375,y=-43182..-28399,z=-30170..-5548
|
|
||||||
off x=-39484..-26626,y=46563..57448,z=-70491..-43484
|
|
||||||
on x=-11575..6240,y=-44470..-23882,z=-80590..-52319
|
|
||||||
off x=34368..38954,y=-77664..-45070,z=23154..37589
|
|
||||||
on x=23476..25973,y=-81946..-53549,z=19755..36372
|
|
||||||
on x=-70072..-56024,y=-42751..-25176,z=4968..16718
|
|
||||||
on x=44401..55480,y=-10001..5439,z=60788..71332
|
|
||||||
on x=-80447..-65355,y=24494..41918,z=-48047..-24893
|
|
||||||
on x=-25175..-5264,y=59599..83851,z=-43682..-19535
|
|
||||||
off x=-16008..-9052,y=68012..88912,z=-30931..-23360
|
|
||||||
on x=3262..31382,y=-59562..-48713,z=-65187..-50358
|
|
||||||
on x=-38630..-14647,y=-67513..-61283,z=21962..51871
|
|
||||||
off x=-37398..-18396,y=-36946..-24449,z=67584..85395
|
|
||||||
on x=-83796..-70334,y=-1617..3346,z=-42353..-5422
|
|
||||||
on x=71118..72869,y=-13101..1991,z=30833..48589
|
|
||||||
off x=19182..36667,y=-84948..-53662,z=-15128..-6251
|
|
||||||
on x=-32891..-12512,y=46790..64941,z=-37805..-31758
|
|
||||||
off x=-87853..-57958,y=-9105..10250,z=-27666..-5705
|
|
||||||
on x=-55159..-15768,y=-23929..-9785,z=49353..69701
|
|
||||||
off x=58381..63179,y=37782..69395,z=-5063..21127
|
|
||||||
on x=29347..54026,y=-84030..-63792,z=20530..32897
|
|
||||||
on x=1052..19601,y=-14750..-4884,z=70402..91679
|
|
||||||
off x=-43193..-30770,y=63615..86118,z=-19288..-5103
|
|
||||||
on x=59886..71212,y=-50156..-18781,z=-25959..4904
|
|
||||||
on x=-47400..-33917,y=45116..46183,z=-52576..-42214
|
|
||||||
off x=-2916..8013,y=72215..79301,z=12660..39986
|
|
||||||
on x=-47600..-29671,y=-66262..-47736,z=-250..18288
|
|
||||||
off x=-76766..-67021,y=23902..56855,z=-24188..-10948
|
|
||||||
on x=40863..55547,y=-41154..-4752,z=-60017..-51932
|
|
||||||
on x=19691..33799,y=-91077..-61569,z=-17018..7955
|
|
||||||
on x=-2214..28174,y=-39590..-31800,z=59281..85857
|
|
||||||
on x=40206..73039,y=45740..74950,z=-32389..-7431
|
|
||||||
on x=-60834..-50842,y=-68433..-41429,z=22771..27775
|
|
||||||
off x=31115..64073,y=-66256..-40204,z=-44062..-24526
|
|
||||||
on x=-10832..6359,y=-85458..-70278,z=-31345..-13315
|
|
||||||
off x=26581..36176,y=66579..67779,z=-35420..-10427
|
|
||||||
on x=66912..86434,y=-10806..2524,z=30276..35350
|
|
||||||
off x=60734..71718,y=-26519..-13963,z=32357..52134
|
|
||||||
on x=64029..94207,y=-21424..4543,z=-19917..-5796
|
|
||||||
off x=-22578..9205,y=26649..48657,z=-69531..-60261
|
|
||||||
off x=36844..66645,y=34250..50170,z=31072..49267
|
|
||||||
on x=-9961..-5497,y=7380..37072,z=-89348..-57961
|
|
||||||
on x=18102..50680,y=-76562..-65621,z=4542..24597
|
|
||||||
on x=-63529..-54599,y=-53394..-47786,z=21888..25725
|
|
||||||
off x=63654..94850,y=965..22382,z=-31743..-2000
|
|
||||||
on x=74998..76278,y=-37896..-10505,z=-9186..22612
|
|
||||||
off x=-30811..2911,y=-89485..-75160,z=-36405..-3483
|
|
||||||
off x=51745..78582,y=25188..33294,z=26010..58376
|
|
||||||
off x=15024..35252,y=-43146..-33304,z=-73102..-57750
|
|
||||||
on x=2426..9775,y=54690..83625,z=-41065..-25812
|
|
||||||
off x=-24228..-570,y=-52801..-30297,z=49276..66451
|
|
||||||
off x=-74129..-54073,y=-56542..-35923,z=-32562..-468
|
|
||||||
off x=-2928..15901,y=15260..33101,z=67801..88745
|
|
||||||
off x=-53099..-47112,y=-19233..13470,z=52727..69682
|
|
||||||
off x=35876..62082,y=-29873..3214,z=64189..67241
|
|
||||||
off x=-3064..17661,y=65230..82048,z=-410..28371
|
|
||||||
on x=14630..34564,y=-4463..16268,z=-96585..-71246
|
|
||||||
on x=-60251..-39251,y=-6775..3343,z=37689..65303
|
|
||||||
off x=50322..66243,y=19278..44771,z=41067..64697
|
|
||||||
off x=36020..61904,y=-27183..-9736,z=46137..73036
|
|
||||||
on x=61922..69366,y=-51710..-34152,z=21534..42960
|
|
||||||
on x=-48310..-33496,y=36461..61490,z=42916..57166
|
|
||||||
off x=-14180..12358,y=67333..80981,z=-40807..-23314
|
|
||||||
off x=-806..32676,y=-88882..-71765,z=10596..21784
|
|
||||||
on x=4361..34509,y=73189..90685,z=2499..14138
|
|
||||||
off x=-87784..-75559,y=-23875..-9307,z=-7239..13845
|
|
||||||
on x=-68172..-53511,y=35832..49496,z=33932..46400
|
|
||||||
on x=-55713..-37433,y=-5286..18352,z=55977..63293
|
|
||||||
on x=-17643..17283,y=-35303..-16046,z=68866..82087
|
|
||||||
off x=25050..58536,y=-75214..-40996,z=-53573..-16621
|
|
||||||
off x=14898..28167,y=-85300..-58742,z=-21836..-5732
|
|
||||||
off x=-87322..-55171,y=-35094..-10807,z=9939..27679
|
|
||||||
on x=-56866..-31891,y=-52393..-39065,z=51551..54781
|
|
||||||
on x=1566..33534,y=54640..59730,z=51744..60395
|
|
||||||
on x=15272..24542,y=64983..91848,z=3089..8627
|
|
||||||
on x=65424..83864,y=29222..36126,z=-12872..15695
|
|
||||||
off x=-2899..17557,y=-87982..-63662,z=1631..29537
|
|
||||||
off x=-26849..-9477,y=53092..71495,z=-64534..-33903
|
|
||||||
on x=-8981..22557,y=22399..30246,z=-76499..-58300
|
|
||||||
off x=-72834..-48859,y=-18764..9128,z=35760..62856
|
|
||||||
off x=-24250..-15338,y=31706..46920,z=55005..82901
|
|
||||||
off x=37368..45012,y=-40763..-35016,z=-60587..-38956
|
|
||||||
on x=9616..34618,y=-61089..-34252,z=50095..76726
|
|
||||||
off x=-14337..4309,y=-63805..-49426,z=-75783..-53417
|
|
||||||
on x=-31091..2449,y=55254..83398,z=-55349..-29593
|
|
||||||
on x=66679..79368,y=-43938..-18102,z=1633..26650
|
|
||||||
on x=-32143..-25109,y=62219..88867,z=1027..29516
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#############
|
|
||||||
#...........#
|
|
||||||
###D#A#C#D###
|
|
||||||
#C#A#B#B#
|
|
||||||
#########
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
9976786789439313678999989767678999865435679398654323678999987654313468954569865334568916987643236789
|
|
||||||
9754395678998754599898978954567999976556789498775413478998798743203457893479973212479425698432145799
|
|
||||||
9843234589899866698786767943456789987687899987653104567897659957312368931298984596599934679549234689
|
|
||||||
8654785789789979897645459892967895698798999999873215698958349876433456892987899989989895998998965899
|
|
||||||
9865696895678989999731346799898954569999888921954524899542129986556767999976998679767699767897896789
|
|
||||||
9876789934799998997890235689799962978999767939878436789674398898668979998865797598755589656656897994
|
|
||||||
9997898956789987976531345679677899899987656899989547994989987798779893987654679459543478943348998923
|
|
||||||
8998987997999995987632456789545698789498545689999759213498986649899754597643812398656569651267899434
|
|
||||||
7999896889998754698743458997324789579597934778923978904597665431998996997532101259769778953456897645
|
|
||||||
6798765567899643987654599765437994468986724567910989895689543210127789876543312345978989764567979967
|
|
||||||
4987654378989756998765689976546792399654212389891296789798787631435678987654443656989999875678967898
|
|
||||||
2098754235678999779876797987656910987543101245789945679899976543576899998765564778999932996789458929
|
|
||||||
3989976127889987667997896798767891987654424699896832398932987656688978989896685889568899869892349310
|
|
||||||
9868997346999875454598945699898932398765536789995431987893498767899769875959786893456789654901258921
|
|
||||||
8754398757997654323579436989989693999896645892189546976789999989923459974349897932365696543212347893
|
|
||||||
6543239898996543212467949876976579899987756943478969875656898694304598763201998921234789876423456789
|
|
||||||
5432123999987954323678998765432455689299897894567899764348976543212797654512989432345998765434567892
|
|
||||||
7521012999899876549789999897621234579109998985678998654237898754344598865623976543456899876545679921
|
|
||||||
8633439878799987899897899998510123678998789976899899893156789765998789998734989954987932987678789540
|
|
||||||
9864598765689998965956798679323234569876577897916789989345678989899893239845698899898921099989898432
|
|
||||||
9998679854345999654346689598764345779765466789434598978976789998799932134956987645689542134599987656
|
|
||||||
8998798943239876543235595439895456989887345678949987956897899987679543235977898634579763289998799867
|
|
||||||
6899987654945998754123459910976567899996576789298976745679999896568954345989999548678975467896549878
|
|
||||||
5979898999899986543234567891297679999987897890197545236798998765467895456791987656799987579965434989
|
|
||||||
4656789889788998767349679999989989998799998989975432124567899865346896569942998979989998998943219898
|
|
||||||
3546798775667899898457889998967899989654349678985421013456792964236789998899879998879899987894698767
|
|
||||||
2124999654556999999578999887856789978993244569876534124567891098145698766679965987768798986999898756
|
|
||||||
4019886543445678998789498656745689869789123456998975335688989987234897655567894976543567895878986545
|
|
||||||
2129765432137999999894349743136789754698934567899996746899978976457986543456932987657678944669875436
|
|
||||||
7439876543446789987953219865347996543567897678985987968999767896569875432345891099768989323456996557
|
|
||||||
6545998655567896896432101965468987662378998989864699879987658899678987564676792943978993101245987698
|
|
||||||
9656789986878995987643229877599299831499349899943012989976545798989898665687899891099765622456798789
|
|
||||||
8967893297889689998784346987689123910976456789652127899965434567898799897798989799999865436567899893
|
|
||||||
7898989098993568999896598998891019899897887899754335789854323459998678998929978677892987545678978932
|
|
||||||
6989878999012456789998799989989129798789998979896467899765401568892489789219865566991297656789769991
|
|
||||||
5978567896434568999999988664578998654698999567987568987654312456791336678997654455789998769893456989
|
|
||||||
4564456789565689989899977553467976553487893459998679598776534587890124569898653234567899899932499879
|
|
||||||
3412367998798799976799765432149875432346892467899795439987659698989235879679765165689998989543989967
|
|
||||||
2101267899899899865789979574235996543556921235679899920398878969778956989469981012357897678999867898
|
|
||||||
3213458902942998654799988765346987965698910126896998891239989754567897892398792123968958569987658919
|
|
||||||
4323667899431299865678999875467899879899991298945987789645997643456789954999653246799542459876549201
|
|
||||||
6454798988949987978789543987598923989987789989539976567959865432347899999898754757898931345998678912
|
|
||||||
7565899567898765989999432399999212399876569878998765458967987541767979889769875768967890156999789323
|
|
||||||
8787893458999994395678940998798993569765498567897654378998998652378967678943986779756799299899996547
|
|
||||||
9898984567899989234567899895576789679854376456899989234989976543578954587892197889549898986789769756
|
|
||||||
8999765698969878987679999784445689798765212345698762134567897665689543456789098994338987654678959897
|
|
||||||
7689878789757767898991987643234778949854323456798743457789998778789642345678999543227699865789244998
|
|
||||||
6567989897643456789210299753124569534999954567987654568899899899999765467889987654103456986990123469
|
|
||||||
5478999976532345689321398921015678965987895678998865679945799998999876989996798793212568998932645567
|
|
||||||
4369898764321234789932987932124789976996799799879978795634568987899987896765979984324579679943787699
|
|
||||||
5456798765410123567893996893245899989875778986565989894325689976799898965434769876458689557899998789
|
|
||||||
6568899879321235778999875789359989898764567897454598965434798765689769996323459987568789445678999897
|
|
||||||
7679932998932446799987754568998766789832456779213457896545679874579943987899968998789893234789678965
|
|
||||||
8998921987999967899876543479899854698901234568902345679656789863467892399998799659899932145796567973
|
|
||||||
9867899896987899998765432456789783987892345689214696898767998654567999457987688943998643466965459892
|
|
||||||
8756798765695678999897551235699542356789466895438789999879979865678978969896567891239894997896569789
|
|
||||||
4348898654254768999959652357898421368996598987549899989999867979789767998765456789349989789998879675
|
|
||||||
2123998763123456789239743568987210156987679297656789878987656899897659798765345695498878678899998423
|
|
||||||
3239129864346579890126987679875431234898789198987997569876543988987545679892129989697666567789397674
|
|
||||||
5498998765457678989345999893986532456789999999798998678998732567896534569989398879986553435679298786
|
|
||||||
6987689986678799778999878912976543467895667894569989799998643488965423498878987969865432324778999897
|
|
||||||
9876579997989891566789967109898654567973456789994679987987656567893212987569976656986541013567899998
|
|
||||||
9765468998999932345698754398769767678962347999873598976598767779984329765467965545987656723459999999
|
|
||||||
7654357899989993996789965987659898889653458998762987654349898899876498654389894321299867936578987899
|
|
||||||
6543246789879879789898996986543969999784567897654998743236999999987569865234789210156978547789476789
|
|
||||||
6432135678967865678987989987542355678996788969879876574135789987598997973123579931345899658892345699
|
|
||||||
7687548789656654599876767895431234567899899356998765431013892393469986521034567892456789867901557789
|
|
||||||
9798656899545433987654456987650125678967943249659896432354989989578987432145679954667898979212678994
|
|
||||||
9898787998621012976512345798761334789458954998949999563765679878999976565358789976898997989954569313
|
|
||||||
8999998999732135997433558999873547997378999876797698754876798767989989987467898989929876896796798901
|
|
||||||
7899899986543249876547667898984756895489987945679549865677899654878990298998957599949765765689997899
|
|
||||||
6789763298854658997659879987899867896999876435678939978788998743456891999979546467899854234567895998
|
|
||||||
5678943149765867899792989976789998979899987549899598989899239654789979799868932345679972123478924987
|
|
||||||
4789432027986878998910996765678999456789898956965467899999198765689565689657896566798763244569109876
|
|
||||||
9899843456797899987899875654567892345798779767895345678988989876789434798798997678987654559789299954
|
|
||||||
9999754568998998976789654563479954467997659878943234589967979987996545899899698789899765667899987832
|
|
||||||
9998765678919987565699943242348976778976543989542199789856567699397696799943569898759876779999876521
|
|
||||||
8989876789109875454689893101567898989975432397659988998743434569298787898759699999643998896598765430
|
|
||||||
7976989893298755323456789232456789090986941098798767997632129678969899969898988998932449987439875421
|
|
||||||
6895492994398943212345795467767892191999892149899656789547298989654993456987776897891234598321987632
|
|
||||||
5999910989987653202456789578978943989898789236987646797656956996532389767996545456910123987532398943
|
|
||||||
4687899875499854578569897989989659878767679345998334689899897898675478979885432345891435798543459654
|
|
||||||
3496789986799875989689965395699899767654578959886123899989799999896567898765421256789545899866599975
|
|
||||||
2345678997898976798798754234579987654323467998765335789975639878987679999854210168998766789978789989
|
|
||||||
1456789998966987899898655123678999843212345689976547999764526567998989988975432259789987893199899899
|
|
||||||
0267899869445698999989632016789654954301386797897678998653212349999899867997546345678998992098965789
|
|
||||||
9469923954236789998679542124578979865716577896779989998632101239877645456789667456799659789987654567
|
|
||||||
8999919878997999997568993295689899876897679954567896987543212349765432347898778568892345694398767678
|
|
||||||
7887899989889999876457789989789789998998789343679964597654343598654321236789889678901299789459998789
|
|
||||||
6576789999768798765354699979998679789659893212489873298785764789965446545899998799999987999567999893
|
|
||||||
5454678988657669989212989767897578679943954401678994569876989999876557656999029891987686898978998942
|
|
||||||
6213469976543457898929876456896434578894975626899789978989899997998969797898998932396545657899997653
|
|
||||||
7534578954332598997899954345965323456789876545679679899998789896989979898967987543987432346998789767
|
|
||||||
8945789764101239876799875697894212399899998666789456789989679765879989999656798654987621499887679988
|
|
||||||
9767897653214398785789976989976201987989109877891345679765578954567898989545659765699710987674567899
|
|
||||||
9878999764323987674567897978943219896579299989943456998674458943456967878931349889799831298543456789
|
|
||||||
6989789975439876563456999867894329785498989998657569876533267932678955467893456992987542975432545699
|
|
||||||
5497569876798765442499998758965498674356678939978998975420157893489543248954567891598659864321234568
|
|
||||||
4323456988999654321378959967976987543234568921989987654321345789599432139896689932398769765434656899
|
|
||||||
5435567899998766562457949878987898656045679210191099865432467897678945546789796546459879876545767899
|
|
||||||
@@ -1,265 +0,0 @@
|
|||||||
//! --- Day 10: Syntax Scoring ---
|
|
||||||
//! You ask the submarine to determine the best route out of the deep-sea cave, but it only replies:
|
|
||||||
//!
|
|
||||||
//! Syntax error in navigation subsystem on line: all of them
|
|
||||||
//! All of them?! The damage is worse than you thought. You bring up a copy of the navigation subsystem (your puzzle input).
|
|
||||||
//!
|
|
||||||
//! The navigation subsystem syntax is made of several lines containing chunks. There are one or more chunks on each line, and chunks contain zero or more other chunks. Adjacent chunks are not separated by any delimiter; if one chunk stops, the next chunk (if any) can immediately start. Every chunk must open and close with one of four legal pairs of matching characters:
|
|
||||||
//!
|
|
||||||
//! If a chunk opens with (, it must close with ).
|
|
||||||
//! If a chunk opens with [, it must close with ].
|
|
||||||
//! If a chunk opens with {, it must close with }.
|
|
||||||
//! If a chunk opens with <, it must close with >.
|
|
||||||
//! So, () is a legal chunk that contains no other chunks, as is []. More complex but valid chunks include ([]), {()()()}, <([{}])>, [<>({}){}[([])<>]], and even (((((((((()))))))))).
|
|
||||||
//!
|
|
||||||
//! Some lines are incomplete, but others are corrupted. Find and discard the corrupted lines first.
|
|
||||||
//!
|
|
||||||
//! A corrupted line is one where a chunk closes with the wrong character - that is, where the characters it opens and closes with do not form one of the four legal pairs listed above.
|
|
||||||
//!
|
|
||||||
//! Examples of corrupted chunks include (], {()()()>, (((()))}, and <([]){()}[{}]). Such a chunk can appear anywhere within a line, and its presence causes the whole line to be considered corrupted.
|
|
||||||
//!
|
|
||||||
//! For example, consider the following navigation subsystem:
|
|
||||||
//!
|
|
||||||
//! [({(<(())[]>[[{[]{<()<>>
|
|
||||||
//! [(()[<>])]({[<{<<[]>>(
|
|
||||||
//! {([(<{}[<>[]}>{[]{[(<()>
|
|
||||||
//! (((({<>}<{<{<>}{[]{[]{}
|
|
||||||
//! [[<[([]))<([[{}[[()]]]
|
|
||||||
//! [{[{({}]{}}([{[{{{}}([]
|
|
||||||
//! {<[[]]>}<{[{[{[]{()[[[]
|
|
||||||
//! [<(<(<(<{}))><([]([]()
|
|
||||||
//! <{([([[(<>()){}]>(<<{{
|
|
||||||
//! <{([{{}}[<[[[<>{}]]]>[]]
|
|
||||||
//! Some of the lines aren't corrupted, just incomplete; you can ignore these lines for now. The remaining five lines are corrupted:
|
|
||||||
//!
|
|
||||||
//! {([(<{}[<>[]}>{[]{[(<()> - Expected ], but found } instead.
|
|
||||||
//! [[<[([]))<([[{}[[()]]] - Expected ], but found ) instead.
|
|
||||||
//! [{[{({}]{}}([{[{{{}}([] - Expected ), but found ] instead.
|
|
||||||
//! [<(<(<(<{}))><([]([]() - Expected >, but found ) instead.
|
|
||||||
//! <{([([[(<>()){}]>(<<{{ - Expected ], but found > instead.
|
|
||||||
//! Stop at the first incorrect closing character on each corrupted line.
|
|
||||||
//!
|
|
||||||
//! Did you know that syntax checkers actually have contests to see who can get the high score for syntax errors in a file? It's true! To calculate the syntax error score for a line, take the first illegal character on the line and look it up in the following table:
|
|
||||||
//!
|
|
||||||
//! ): 3 points.
|
|
||||||
//! ]: 57 points.
|
|
||||||
//! }: 1197 points.
|
|
||||||
//! >: 25137 points.
|
|
||||||
//! In the above example, an illegal ) was found twice (2*3 = 6 points), an illegal ] was found once (57 points), an illegal } was found once (1197 points), and an illegal > was found once (25137 points). So, the total syntax error score for this file is 6+57+1197+25137 = 26397 points!
|
|
||||||
//!
|
|
||||||
//! Find the first illegal character in each corrupted line of the navigation subsystem. What is the total syntax error score for those errors?
|
|
||||||
//!
|
|
||||||
//! --- Part Two ---
|
|
||||||
//! Now, discard the corrupted lines. The remaining lines are incomplete.
|
|
||||||
//!
|
|
||||||
//! Incomplete lines don't have any incorrect characters - instead, they're missing some closing characters at the end of the line. To repair the navigation subsystem, you just need to figure out the sequence of closing characters that complete all open chunks in the line.
|
|
||||||
//!
|
|
||||||
//! You can only use closing characters (), ], }, or >), and you must add them in the correct order so that only legal pairs are formed and all chunks end up closed.
|
|
||||||
//!
|
|
||||||
//! In the example above, there are five incomplete lines:
|
|
||||||
//!
|
|
||||||
//!
|
|
||||||
//! [({(<(())[]>[[{[]{<()<>> - Complete by adding }}]])})].
|
|
||||||
//! [(()[<>])]({[<{<<[]>>( - Complete by adding )}>]}).
|
|
||||||
//! (((({<>}<{<{<>}{[]{[]{} - Complete by adding }}>}>)))).
|
|
||||||
//! {<[[]]>}<{[{[{[]{()[[[] - Complete by adding ]]}}]}]}>.
|
|
||||||
//! <{([{{}}[<[[[<>{}]]]>[]] - Complete by adding ])}>.
|
|
||||||
//! Did you know that autocomplete tools also have contests? It's true! The score is determined by considering the completion string character-by-character. Start with a total score of 0. Then, for each character, multiply the total score by 5 and then increase the total score by the point value given for the character in the following table:
|
|
||||||
//!
|
|
||||||
//! ): 1 point.
|
|
||||||
//! ]: 2 points.
|
|
||||||
//! }: 3 points.
|
|
||||||
//! >: 4 points.
|
|
||||||
//! So, the last completion string above - ])}> - would be scored as follows:
|
|
||||||
//!
|
|
||||||
//! Start with a total score of 0.
|
|
||||||
//! Multiply the total score by 5 to get 0, then add the value of ] (2) to get a new total score of 2.
|
|
||||||
//! Multiply the total score by 5 to get 10, then add the value of ) (1) to get a new total score of 11.
|
|
||||||
//! Multiply the total score by 5 to get 55, then add the value of } (3) to get a new total score of 58.
|
|
||||||
//! Multiply the total score by 5 to get 290, then add the value of > (4) to get a new total score of 294.
|
|
||||||
//! The five lines' completion strings have total scores as follows:
|
|
||||||
//!
|
|
||||||
//! }}]])})] - 288957 total points.
|
|
||||||
//! )}>]}) - 5566 total points.
|
|
||||||
//! }}>}>)))) - 1480781 total points.
|
|
||||||
//! ]]}}]}]}> - 995444 total points.
|
|
||||||
//! ])}> - 294 total points.
|
|
||||||
//! Autocomplete tools are an odd bunch: the winner is found by sorting all of the scores and then taking the middle score. (There will always be an odd number of scores to consider.) In this example, the middle score is 288957 because there are the same number of scores smaller and larger than it.
|
|
||||||
//!
|
|
||||||
//! Find the completion string for each incomplete line, score the completion strings, and sort the scores. What is the middle score?
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
fn corrupt_score(b: u8) -> u64 {
|
|
||||||
match b {
|
|
||||||
b')' => 3,
|
|
||||||
b']' => 57,
|
|
||||||
b'}' => 1197,
|
|
||||||
b'>' => 25137,
|
|
||||||
_ => panic!("unknown illegal character '{}'", b),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn corrupted(line: &str) -> Option<u8> {
|
|
||||||
let pairs: HashMap<_, _> = vec![
|
|
||||||
(b'(', b')'),
|
|
||||||
(b'{', b'}'),
|
|
||||||
(b'[', b']'),
|
|
||||||
(b'<', b'>'),
|
|
||||||
(b')', b'('),
|
|
||||||
(b'}', b'{'),
|
|
||||||
(b']', b'['),
|
|
||||||
(b'>', b'<'),
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.collect();
|
|
||||||
let mut stack = Vec::new();
|
|
||||||
for b in line.as_bytes() {
|
|
||||||
match b {
|
|
||||||
b'[' | b'(' | b'{' | b'<' => stack.push(b),
|
|
||||||
b']' | b')' | b'}' | b'>' => {
|
|
||||||
let c = pairs[stack.pop().unwrap()];
|
|
||||||
if c != *b {
|
|
||||||
return Some(*b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => panic!("Unexpected delimiter '{}'", b),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
fn incomplete_score(bs: &[u8]) -> u64 {
|
|
||||||
bs.iter().fold(0, |acc, b| {
|
|
||||||
acc * 5
|
|
||||||
+ match b {
|
|
||||||
b')' => 1,
|
|
||||||
b']' => 2,
|
|
||||||
b'}' => 3,
|
|
||||||
b'>' => 4,
|
|
||||||
_ => panic!("unknown illegal character '{}'", b),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn incompleted(line: &str) -> Vec<u8> {
|
|
||||||
let pairs: HashMap<_, _> = vec![
|
|
||||||
(b'(', b')'),
|
|
||||||
(b'{', b'}'),
|
|
||||||
(b'[', b']'),
|
|
||||||
(b'<', b'>'),
|
|
||||||
(b')', b'('),
|
|
||||||
(b'}', b'{'),
|
|
||||||
(b']', b'['),
|
|
||||||
(b'>', b'<'),
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
.collect();
|
|
||||||
let mut stack = Vec::new();
|
|
||||||
for b in line.as_bytes() {
|
|
||||||
match b {
|
|
||||||
b'[' | b'(' | b'{' | b'<' => stack.push(b),
|
|
||||||
b']' | b')' | b'}' | b'>' => {
|
|
||||||
stack.pop();
|
|
||||||
}
|
|
||||||
_ => panic!("Unexpected delimiter '{}'", b),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stack.iter().rev().map(|b| pairs[b]).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day10, part1)]
|
|
||||||
fn part1(input: &str) -> Result<u64> {
|
|
||||||
Ok(input.lines().filter_map(corrupted).map(corrupt_score).sum())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day10, part2)]
|
|
||||||
fn part2(input: &str) -> Result<u64> {
|
|
||||||
let mut scores: Vec<_> = input
|
|
||||||
.lines()
|
|
||||||
.filter(|l| corrupted(l).is_none())
|
|
||||||
.filter_map(|l| {
|
|
||||||
let r = incompleted(l);
|
|
||||||
if r.is_empty() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(r)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.map(|bs| incomplete_score(&bs))
|
|
||||||
.collect();
|
|
||||||
scores.sort_unstable();
|
|
||||||
Ok(scores[scores.len() / 2])
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
[({(<(())[]>[[{[]{<()<>>
|
|
||||||
[(()[<>])]({[<{<<[]>>(
|
|
||||||
{([(<{}[<>[]}>{[]{[(<()>
|
|
||||||
(((({<>}<{<{<>}{[]{[]{}
|
|
||||||
[[<[([]))<([[{}[[()]]]
|
|
||||||
[{[{({}]{}}([{[{{{}}([]
|
|
||||||
{<[[]]>}<{[{[{[]{()[[[]
|
|
||||||
[<(<(<(<{}))><([]([]()
|
|
||||||
<{([([[(<>()){}]>(<<{{
|
|
||||||
<{([{{}}[<[[[<>{}]]]>[]]
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 26397);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_incompleted() {
|
|
||||||
assert_eq!(
|
|
||||||
incompleted("[({(<(())[]>[[{[]{<()<>>"),
|
|
||||||
b"}}]])})]".to_vec()
|
|
||||||
);
|
|
||||||
assert_eq!(incompleted("[(()[<>])]({[<{<<[]>>("), b")}>]})".to_vec());
|
|
||||||
assert_eq!(
|
|
||||||
incompleted("(((({<>}<{<{<>}{[]{[]{}"),
|
|
||||||
b"}}>}>))))".to_vec()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
incompleted("{<[[]]>}<{[{[{[]{()[[[]"),
|
|
||||||
b"]]}}]}]}>".to_vec()
|
|
||||||
);
|
|
||||||
assert_eq!(incompleted("<{([{{}}[<[[[<>{}]]]>[]]"), b"])}>".to_vec());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_incomplete_score() {
|
|
||||||
assert_eq!(incomplete_score(&b"}}]])})]".to_vec()), 288957);
|
|
||||||
assert_eq!(incomplete_score(&b")}>]})".to_vec()), 5566);
|
|
||||||
assert_eq!(incomplete_score(&b"}}>}>))))".to_vec()), 1480781);
|
|
||||||
assert_eq!(incomplete_score(&b"]]}}]}]}>".to_vec()), 995444);
|
|
||||||
assert_eq!(incomplete_score(&b"])}>".to_vec()), 294);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
[({(<(())[]>[[{[]{<()<>>
|
|
||||||
[(()[<>])]({[<{<<[]>>(
|
|
||||||
{([(<{}[<>[]}>{[]{[(<()>
|
|
||||||
(((({<>}<{<{<>}{[]{[]{}
|
|
||||||
[[<[([]))<([[{}[[()]]]
|
|
||||||
[{[{({}]{}}([{[{{{}}([]
|
|
||||||
{<[[]]>}<{[{[{[]{()[[[]
|
|
||||||
[<(<(<(<{}))><([]([]()
|
|
||||||
<{([([[(<>()){}]>(<<{{
|
|
||||||
<{([{{}}[<[[[<>{}]]]>[]]
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 288957);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,444 +0,0 @@
|
|||||||
use std::{
|
|
||||||
collections::HashSet,
|
|
||||||
convert::Infallible,
|
|
||||||
fmt::{Debug, Error, Formatter},
|
|
||||||
ops::{Index, IndexMut},
|
|
||||||
str::FromStr,
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
struct Image {
|
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
pixels: Vec<u8>,
|
|
||||||
flashes: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Image {
|
|
||||||
fn kernel3x3<F>(&mut self, (x, y): (usize, usize), func: F)
|
|
||||||
where
|
|
||||||
F: Fn(u8) -> u8,
|
|
||||||
{
|
|
||||||
if x > 0 {
|
|
||||||
self[(x - 1, y)] = func(self[(x - 1, y)]);
|
|
||||||
if y > 0 {
|
|
||||||
self[(x - 1, y - 1)] = func(self[(x - 1, y - 1)]);
|
|
||||||
}
|
|
||||||
if y < self.height - 1 {
|
|
||||||
self[(x - 1, y + 1)] = func(self[(x - 1, y + 1)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if y > 0 {
|
|
||||||
self[(x, y - 1)] = func(self[(x, y - 1)]);
|
|
||||||
}
|
|
||||||
if y < self.height - 1 {
|
|
||||||
self[(x, y + 1)] = func(self[(x, y + 1)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if x < self.width - 1 {
|
|
||||||
self[(x + 1, y)] = func(self[(x + 1, y)]);
|
|
||||||
if y > 0 {
|
|
||||||
self[(x + 1, y - 1)] = func(self[(x + 1, y - 1)]);
|
|
||||||
}
|
|
||||||
if y < self.height - 1 {
|
|
||||||
self[(x + 1, y + 1)] = func(self[(x + 1, y + 1)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn step(&mut self) {
|
|
||||||
self.pixels.iter_mut().for_each(|p| *p += 1);
|
|
||||||
let mut flashed: HashSet<(usize, usize)> = HashSet::new();
|
|
||||||
loop {
|
|
||||||
let mut flashes = 0;
|
|
||||||
// Apply the effect of a flash on neighbors
|
|
||||||
let mut need_to_flash = Vec::new();
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
if self[(x, y)] > 9 && !flashed.contains(&(x, y)) {
|
|
||||||
need_to_flash.push((x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (x, y) in need_to_flash {
|
|
||||||
self.kernel3x3((x, y), |x| x + 1);
|
|
||||||
flashed.insert((x, y));
|
|
||||||
flashes += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if flashes == 0 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
self.flashes += flashes;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.pixels.iter_mut().for_each(|p| {
|
|
||||||
if *p > 9 {
|
|
||||||
*p = 0
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sync(&self) -> bool {
|
|
||||||
let sentinel = self[(0, 0)];
|
|
||||||
for p in &self.pixels {
|
|
||||||
if *p != sentinel {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for Image {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.width == other.width && self.height == other.height && self.pixels == other.pixels
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Image {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
writeln!(f)?;
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
write!(f, "{:3}", self[(x, y)])?;
|
|
||||||
}
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Image {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
let rows: Vec<_> = s.lines().collect();
|
|
||||||
let width = rows[0].len();
|
|
||||||
let height = rows.len();
|
|
||||||
let pixels = rows
|
|
||||||
.iter()
|
|
||||||
.flat_map(|row| row.as_bytes().iter().map(|b| b - b'0'))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(Image {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
flashes: 0,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Index<(usize, usize)> for Image {
|
|
||||||
type Output = u8;
|
|
||||||
fn index(&self, (x, y): (usize, usize)) -> &Self::Output {
|
|
||||||
&self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IndexMut<(usize, usize)> for Image {
|
|
||||||
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut Self::Output {
|
|
||||||
&mut self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day11, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let mut im: Image = input.parse()?;
|
|
||||||
for _ in 0..100 {
|
|
||||||
im.step();
|
|
||||||
}
|
|
||||||
if im.width > 11 {
|
|
||||||
assert!(im.flashes > 1355);
|
|
||||||
}
|
|
||||||
Ok(im.flashes)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day11, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let mut im: Image = input.parse()?;
|
|
||||||
for i in 1.. {
|
|
||||||
im.step();
|
|
||||||
if im.sync() {
|
|
||||||
return Ok(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unreachable!();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
5483143223
|
|
||||||
2745854711
|
|
||||||
5264556173
|
|
||||||
6141336146
|
|
||||||
6357385478
|
|
||||||
4167524645
|
|
||||||
2176841721
|
|
||||||
6882881134
|
|
||||||
4846848554
|
|
||||||
5283751526
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 1656);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_step() -> Result<()> {
|
|
||||||
let mut im: Image = r#"
|
|
||||||
11111
|
|
||||||
19991
|
|
||||||
19191
|
|
||||||
19991
|
|
||||||
11111
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
let step1: Image = r#"
|
|
||||||
34543
|
|
||||||
40004
|
|
||||||
50005
|
|
||||||
40004
|
|
||||||
34543
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step2: Image = r#"
|
|
||||||
45654
|
|
||||||
51115
|
|
||||||
61116
|
|
||||||
51115
|
|
||||||
45654
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step1);
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step2);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_many_iterations() -> Result<()> {
|
|
||||||
let mut im: Image = r#"
|
|
||||||
5483143223
|
|
||||||
2745854711
|
|
||||||
5264556173
|
|
||||||
6141336146
|
|
||||||
6357385478
|
|
||||||
4167524645
|
|
||||||
2176841721
|
|
||||||
6882881134
|
|
||||||
4846848554
|
|
||||||
5283751526
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step1: Image = r#"
|
|
||||||
6594254334
|
|
||||||
3856965822
|
|
||||||
6375667284
|
|
||||||
7252447257
|
|
||||||
7468496589
|
|
||||||
5278635756
|
|
||||||
3287952832
|
|
||||||
7993992245
|
|
||||||
5957959665
|
|
||||||
6394862637
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step2: Image = r#"
|
|
||||||
8807476555
|
|
||||||
5089087054
|
|
||||||
8597889608
|
|
||||||
8485769600
|
|
||||||
8700908800
|
|
||||||
6600088989
|
|
||||||
6800005943
|
|
||||||
0000007456
|
|
||||||
9000000876
|
|
||||||
8700006848
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step3: Image = r#"
|
|
||||||
0050900866
|
|
||||||
8500800575
|
|
||||||
9900000039
|
|
||||||
9700000041
|
|
||||||
9935080063
|
|
||||||
7712300000
|
|
||||||
7911250009
|
|
||||||
2211130000
|
|
||||||
0421125000
|
|
||||||
0021119000
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step4: Image = r#"
|
|
||||||
2263031977
|
|
||||||
0923031697
|
|
||||||
0032221150
|
|
||||||
0041111163
|
|
||||||
0076191174
|
|
||||||
0053411122
|
|
||||||
0042361120
|
|
||||||
5532241122
|
|
||||||
1532247211
|
|
||||||
1132230211
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step5: Image = r#"
|
|
||||||
4484144000
|
|
||||||
2044144000
|
|
||||||
2253333493
|
|
||||||
1152333274
|
|
||||||
1187303285
|
|
||||||
1164633233
|
|
||||||
1153472231
|
|
||||||
6643352233
|
|
||||||
2643358322
|
|
||||||
2243341322
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step6: Image = r#"
|
|
||||||
5595255111
|
|
||||||
3155255222
|
|
||||||
3364444605
|
|
||||||
2263444496
|
|
||||||
2298414396
|
|
||||||
2275744344
|
|
||||||
2264583342
|
|
||||||
7754463344
|
|
||||||
3754469433
|
|
||||||
3354452433
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step7: Image = r#"
|
|
||||||
6707366222
|
|
||||||
4377366333
|
|
||||||
4475555827
|
|
||||||
3496655709
|
|
||||||
3500625609
|
|
||||||
3509955566
|
|
||||||
3486694453
|
|
||||||
8865585555
|
|
||||||
4865580644
|
|
||||||
4465574644
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step8: Image = r#"
|
|
||||||
7818477333
|
|
||||||
5488477444
|
|
||||||
5697666949
|
|
||||||
4608766830
|
|
||||||
4734946730
|
|
||||||
4740097688
|
|
||||||
6900007564
|
|
||||||
0000009666
|
|
||||||
8000004755
|
|
||||||
6800007755
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step9: Image = r#"
|
|
||||||
9060000644
|
|
||||||
7800000976
|
|
||||||
6900000080
|
|
||||||
5840000082
|
|
||||||
5858000093
|
|
||||||
6962400000
|
|
||||||
8021250009
|
|
||||||
2221130009
|
|
||||||
9111128097
|
|
||||||
7911119976
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
|
|
||||||
let step10: Image = r#"
|
|
||||||
0481112976
|
|
||||||
0031112009
|
|
||||||
0041112504
|
|
||||||
0081111406
|
|
||||||
0099111306
|
|
||||||
0093511233
|
|
||||||
0442361130
|
|
||||||
5532252350
|
|
||||||
0532250600
|
|
||||||
0032240000
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.parse()?;
|
|
||||||
let step10_flashes = 204;
|
|
||||||
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step1, "step1");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step2, "step2");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step3, "step3");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step4, "step4");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step5, "step5");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step6, "step6");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step7, "step7");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step8, "step8");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step9, "step9");
|
|
||||||
im.step();
|
|
||||||
assert_eq!(im, step10, "step10");
|
|
||||||
assert_eq!(im.flashes, step10_flashes, "step10 wrong flashes");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
5483143223
|
|
||||||
2745854711
|
|
||||||
5264556173
|
|
||||||
6141336146
|
|
||||||
6357385478
|
|
||||||
4167524645
|
|
||||||
2176841721
|
|
||||||
6882881134
|
|
||||||
4846848554
|
|
||||||
5283751526
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 195);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
fn search(node: &str, nodes: &HashMap<&str, Vec<&str>>, path: String, paths: &mut Vec<String>) {
|
|
||||||
if node == "end" {
|
|
||||||
paths.push(path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for neighbor in &nodes[node] {
|
|
||||||
// If lowercase.
|
|
||||||
if neighbor.as_bytes()[0] & 0x20 != 0 && path.contains(neighbor) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
search(neighbor, nodes, format!("{},{}", path, neighbor), paths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn paths(nodes: &HashMap<&str, Vec<&str>>) -> usize {
|
|
||||||
let mut paths = Vec::new();
|
|
||||||
search("start", nodes, "start".to_string(), &mut paths);
|
|
||||||
paths.len()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day12, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let mut nodes = HashMap::new();
|
|
||||||
input.lines().for_each(|p| {
|
|
||||||
let (n1, n2) = p.split_once('-').expect("missing dash");
|
|
||||||
nodes.entry(n1).or_insert_with(Vec::new).push(n2);
|
|
||||||
nodes.entry(n2).or_insert_with(Vec::new).push(n1);
|
|
||||||
});
|
|
||||||
Ok(paths(&nodes))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn search2<'a>(
|
|
||||||
node: &str,
|
|
||||||
nodes: &HashMap<&'a str, Vec<&'a str>>,
|
|
||||||
path: &[&'a str],
|
|
||||||
paths: &mut Vec<Vec<&'a str>>,
|
|
||||||
double: &'a str,
|
|
||||||
smalls: &[&'a str],
|
|
||||||
) {
|
|
||||||
if node == "end" {
|
|
||||||
paths.push(path.to_vec());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for neighbor in &nodes[node] {
|
|
||||||
// If lowercase.
|
|
||||||
if neighbor.as_bytes()[0] & 0x20 != 0 {
|
|
||||||
if neighbor == &double {
|
|
||||||
// Allow two passes for this small node.
|
|
||||||
if path.iter().filter(|p| p == &neighbor).count() >= 2 {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Only allow one pass for this small node.
|
|
||||||
if path.contains(neighbor) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut child_path = path.to_vec();
|
|
||||||
child_path.push(neighbor);
|
|
||||||
search2(neighbor, nodes, &child_path, paths, double, smalls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn paths2(nodes: &HashMap<&str, Vec<&str>>) -> usize {
|
|
||||||
let mut paths = Vec::new();
|
|
||||||
let smalls: Vec<_> = nodes
|
|
||||||
.keys()
|
|
||||||
.filter(|n| n.as_bytes()[0] & 0x20 != 0)
|
|
||||||
.filter(|&n| n != &"start" && n != &"end")
|
|
||||||
.cloned()
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
for double in &smalls {
|
|
||||||
search2(
|
|
||||||
"start",
|
|
||||||
nodes,
|
|
||||||
&["start"],
|
|
||||||
&mut paths,
|
|
||||||
double,
|
|
||||||
smalls.as_slice(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
paths.sort();
|
|
||||||
paths.dedup();
|
|
||||||
paths.len()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day12, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let mut nodes = HashMap::new();
|
|
||||||
input.lines().for_each(|p| {
|
|
||||||
let (n1, n2) = p.split_once('-').expect("missing dash");
|
|
||||||
nodes.entry(n1).or_insert_with(Vec::new).push(n2);
|
|
||||||
nodes.entry(n2).or_insert_with(Vec::new).push(n1);
|
|
||||||
});
|
|
||||||
Ok(paths2(&nodes))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
start-A
|
|
||||||
start-b
|
|
||||||
A-c
|
|
||||||
A-b
|
|
||||||
b-d
|
|
||||||
A-end
|
|
||||||
b-end
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
|
|
||||||
assert_eq!(part1(input)?, 10);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
start-A
|
|
||||||
start-b
|
|
||||||
A-c
|
|
||||||
A-b
|
|
||||||
b-d
|
|
||||||
A-end
|
|
||||||
b-end
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 36);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,258 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
struct Image {
|
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
pixels: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Image {
|
|
||||||
fn new(width: usize, height: usize) -> Image {
|
|
||||||
let pixels = vec![0; width * height];
|
|
||||||
Image {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn new_with_pts(width: usize, height: usize, pts: &[(usize, usize)]) -> Image {
|
|
||||||
let pixels = vec![0; width * height];
|
|
||||||
let mut im = Image {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
};
|
|
||||||
dbg!(&width, &height);
|
|
||||||
pts.iter().for_each(|xy| im[*xy] = 1);
|
|
||||||
im
|
|
||||||
}
|
|
||||||
fn fold_y(&self, y_axis: usize) -> Image {
|
|
||||||
println!("fold_y @ {}", y_axis);
|
|
||||||
let mut im = Image::new(self.width, y_axis);
|
|
||||||
let odd = self.height % 2;
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
//dbg!( self.width, self.height, x, y, y_axis, (y % y_axis), self.pixels.len(), im.pixels.len());
|
|
||||||
if self[(x, y)] > 0 {
|
|
||||||
if y > y_axis {
|
|
||||||
im[(x, self.height - y - odd)] = self[(x, y)];
|
|
||||||
} else {
|
|
||||||
im[(x, y)] = self[(x, y)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
im
|
|
||||||
}
|
|
||||||
fn fold_x(&self, x_axis: usize) -> Image {
|
|
||||||
let odd = self.width % 2;
|
|
||||||
println!("fold_x @ {}", x_axis);
|
|
||||||
for y in 0..self.height {
|
|
||||||
assert_eq!(
|
|
||||||
self[(x_axis, y)],
|
|
||||||
0,
|
|
||||||
"w,h {},{} x_axis {}",
|
|
||||||
self.width,
|
|
||||||
self.height,
|
|
||||||
x_axis,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let mut im = Image::new(x_axis, self.height);
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
if self[(x, y)] > 0 {
|
|
||||||
if x > x_axis {
|
|
||||||
im[(self.width - x - odd, y)] = self[(x, y)];
|
|
||||||
} else {
|
|
||||||
im[(x, y)] = self[(x, y)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
im
|
|
||||||
}
|
|
||||||
|
|
||||||
fn count(&self) -> usize {
|
|
||||||
self.pixels.iter().filter(|&n| *n != 0).count()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Image {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
writeln!(f)?;
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
if self[(x, y)] > 0 {
|
|
||||||
write!(f, "#")?;
|
|
||||||
} else {
|
|
||||||
write!(f, ".")?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Index<(usize, usize)> for Image {
|
|
||||||
type Output = u8;
|
|
||||||
fn index(&self, (x, y): (usize, usize)) -> &Self::Output {
|
|
||||||
&self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IndexMut<(usize, usize)> for Image {
|
|
||||||
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut Self::Output {
|
|
||||||
//dbg!(self.width, self.height, x, y, self.pixels.len());
|
|
||||||
&mut self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day13, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let (pts, folds) = input.split_once("\n\n").unwrap();
|
|
||||||
let pts: Vec<(usize, usize)> = pts
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split_once(',').unwrap())
|
|
||||||
.map(|(x, y)| (x.parse().unwrap(), y.parse().unwrap()))
|
|
||||||
.collect();
|
|
||||||
let folds: Vec<_> = folds
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split(' ').nth(2).unwrap().split_once('=').unwrap())
|
|
||||||
.map(|(axis, idx)| (axis, idx.parse().unwrap()))
|
|
||||||
.collect();
|
|
||||||
let (maxx, maxy) = pts
|
|
||||||
.iter()
|
|
||||||
.fold((0, 0), |(maxx, maxy), (x, y)| (maxx.max(*x), maxy.max(*y)));
|
|
||||||
let mut im = Image::new_with_pts(maxx + 1, maxy + 1, &pts);
|
|
||||||
//dbg!(&im);
|
|
||||||
|
|
||||||
for (axis, idx) in folds.iter().take(1) {
|
|
||||||
im = if *axis == "y" {
|
|
||||||
im.fold_y(*idx)
|
|
||||||
} else {
|
|
||||||
im.fold_x(*idx)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
//assert!(im.count() < 896);
|
|
||||||
dbg!(&im);
|
|
||||||
Ok(im.count())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day13, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let (pts, folds) = input.split_once("\n\n").unwrap();
|
|
||||||
let pts: Vec<(usize, usize)> = pts
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split_once(',').unwrap())
|
|
||||||
.map(|(x, y)| (x.parse().unwrap(), y.parse().unwrap()))
|
|
||||||
.collect();
|
|
||||||
let folds: Vec<_> = folds
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split(' ').nth(2).unwrap().split_once('=').unwrap())
|
|
||||||
.map(|(axis, idx)| (axis, idx.parse().unwrap()))
|
|
||||||
.collect();
|
|
||||||
let (maxx, maxy) = pts
|
|
||||||
.iter()
|
|
||||||
.fold((0, 0), |(maxx, maxy), (x, y)| (maxx.max(*x), maxy.max(*y)));
|
|
||||||
let mut im = Image::new_with_pts(maxx + 1, maxy + 1, &pts);
|
|
||||||
//dbg!(&im);
|
|
||||||
|
|
||||||
for (axis, idx) in folds.iter() {
|
|
||||||
im = if *axis == "y" {
|
|
||||||
im.fold_y(*idx)
|
|
||||||
} else {
|
|
||||||
im.fold_x(*idx)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
dbg!(&im);
|
|
||||||
Ok(im.count())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
6,10
|
|
||||||
0,14
|
|
||||||
9,10
|
|
||||||
0,3
|
|
||||||
10,4
|
|
||||||
4,11
|
|
||||||
6,0
|
|
||||||
6,12
|
|
||||||
4,1
|
|
||||||
0,13
|
|
||||||
10,12
|
|
||||||
3,4
|
|
||||||
3,0
|
|
||||||
8,4
|
|
||||||
1,10
|
|
||||||
2,14
|
|
||||||
8,10
|
|
||||||
9,0
|
|
||||||
|
|
||||||
fold along y=7
|
|
||||||
fold along x=5
|
|
||||||
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 17);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_fold_x() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
0,0
|
|
||||||
1,1
|
|
||||||
3,3
|
|
||||||
4,4
|
|
||||||
|
|
||||||
fold along x=2
|
|
||||||
fold along y=2
|
|
||||||
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
let (pts, folds) = input.split_once("\n\n").unwrap();
|
|
||||||
let pts: Vec<(usize, usize)> = pts
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split_once(',').unwrap())
|
|
||||||
.map(|(x, y)| (x.parse().unwrap(), y.parse().unwrap()))
|
|
||||||
.collect();
|
|
||||||
let folds: Vec<_> = folds
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split(' ').nth(2).unwrap().split_once('=').unwrap())
|
|
||||||
.map(|(axis, idx)| (axis, idx.parse().unwrap()))
|
|
||||||
.collect();
|
|
||||||
let (maxx, maxy) = pts
|
|
||||||
.iter()
|
|
||||||
.fold((0, 0), |(maxx, maxy), (x, y)| (maxx.max(*x), maxy.max(*y)));
|
|
||||||
let mut im = Image::new_with_pts(maxx + 1, maxy + 1, &pts);
|
|
||||||
dbg!(&im);
|
|
||||||
for (axis, idx) in folds.iter() {
|
|
||||||
im = if *axis == "y" {
|
|
||||||
im.fold_y(*idx)
|
|
||||||
} else {
|
|
||||||
im.fold_x(*idx)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
dbg!(&im);
|
|
||||||
//assert_eq!(im.count(), 17);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
#[test]
|
|
||||||
fn test_part2()->Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, usize::MAX);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
struct TupleWindow<I, T>
|
|
||||||
where
|
|
||||||
I: Iterator<Item = T>,
|
|
||||||
{
|
|
||||||
iter: I,
|
|
||||||
prev: Option<T>,
|
|
||||||
next: Option<T>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I, T> TupleWindow<I, T>
|
|
||||||
where
|
|
||||||
I: Iterator<Item = T>,
|
|
||||||
{
|
|
||||||
fn new(iter: I, rules: &HashMap<&[u8], u8>) -> Self {
|
|
||||||
TupleWindow {
|
|
||||||
iter,
|
|
||||||
prev: None,
|
|
||||||
next: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<I, T> Iterator for TupleWindow<I, T>
|
|
||||||
where
|
|
||||||
I: Iterator<Item = T>,
|
|
||||||
{
|
|
||||||
type Item = T;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
if self.prev.is_none() {
|
|
||||||
self.prev = self.iter.next();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
template.next() {
|
|
||||||
template.flat_map(|y|
|
|
||||||
let z = rules[xy];
|
|
||||||
res[i * 2] = xy[0];
|
|
||||||
res[i * 2 + 1] = z;
|
|
||||||
res[i * 2 + 2] = xy[1];
|
|
||||||
});
|
|
||||||
//dbg!(String::from_utf8_lossy(&res));
|
|
||||||
res
|
|
||||||
*/
|
|
||||||
|
|
||||||
if let Some(next) = self.iter.next() {
|
|
||||||
let prev = self.prev.take();
|
|
||||||
self.prev = Some(next);
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expand_it<'a, I: 'a + Iterator<Item = &'a u8>>(
|
|
||||||
template: I,
|
|
||||||
rules: &HashMap<&[u8], u8>,
|
|
||||||
) -> impl Iterator<Item = &'a u8> {
|
|
||||||
TupleWindow::new(template, rules)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn forty_steps<'a, I: 'a + Iterator<Item = &'a u8>>(it: I, rules: &HashMap<&[u8], u8>) -> usize {
|
|
||||||
return 0;
|
|
||||||
//let it = (1..40).fold(it, |acc, _| expand_it(acc, &rules));
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(
|
|
||||||
expand_it(it, &rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules),
|
|
||||||
&rules,
|
|
||||||
)
|
|
||||||
.count()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn expand(template: &[u8], rules: &HashMap<&[u8], u8>) -> Vec<u8> {
|
|
||||||
let mut res = vec![0u8; template.len() * 2 - 1];
|
|
||||||
template.windows(2).enumerate().for_each(|(i, xy)| {
|
|
||||||
let z = rules[xy];
|
|
||||||
res[i * 2] = xy[0];
|
|
||||||
res[i * 2 + 1] = z;
|
|
||||||
res[i * 2 + 2] = xy[1];
|
|
||||||
});
|
|
||||||
//dbg!(String::from_utf8_lossy(&res));
|
|
||||||
res
|
|
||||||
}
|
|
||||||
|
|
||||||
fn count(template: &[u8]) -> (usize, usize) {
|
|
||||||
let m = template
|
|
||||||
.iter()
|
|
||||||
.fold(HashMap::<u8, usize>::new(), |mut m, v| {
|
|
||||||
*m.entry(*v).or_insert(0) += 1;
|
|
||||||
m
|
|
||||||
});
|
|
||||||
let mut keys: Vec<_> = m.keys().collect();
|
|
||||||
keys.sort_unstable();
|
|
||||||
let mut s = "".to_string();
|
|
||||||
for k in keys {
|
|
||||||
s.push_str(&format!("{}: {} ", String::from_utf8_lossy(&[*k]), m[k]));
|
|
||||||
}
|
|
||||||
m.values()
|
|
||||||
.fold((usize::MAX, 0), |(min, max), v| (min.min(*v), max.max(*v)))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day14, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let (template, rules) = input.split_once("\n\n").unwrap();
|
|
||||||
let rules: HashMap<&[u8], u8> = rules
|
|
||||||
.lines()
|
|
||||||
.map(|l| {
|
|
||||||
let (pair, insert) = l.split_once(" -> ").unwrap();
|
|
||||||
(pair.as_bytes(), insert.as_bytes()[0])
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let mut template = template.as_bytes().to_vec();
|
|
||||||
for i in 1..11 {
|
|
||||||
template = expand(&template, &rules);
|
|
||||||
let s = String::from_utf8_lossy(&template);
|
|
||||||
count(&template);
|
|
||||||
}
|
|
||||||
let (min, max) = count(&template);
|
|
||||||
Ok(max - min)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
//#[aoc(day14, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let (template, rules) = input.split_once("\n\n").unwrap();
|
|
||||||
let rules: HashMap<&[u8], u8> = rules
|
|
||||||
.lines()
|
|
||||||
.map(|l| {
|
|
||||||
let (pair, insert) = l.split_once(" -> ").unwrap();
|
|
||||||
(pair.as_bytes(), insert.as_bytes()[0])
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let cnt = forty_steps(template.as_bytes().iter(), &rules);
|
|
||||||
dbg!(cnt);
|
|
||||||
//println!("After step {}: {}", i, String::from_utf8_lossy(&template));
|
|
||||||
//let (min, max) = count(template);
|
|
||||||
//Ok(max - min)
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
NNCB
|
|
||||||
|
|
||||||
CH -> B
|
|
||||||
HH -> N
|
|
||||||
CB -> H
|
|
||||||
NH -> C
|
|
||||||
HB -> C
|
|
||||||
HC -> B
|
|
||||||
HN -> C
|
|
||||||
NN -> C
|
|
||||||
BH -> H
|
|
||||||
NC -> B
|
|
||||||
NB -> B
|
|
||||||
BN -> B
|
|
||||||
BB -> N
|
|
||||||
BC -> B
|
|
||||||
CC -> N
|
|
||||||
CN -> C
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 1588);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
//#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
NNCB
|
|
||||||
|
|
||||||
CH -> B
|
|
||||||
HH -> N
|
|
||||||
CB -> H
|
|
||||||
NH -> C
|
|
||||||
HB -> C
|
|
||||||
HC -> B
|
|
||||||
HN -> C
|
|
||||||
NN -> C
|
|
||||||
BH -> H
|
|
||||||
NC -> B
|
|
||||||
NB -> B
|
|
||||||
BN -> B
|
|
||||||
BB -> N
|
|
||||||
BC -> B
|
|
||||||
CC -> N
|
|
||||||
CN -> C
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 2188189693529);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BB -> N BN NB BB NB NB BB
|
|
||||||
// BC -> B BB BC BN NB BB BC
|
|
||||||
// BH -> H BH HH BH HH HN NH
|
|
||||||
// BN -> B BB NB BN NB NB BB
|
|
||||||
// CB -> H CH HB \
|
|
||||||
// CC -> N CN NC
|
|
||||||
// CH -> B CB BH
|
|
||||||
// CN -> C CC CN
|
|
||||||
// HB -> C HC CB
|
|
||||||
// HC -> B HB BC
|
|
||||||
// HH -> N HN NH
|
|
||||||
// HN -> C HC CN
|
|
||||||
// NB -> B NB BB
|
|
||||||
// NC -> B NC BC
|
|
||||||
// NH -> C NC CH
|
|
||||||
// NN -> C NC CN
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
@@ -1,272 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
struct Image {
|
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
pixels: Vec<usize>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Image {
|
|
||||||
fn new(width: usize, height: usize) -> Image {
|
|
||||||
let pixels = vec![0; width * height];
|
|
||||||
Image {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Image {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
writeln!(f)?;
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
write!(f, "{}", self[(x, y)])?;
|
|
||||||
}
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Index<(usize, usize)> for Image {
|
|
||||||
type Output = usize;
|
|
||||||
fn index(&self, (x, y): (usize, usize)) -> &Self::Output {
|
|
||||||
&self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IndexMut<(usize, usize)> for Image {
|
|
||||||
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut Self::Output {
|
|
||||||
&mut self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Image {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
let rows: Vec<_> = s.lines().collect();
|
|
||||||
let width = rows[0].len();
|
|
||||||
let height = rows.len();
|
|
||||||
let pixels = rows
|
|
||||||
.iter()
|
|
||||||
.flat_map(|row| row.as_bytes().iter().map(|b| (b - b'0') as usize))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(Image {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use std::{cmp::Ordering, collections::BinaryHeap};
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
|
||||||
struct State {
|
|
||||||
cost: usize,
|
|
||||||
position: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
// The priority queue depends on `Ord`.
|
|
||||||
// Explicitly implement the trait so the queue becomes a min-heap
|
|
||||||
// instead of a max-heap.
|
|
||||||
impl Ord for State {
|
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
|
||||||
// Notice that the we flip the ordering on costs.
|
|
||||||
// In case of a tie we compare positions - this step is necessary
|
|
||||||
// to make implementations of `PartialEq` and `Ord` consistent.
|
|
||||||
other
|
|
||||||
.cost
|
|
||||||
.cmp(&self.cost)
|
|
||||||
.then_with(|| self.position.cmp(&other.position))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// `PartialOrd` needs to be implemented as well.
|
|
||||||
impl PartialOrd for State {
|
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
||||||
Some(self.cmp(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Each node is represented as a `usize`, for a shorter implementation.
|
|
||||||
struct Edge {
|
|
||||||
node: usize,
|
|
||||||
cost: usize,
|
|
||||||
}
|
|
||||||
impl Debug for Edge {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
write!(f, "Edge{{node: {}, cost: {}}}", self.node, self.cost)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// From https://doc.rust-lang.org/std/collections/binary_heap/index.html
|
|
||||||
|
|
||||||
// Dijkstra's shortest path algorithm.
|
|
||||||
|
|
||||||
// Start at `start` and use `dist` to track the current shortest distance
|
|
||||||
// to each node. This implementation isn't memory-efficient as it may leave duplicate
|
|
||||||
// nodes in the queue. It also uses `usize::MAX` as a sentinel value,
|
|
||||||
// for a simpler implementation.
|
|
||||||
fn shortest_path(adj_list: &[Vec<Edge>], start: usize, goal: usize) -> Option<usize> {
|
|
||||||
// dist[node] = current shortest distance from `start` to `node`
|
|
||||||
let mut dist: Vec<_> = (0..adj_list.len()).map(|_| usize::MAX).collect();
|
|
||||||
|
|
||||||
let mut heap = BinaryHeap::new();
|
|
||||||
|
|
||||||
// We're at `start`, with a zero cost
|
|
||||||
dist[start] = 0;
|
|
||||||
heap.push(State {
|
|
||||||
cost: 0,
|
|
||||||
position: start,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Examine the frontier with lower cost nodes first (min-heap)
|
|
||||||
while let Some(State { cost, position }) = heap.pop() {
|
|
||||||
// Alternatively we could have continued to find all shortest paths
|
|
||||||
if position == goal {
|
|
||||||
return Some(cost);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Important as we may have already found a better way
|
|
||||||
if cost > dist[position] {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For each node we can reach, see if we can find a way with
|
|
||||||
// a lower cost going through this node
|
|
||||||
for edge in &adj_list[position] {
|
|
||||||
let next = State {
|
|
||||||
cost: cost + edge.cost,
|
|
||||||
position: edge.node,
|
|
||||||
};
|
|
||||||
|
|
||||||
// If so, add it to the frontier and continue
|
|
||||||
if next.cost < dist[next.position] {
|
|
||||||
heap.push(next);
|
|
||||||
// Relaxation, we have now found a better way
|
|
||||||
dist[next.position] = next.cost;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Goal not reachable
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn make_graph(im: &Image) -> Vec<Vec<Edge>> {
|
|
||||||
let idx = |x, y| y * im.width + x;
|
|
||||||
let mut graph: Vec<_> = Vec::new();
|
|
||||||
for y in 0..im.height {
|
|
||||||
for x in 0..im.width {
|
|
||||||
let mut edges = Vec::new();
|
|
||||||
if x > 0 {
|
|
||||||
edges.push(Edge {
|
|
||||||
node: idx(x - 1, y),
|
|
||||||
cost: im[(x - 1, y)],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if x < im.width - 1 {
|
|
||||||
edges.push(Edge {
|
|
||||||
node: idx(x + 1, y),
|
|
||||||
cost: im[(x + 1, y)],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if y > 0 {
|
|
||||||
edges.push(Edge {
|
|
||||||
node: idx(x, y - 1),
|
|
||||||
cost: im[(x, y - 1)],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if y < im.height - 1 {
|
|
||||||
edges.push(Edge {
|
|
||||||
node: idx(x, y + 1),
|
|
||||||
cost: im[(x, y + 1)],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
graph.push(edges);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
graph
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day15, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let im: Image = input.parse()?;
|
|
||||||
let graph = make_graph(&im);
|
|
||||||
Ok(shortest_path(&graph, 0, im.pixels.len() - 1).unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn x5(im: &Image) -> Image {
|
|
||||||
let mut im5 = Image::new(im.width * 5, im.height * 5);
|
|
||||||
for iy in 0..5 {
|
|
||||||
for ix in 0..5 {
|
|
||||||
for y in 0..im.height {
|
|
||||||
for x in 0..im.width {
|
|
||||||
let v = im[(x, y)] + ix + iy;
|
|
||||||
let dst_x = ix * im.width + x;
|
|
||||||
let dst_y = iy * im.height + y;
|
|
||||||
im5[(dst_x, dst_y)] = if v > 9 { v % 9 } else { v };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
im5
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day15, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let im: Image = input.parse()?;
|
|
||||||
let im = x5(&im);
|
|
||||||
let graph = make_graph(&im);
|
|
||||||
Ok(shortest_path(&graph, 0, im.pixels.len() - 1).unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
1163751742
|
|
||||||
1381373672
|
|
||||||
2136511328
|
|
||||||
3694931569
|
|
||||||
7463417111
|
|
||||||
1319128137
|
|
||||||
1359912421
|
|
||||||
3125421639
|
|
||||||
1293138521
|
|
||||||
2311944581
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 40);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
1163751742
|
|
||||||
1381373672
|
|
||||||
2136511328
|
|
||||||
3694931569
|
|
||||||
7463417111
|
|
||||||
1319128137
|
|
||||||
1359912421
|
|
||||||
3125421639
|
|
||||||
1293138521
|
|
||||||
2311944581
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 315);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
fn hex(b: &u8) -> u8 {
|
|
||||||
if *b >= b'A' {
|
|
||||||
10 + b - b'A'
|
|
||||||
} else {
|
|
||||||
b - b'0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sum_version(packet: &Packet) -> u64 {
|
|
||||||
fn sum_packets(packets: &[Packet]) -> u64 {
|
|
||||||
packets.iter().map(sum_version).sum()
|
|
||||||
}
|
|
||||||
packet.version as u64
|
|
||||||
+ match &packet.packet_type {
|
|
||||||
PacketType::Sum(packets) => sum_packets(packets),
|
|
||||||
PacketType::Product(packets) => sum_packets(packets),
|
|
||||||
PacketType::Minimum(packets) => sum_packets(packets),
|
|
||||||
PacketType::Maximum(packets) => sum_packets(packets),
|
|
||||||
PacketType::Literal(_) => 0,
|
|
||||||
PacketType::GreaterThan(packets) => sum_packets(packets),
|
|
||||||
PacketType::LessThan(packets) => sum_packets(packets),
|
|
||||||
PacketType::Equal(packets) => sum_packets(packets),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn interpret(packet: &Packet) -> u64 {
|
|
||||||
match &packet.packet_type {
|
|
||||||
PacketType::Sum(packets) => packets.iter().map(interpret).sum(),
|
|
||||||
PacketType::Product(packets) => packets.iter().map(interpret).product(),
|
|
||||||
PacketType::Minimum(packets) => packets.iter().map(interpret).min().unwrap(),
|
|
||||||
PacketType::Maximum(packets) => packets.iter().map(interpret).max().unwrap(),
|
|
||||||
PacketType::Literal(v) => *v,
|
|
||||||
PacketType::GreaterThan(packets) => {
|
|
||||||
if interpret(&packets[0]) > interpret(&packets[1]) {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PacketType::LessThan(packets) => {
|
|
||||||
if interpret(&packets[0]) < interpret(&packets[1]) {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PacketType::Equal(packets) => {
|
|
||||||
if interpret(&packets[0]) == interpret(&packets[1]) {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum PacketType {
|
|
||||||
// 0
|
|
||||||
Sum(Vec<Packet>),
|
|
||||||
// 1
|
|
||||||
Product(Vec<Packet>),
|
|
||||||
// 2
|
|
||||||
Minimum(Vec<Packet>),
|
|
||||||
// 3
|
|
||||||
Maximum(Vec<Packet>),
|
|
||||||
// 4
|
|
||||||
Literal(u64),
|
|
||||||
// 5
|
|
||||||
GreaterThan(Vec<Packet>),
|
|
||||||
// 6
|
|
||||||
LessThan(Vec<Packet>),
|
|
||||||
// 7
|
|
||||||
Equal(Vec<Packet>),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Packet {
|
|
||||||
version: u64,
|
|
||||||
bit_size: u64,
|
|
||||||
packet_type: PacketType,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Parser<'a> {
|
|
||||||
bytes: &'a [u8],
|
|
||||||
tmp: u64,
|
|
||||||
tmp_len: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Parser<'a> {
|
|
||||||
fn new(input: &str) -> Parser {
|
|
||||||
Parser {
|
|
||||||
bytes: input.as_bytes(),
|
|
||||||
tmp: 0,
|
|
||||||
tmp_len: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn read(&mut self, n: usize) -> u64 {
|
|
||||||
assert!(n < 32, "can't read more than 32 bits at time");
|
|
||||||
//print!( " BEGIN n {0} tmp 0b{1:b} len {2} - ", n, self.tmp, self.tmp_len);
|
|
||||||
while self.tmp_len < n {
|
|
||||||
let mut buf = [0; 1];
|
|
||||||
self.bytes.read_exact(&mut buf).expect("EOF");
|
|
||||||
// Convert the byte from hexdecimal to binary and merge with any leftover bits.
|
|
||||||
self.tmp = (self.tmp << 4) | hex(&buf[0]) as u64;
|
|
||||||
self.tmp_len += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mask = (1 << n) - 1;
|
|
||||||
self.tmp_len -= n;
|
|
||||||
let v = (self.tmp >> self.tmp_len) & mask;
|
|
||||||
|
|
||||||
let mask = (1 << self.tmp_len) - 1;
|
|
||||||
self.tmp &= mask;
|
|
||||||
|
|
||||||
//println!( " END n {0} tmp 0b{2:b} len {3} v 0b{1:00$b} ", n, v, self.tmp, self.tmp_len);
|
|
||||||
v as u64
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_packet(p: &mut Parser) -> Packet {
|
|
||||||
let mut bit_size: u64 = 0;
|
|
||||||
let version = p.read(3);
|
|
||||||
bit_size += 3;
|
|
||||||
let packet_type_id = p.read(3);
|
|
||||||
bit_size += 3;
|
|
||||||
let packet_type = if packet_type_id == 4 {
|
|
||||||
// Literal, read 5 bits at a time until MSB is 0
|
|
||||||
let mut v = 0;
|
|
||||||
loop {
|
|
||||||
let l = p.read(5);
|
|
||||||
v = (v << 4) | (l & 0b1111);
|
|
||||||
bit_size += 5;
|
|
||||||
if 0b10000 & l == 0 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PacketType::Literal(v)
|
|
||||||
} else {
|
|
||||||
// length type ID
|
|
||||||
let ltid = p.read(1);
|
|
||||||
bit_size += 1;
|
|
||||||
let mut packets = Vec::new();
|
|
||||||
if ltid == 0 {
|
|
||||||
// If the length type ID is 0, then the next 15 bits are a number that represents the total length in bits of the sub-packets contained by this packet.
|
|
||||||
let len = p.read(15);
|
|
||||||
bit_size += 15;
|
|
||||||
let mut sub_bits = 0;
|
|
||||||
while sub_bits < len {
|
|
||||||
let sub_p = parse_packet(p);
|
|
||||||
bit_size += sub_p.bit_size;
|
|
||||||
sub_bits += sub_p.bit_size;
|
|
||||||
packets.push(sub_p);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If the length type ID is 1, then the next 11 bits are a number that represents the number of sub-packets immediately contained by this packet.
|
|
||||||
let num = p.read(11);
|
|
||||||
bit_size += 11;
|
|
||||||
for _ in 0..num {
|
|
||||||
let sub_p = parse_packet(p);
|
|
||||||
bit_size += sub_p.bit_size;
|
|
||||||
packets.push(sub_p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
match packet_type_id {
|
|
||||||
0 => PacketType::Sum(packets),
|
|
||||||
1 => PacketType::Product(packets),
|
|
||||||
2 => PacketType::Minimum(packets),
|
|
||||||
3 => PacketType::Maximum(packets),
|
|
||||||
5 => PacketType::GreaterThan(packets),
|
|
||||||
6 => PacketType::LessThan(packets),
|
|
||||||
7 => PacketType::Equal(packets),
|
|
||||||
_ => panic!("unknown packet type ID {}", packet_type_id),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Packet {
|
|
||||||
version,
|
|
||||||
bit_size,
|
|
||||||
packet_type,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day16, part1)]
|
|
||||||
fn part1(input: &str) -> Result<u64> {
|
|
||||||
let mut p = Parser::new(input);
|
|
||||||
let packet = parse_packet(&mut p);
|
|
||||||
Ok(sum_version(&packet))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day16, part2)]
|
|
||||||
fn part2(input: &str) -> Result<u64> {
|
|
||||||
let mut p = Parser::new(input);
|
|
||||||
let packet = parse_packet(&mut p);
|
|
||||||
Ok(interpret(&packet))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = vec![
|
|
||||||
("D2FE28", 6),
|
|
||||||
//("38006F45291200", 1 + 0 + 0),
|
|
||||||
("8A004A801A8002F478", 16),
|
|
||||||
("620080001611562C8802118E34", 12),
|
|
||||||
("C0015000016115A2E0802F182340", 23),
|
|
||||||
("A0016C880162017C3686B18A3D4780", 31),
|
|
||||||
];
|
|
||||||
for (inp, want) in input {
|
|
||||||
print!("\nTesting '{}'\n - ", inp);
|
|
||||||
inp.as_bytes().iter().for_each(|c| print!("{:04b}", hex(c)));
|
|
||||||
println!();
|
|
||||||
assert_eq!(part1(inp)?, want);
|
|
||||||
println!("Passed '{}'", inp);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = vec![
|
|
||||||
("C200B40A82", 3),
|
|
||||||
("04005AC33890", 54),
|
|
||||||
("880086C3E88112", 7),
|
|
||||||
("CE00C43D881120", 9),
|
|
||||||
("D8005AC2A8F0", 1),
|
|
||||||
("F600BC2D8F", 0),
|
|
||||||
("9C005AC2F8F0", 0),
|
|
||||||
("9C0141080250320F1802104A08", 1),
|
|
||||||
];
|
|
||||||
for (inp, want) in input {
|
|
||||||
print!("\nTesting '{}'\n - ", inp);
|
|
||||||
inp.as_bytes().iter().for_each(|c| print!("{:04b}", hex(c)));
|
|
||||||
println!();
|
|
||||||
assert_eq!(part2(inp)?, want);
|
|
||||||
println!("Passed '{}'", inp);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Target {
|
|
||||||
x_min: isize,
|
|
||||||
x_max: isize,
|
|
||||||
y_min: isize,
|
|
||||||
y_max: isize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Target {
|
|
||||||
fn hit(&self, x: isize, y: isize) -> bool {
|
|
||||||
x >= self.x_min && x <= self.x_max && y >= self.y_min && y <= self.y_max
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn shoot(x: isize, y: isize, tgt: &Target) -> bool {
|
|
||||||
let mut x_inc = x;
|
|
||||||
let mut y_inc = y;
|
|
||||||
let mut x_cur = 0;
|
|
||||||
let mut y_cur = 0;
|
|
||||||
while x_cur <= tgt.x_max && y_cur >= tgt.y_min {
|
|
||||||
x_cur += x_inc;
|
|
||||||
y_cur += y_inc;
|
|
||||||
if x_inc > 0 {
|
|
||||||
x_inc -= 1;
|
|
||||||
}
|
|
||||||
y_inc -= 1;
|
|
||||||
if tgt.hit(x_cur, y_cur) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Target {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(input: &str) -> std::result::Result<Target, Infallible> {
|
|
||||||
let parts: Vec<_> = input.split(' ').collect();
|
|
||||||
let x = &parts[2][2..].strip_suffix(',').unwrap();
|
|
||||||
let y = &parts[3][2..];
|
|
||||||
let (x_min, x_max) = x
|
|
||||||
.split_once("..")
|
|
||||||
.map(|(min, max)| (min.parse().unwrap(), max.parse().unwrap()))
|
|
||||||
.unwrap();
|
|
||||||
let (y_min, y_max) = y
|
|
||||||
.split_once("..")
|
|
||||||
.map(|(min, max)| (min.parse().unwrap(), max.parse().unwrap()))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
Ok(Target {
|
|
||||||
x_min,
|
|
||||||
x_max,
|
|
||||||
y_min,
|
|
||||||
y_max,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day17, part1)]
|
|
||||||
fn part1(input: &str) -> Result<isize> {
|
|
||||||
let tgt: Target = input.parse()?;
|
|
||||||
let n = tgt.y_min.abs() - 1;
|
|
||||||
Ok(n * (n + 1) / 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day17, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let tgt: Target = input.parse()?;
|
|
||||||
let mut cnt = 0;
|
|
||||||
let y_range = tgt.y_min.abs().max(tgt.y_min.abs());
|
|
||||||
for y in -y_range..=y_range {
|
|
||||||
for x in 1..=tgt.x_max {
|
|
||||||
if shoot(x, y, &tgt) {
|
|
||||||
cnt += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(cnt)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
target area: x=20..30, y=-10..-5
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 45);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
target area: x=20..30, y=-10..-5
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 112);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,732 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
use std::{
|
|
||||||
io::{BufReader, Cursor, Read},
|
|
||||||
ops::Add,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
|
||||||
enum ChildType {
|
|
||||||
None,
|
|
||||||
Value(usize),
|
|
||||||
Subtree(Idx),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, PartialEq)]
|
|
||||||
struct Idx(usize);
|
|
||||||
|
|
||||||
impl Debug for Idx {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "{}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for Idx {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
write!(f, "{}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
|
||||||
struct Node {
|
|
||||||
deleted: bool,
|
|
||||||
idx: Idx,
|
|
||||||
parent: Option<Idx>,
|
|
||||||
left: ChildType,
|
|
||||||
right: ChildType,
|
|
||||||
}
|
|
||||||
// Tree needs to support merging two into one for adding snailfish numbers.
|
|
||||||
// Tree needs to support rightward and leftward depth first searches to find neighbors for applying
|
|
||||||
// exploded spill over.
|
|
||||||
// Need to support remove and/or replace for explode.
|
|
||||||
// Need to support insert and/or replace for split.
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct Tree {
|
|
||||||
root: Idx,
|
|
||||||
nodes: Vec<Node>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TreeIter {
|
|
||||||
it: std::vec::IntoIter<Idx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TreeIter {
|
|
||||||
fn new(indices: &[Idx]) -> TreeIter {
|
|
||||||
let indices = indices.to_vec();
|
|
||||||
TreeIter {
|
|
||||||
it: indices.into_iter(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Iterator for TreeIter {
|
|
||||||
type Item = Idx;
|
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
|
||||||
self.it.next()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for Tree {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
// Lazy but should work.
|
|
||||||
self.to_string() == other.to_string()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_byte<R: Read>(reader: &mut R) -> std::io::Result<Option<u8>> {
|
|
||||||
reader.bytes().next().transpose()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Tree {
|
|
||||||
fn reduce(&mut self) {
|
|
||||||
let mut changed = true;
|
|
||||||
while changed {
|
|
||||||
changed = self.explode();
|
|
||||||
println!("after explode {}", self);
|
|
||||||
if changed {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
changed = self.split();
|
|
||||||
println!("after split {}", self);
|
|
||||||
//println!("splice changed {}", changed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn magnitude(&self) -> usize {
|
|
||||||
fn inner(tree: &Tree, node: &Node) -> usize {
|
|
||||||
match (node.left, node.right) {
|
|
||||||
(ChildType::Value(l), ChildType::Value(r)) => 3 * l + 2 * r,
|
|
||||||
(ChildType::Subtree(idx), ChildType::Value(r)) => {
|
|
||||||
3 * inner(&tree, &tree[idx]) + 2 * r
|
|
||||||
}
|
|
||||||
(ChildType::Value(l), ChildType::Subtree(idx)) => {
|
|
||||||
3 * l + 2 * inner(&tree, &tree[idx])
|
|
||||||
}
|
|
||||||
(ChildType::Subtree(l_idx), ChildType::Subtree(r_idx)) => {
|
|
||||||
3 * inner(&tree, &tree[l_idx]) + 2 * inner(&tree, &tree[r_idx])
|
|
||||||
}
|
|
||||||
_ => panic!("unhandled combo for magnitude"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inner(self, &self[self.root])
|
|
||||||
}
|
|
||||||
|
|
||||||
fn split(&mut self) -> bool {
|
|
||||||
if let Some(split_idx) = self
|
|
||||||
.left_to_right()
|
|
||||||
.skip_while(|idx| {
|
|
||||||
let n = &self[*idx];
|
|
||||||
if let ChildType::Value(v) = n.left {
|
|
||||||
if v > 9 {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let ChildType::Value(v) = n.right {
|
|
||||||
if v > 9 {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
})
|
|
||||||
.next()
|
|
||||||
{
|
|
||||||
if let ChildType::Value(v) = self[split_idx].left {
|
|
||||||
if v > 9 {
|
|
||||||
let l = v / 2;
|
|
||||||
let r = if v % 2 == 1 { 1 + v / 2 } else { v / 2 };
|
|
||||||
let mut new_idx = self.add_node(ChildType::Value(l), ChildType::Value(r));
|
|
||||||
self[new_idx].parent = Some(split_idx);
|
|
||||||
self[split_idx].left = ChildType::Subtree(new_idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let ChildType::Value(v) = self[split_idx].right {
|
|
||||||
if v > 9 {
|
|
||||||
let l = v / 2;
|
|
||||||
let r = if v % 2 == 1 { 1 + v / 2 } else { v / 2 };
|
|
||||||
let mut new_idx = self.add_node(ChildType::Value(l), ChildType::Value(r));
|
|
||||||
self[new_idx].parent = Some(split_idx);
|
|
||||||
self[split_idx].right = ChildType::Subtree(new_idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
fn explode(&mut self) -> bool {
|
|
||||||
let mut changed = false;
|
|
||||||
if let Some(node) = self
|
|
||||||
.nodes
|
|
||||||
.iter()
|
|
||||||
.filter(|n| !n.deleted)
|
|
||||||
.find(|n| self.depth(n) >= 4)
|
|
||||||
{
|
|
||||||
changed = true;
|
|
||||||
let ex_idx = node.idx;
|
|
||||||
// Find spillover to the right
|
|
||||||
if let Some(spillover) = self
|
|
||||||
.left_to_right()
|
|
||||||
.skip_while(|idx| *idx != ex_idx)
|
|
||||||
.skip(1)
|
|
||||||
.find(|idx| {
|
|
||||||
let n = &self[*idx];
|
|
||||||
match (n.left, n.right) {
|
|
||||||
(ChildType::Subtree(_), ChildType::Subtree(_)) => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
{
|
|
||||||
let src = self[ex_idx].right;
|
|
||||||
let tgt = &mut self[spillover];
|
|
||||||
if let (ChildType::Value(l), ChildType::Value(r)) = (src, tgt.left) {
|
|
||||||
tgt.left = ChildType::Value(l + r);
|
|
||||||
} else if let (ChildType::Value(l), ChildType::Value(r)) = (src, tgt.right) {
|
|
||||||
tgt.right = ChildType::Value(l + r);
|
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// Find spillover to the left
|
|
||||||
if let Some(spillover) = self
|
|
||||||
.right_to_left()
|
|
||||||
.skip_while(|idx| *idx != ex_idx)
|
|
||||||
.skip(1)
|
|
||||||
.find(|idx| {
|
|
||||||
let n = &self[*idx];
|
|
||||||
match (n.left, n.right) {
|
|
||||||
(ChildType::Subtree(_), ChildType::Subtree(_)) => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
{
|
|
||||||
let src = self[ex_idx].left;
|
|
||||||
let tgt = &mut self[spillover];
|
|
||||||
if let (ChildType::Value(l), ChildType::Value(r)) = (src, tgt.right) {
|
|
||||||
tgt.right = ChildType::Value(l + r);
|
|
||||||
} else if let (ChildType::Value(l), ChildType::Value(r)) = (src, tgt.left) {
|
|
||||||
tgt.left = ChildType::Value(l + r);
|
|
||||||
} else {
|
|
||||||
unreachable!()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// Replace exploded node
|
|
||||||
self[ex_idx].deleted = true;
|
|
||||||
let p_idx = self[ex_idx].parent.expect("exploded root");
|
|
||||||
let p = &mut self[p_idx];
|
|
||||||
if let ChildType::Subtree(idx) = p.left {
|
|
||||||
if idx == ex_idx {
|
|
||||||
p.left = ChildType::Value(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let ChildType::Subtree(idx) = p.right {
|
|
||||||
if idx == ex_idx {
|
|
||||||
p.right = ChildType::Value(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
changed
|
|
||||||
}
|
|
||||||
fn depth(&self, node: &Node) -> usize {
|
|
||||||
if let Some(parent_idx) = node.parent {
|
|
||||||
1 + self.depth(&self[parent_idx])
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn find_root(&self, node: &Node) -> Idx {
|
|
||||||
match node.parent {
|
|
||||||
Some(parent_idx) => self.find_root(&self[parent_idx]),
|
|
||||||
None => node.idx,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn add_node(&mut self, left: ChildType, right: ChildType) -> Idx {
|
|
||||||
let idx = Idx(self.nodes.len());
|
|
||||||
self.nodes.push(Node {
|
|
||||||
deleted: false,
|
|
||||||
idx,
|
|
||||||
parent: None,
|
|
||||||
left,
|
|
||||||
right,
|
|
||||||
});
|
|
||||||
idx
|
|
||||||
}
|
|
||||||
|
|
||||||
fn from_str_node(&mut self, r: &mut BufReader<Cursor<&[u8]>>) -> ChildType {
|
|
||||||
let mut parsing_left = true;
|
|
||||||
// Can this be rewritten to eliminate the need for `None`?
|
|
||||||
let mut left = ChildType::None;
|
|
||||||
let mut right = ChildType::None;
|
|
||||||
while let Ok(Some(b)) = read_byte(r) {
|
|
||||||
match b {
|
|
||||||
b'[' => {
|
|
||||||
let node = self.from_str_node(r);
|
|
||||||
if parsing_left {
|
|
||||||
left = node;
|
|
||||||
} else {
|
|
||||||
right = node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b']' => {
|
|
||||||
let mut left_idx = None;
|
|
||||||
let mut right_idx = None;
|
|
||||||
if let ChildType::Subtree(idx) = left {
|
|
||||||
left_idx = Some(idx);
|
|
||||||
}
|
|
||||||
if let ChildType::Subtree(idx) = right {
|
|
||||||
right_idx = Some(idx);
|
|
||||||
}
|
|
||||||
let child_idx = self.add_node(left, right);
|
|
||||||
if let Some(idx) = left_idx {
|
|
||||||
self[idx].parent = Some(child_idx);
|
|
||||||
}
|
|
||||||
if let Some(idx) = right_idx {
|
|
||||||
self[idx].parent = Some(child_idx);
|
|
||||||
}
|
|
||||||
return ChildType::Subtree(child_idx);
|
|
||||||
}
|
|
||||||
b',' => parsing_left = false,
|
|
||||||
b'0'..=b'9' => {
|
|
||||||
let mut v = b - b'0';
|
|
||||||
if let Ok(Some(peek)) = read_byte(r) {
|
|
||||||
match peek {
|
|
||||||
b'0'..=b'9' => v = (peek - b'0') + 10 * v,
|
|
||||||
// Wasn't a number >9, push the byte back into the buffer.
|
|
||||||
_ => r.seek_relative(-1).expect("failed to seek"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if parsing_left {
|
|
||||||
left = ChildType::Value(v.into());
|
|
||||||
parsing_left = false;
|
|
||||||
} else {
|
|
||||||
right = ChildType::Value(v.into());
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_ => panic!("unknown byte '{}'", b),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fmt_node(&self, f: &mut Formatter<'_>, node: &Node) -> std::fmt::Result {
|
|
||||||
write!(f, "[")?;
|
|
||||||
match node.left {
|
|
||||||
ChildType::None => panic!("left node was None"),
|
|
||||||
ChildType::Value(v) => write!(f, "{}", v)?,
|
|
||||||
ChildType::Subtree(idx) => self.fmt_node(f, &self[idx])?,
|
|
||||||
};
|
|
||||||
write!(f, ",")?;
|
|
||||||
match node.right {
|
|
||||||
ChildType::None => panic!("right node was None"),
|
|
||||||
ChildType::Value(v) => write!(f, "{}", v)?,
|
|
||||||
ChildType::Subtree(idx) => self.fmt_node(f, &self[idx])?,
|
|
||||||
};
|
|
||||||
write!(f, "]")?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn left_to_right(&mut self) -> TreeIter {
|
|
||||||
fn dfs(tree: &Tree, n: &Node, mut indices: &mut Vec<Idx>) {
|
|
||||||
if let ChildType::Subtree(idx) = n.left {
|
|
||||||
dfs(tree, &tree[idx], indices);
|
|
||||||
}
|
|
||||||
indices.push(n.idx);
|
|
||||||
if let ChildType::Subtree(idx) = n.right {
|
|
||||||
dfs(tree, &tree[idx], indices);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut indices = Vec::with_capacity(self.nodes.len());
|
|
||||||
dfs(self, &self[self.root], &mut indices);
|
|
||||||
TreeIter::new(&indices)
|
|
||||||
}
|
|
||||||
fn right_to_left(&mut self) -> TreeIter {
|
|
||||||
fn dfs(tree: &Tree, n: &Node, mut indices: &mut Vec<Idx>) {
|
|
||||||
if let ChildType::Subtree(idx) = n.right {
|
|
||||||
dfs(tree, &tree[idx], indices);
|
|
||||||
}
|
|
||||||
indices.push(n.idx);
|
|
||||||
if let ChildType::Subtree(idx) = n.left {
|
|
||||||
dfs(tree, &tree[idx], indices);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let mut indices = Vec::with_capacity(self.nodes.len());
|
|
||||||
dfs(self, &self[self.root], &mut indices);
|
|
||||||
TreeIter::new(&indices)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Add for Tree {
|
|
||||||
type Output = Tree;
|
|
||||||
|
|
||||||
fn add(self, other: Self) -> Self {
|
|
||||||
// This is lazy but works for simple any obvious reasons (if FromStr and Display work
|
|
||||||
// correctly).
|
|
||||||
format!("[{},{}]", self, other)
|
|
||||||
.parse()
|
|
||||||
.expect("failed to parse merge tree")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Tree {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(input: &str) -> std::result::Result<Tree, Infallible> {
|
|
||||||
let mut tree = Tree::default();
|
|
||||||
let mut bytes = input.as_bytes();
|
|
||||||
assert_eq!(
|
|
||||||
read_byte(&mut bytes).expect("couldn't read first byte"),
|
|
||||||
Some(b'[')
|
|
||||||
);
|
|
||||||
let mut b = BufReader::new(Cursor::new(bytes));
|
|
||||||
tree.from_str_node(&mut b);
|
|
||||||
tree.root = tree.find_root(&tree[Idx(0)]);
|
|
||||||
Ok(tree)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Index<Idx> for Tree {
|
|
||||||
type Output = Node;
|
|
||||||
fn index(&self, idx: Idx) -> &Self::Output {
|
|
||||||
&self.nodes[idx.0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IndexMut<Idx> for Tree {
|
|
||||||
fn index_mut(&mut self, idx: Idx) -> &mut Self::Output {
|
|
||||||
&mut self.nodes[idx.0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for Tree {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
||||||
if self.nodes.is_empty() {
|
|
||||||
return write!(f, "[]");
|
|
||||||
}
|
|
||||||
|
|
||||||
let node = &self[self.root];
|
|
||||||
self.fmt_node(f, &node)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sum(input: &str) -> Tree {
|
|
||||||
input
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.parse().expect("failed to parse"))
|
|
||||||
.reduce(|acc, t| acc + t)
|
|
||||||
.expect("failed to reduce")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day18, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let nums: Vec<Tree> = input
|
|
||||||
.lines()
|
|
||||||
.map(|l| {
|
|
||||||
dbg!(l);
|
|
||||||
l.parse().expect("failed to parse")
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let mut it = nums.into_iter();
|
|
||||||
let mut last = it.next().unwrap();
|
|
||||||
while let Some(next) = it.next() {
|
|
||||||
println!(" {}", last);
|
|
||||||
println!("+ {}", next);
|
|
||||||
last = last + next;
|
|
||||||
println!("= {}", last);
|
|
||||||
last.reduce();
|
|
||||||
println!("= {}\n", last);
|
|
||||||
}
|
|
||||||
Ok(last.magnitude())
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[aoc(day18, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
todo!("part2");
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_display() -> Result<()> {
|
|
||||||
for (i, s) in ["[1,2]", "[[1,2],3]", "[1,[2,3]]", "[[1,2],[3,4]]"]
|
|
||||||
.into_iter()
|
|
||||||
.enumerate()
|
|
||||||
{
|
|
||||||
let t = s.parse::<Tree>()?;
|
|
||||||
assert_eq!(&t.to_string(), s, "input {}: '{}'", i, s);
|
|
||||||
//assert_eq!(&t.to_string(), s, "input {}: '{}'\ntree: {:#?}", i, s, t);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_sum() -> Result<()> {
|
|
||||||
let l: Tree = "[1,2]".parse().unwrap();
|
|
||||||
let r: Tree = "[[3,4],5]".parse().unwrap();
|
|
||||||
assert_eq!(l + r, "[[1,2],[[3,4],5]]".parse().unwrap());
|
|
||||||
|
|
||||||
let input = r#"
|
|
||||||
[[[[4,3],4],4],[7,[[8,4],9]]]
|
|
||||||
[1,1]
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
let mut s = sum(input);
|
|
||||||
s.reduce();
|
|
||||||
assert_eq!(s.to_string(), "[[[[0,7],4],[[7,8],[6,0]]],[8,1]]");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_reduce() -> Result<()> {
|
|
||||||
for (input, want) in [
|
|
||||||
("[0,[0,[0,[0,[0,0]]]]]", "[0,[0,[0,[0,0]]]]"),
|
|
||||||
("[[[[[[[[0,0],0],0],0],0],0],0],0]", "[[[[0,0],0],0],0]"),
|
|
||||||
("[[[[[[[0,0],0],0],0],0],0],0]", "[[[[0,0],0],0],0]"),
|
|
||||||
] {
|
|
||||||
println!("== test_reduce: {}", input);
|
|
||||||
let mut tree: Tree = input.parse()?;
|
|
||||||
tree.reduce();
|
|
||||||
let want = want.parse()?;
|
|
||||||
assert_eq!(tree, want, "\nInput {} Got {} Want {}", input, tree, want);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
#[test]
|
|
||||||
fn test_explode() -> Result<()> {
|
|
||||||
for (input, want) in [
|
|
||||||
("[[[[0,0],0],0],0]", "[[[[0,0],0],0],0]"),
|
|
||||||
("[[[0,0],0],0]", "[[[0,0],0],0]"),
|
|
||||||
("[[0,0],0]", "[[0,0],0]"),
|
|
||||||
("[0,[0,[0,[0,0]]]]", "[0,[0,[0,[0,0]]]]"),
|
|
||||||
("[0,[0,[0,0]]]", "[0,[0,[0,0]]]"),
|
|
||||||
("[0,[0,0]]", "[0,[0,0]]"),
|
|
||||||
("[[[[[9,8],1],2],3],4]", "[[[[0,9],2],3],4]"),
|
|
||||||
("[7,[6,[5,[4,[3,2]]]]]", "[7,[6,[5,[7,0]]]]"),
|
|
||||||
("[[6,[5,[4,[3,2]]]],1]", "[[6,[5,[7,0]]],3]"),
|
|
||||||
(
|
|
||||||
"[[3,[2,[1,[7,3]]]],[6,[5,[4,[3,2]]]]]",
|
|
||||||
"[[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[3,[2,[8,0]]],[9,[5,[4,[3,2]]]]]",
|
|
||||||
"[[3,[2,[8,0]]],[9,[5,[7,0]]]]",
|
|
||||||
),
|
|
||||||
] {
|
|
||||||
println!("== test_explode: {}", input);
|
|
||||||
let mut tree: Tree = input.parse()?;
|
|
||||||
tree.explode();
|
|
||||||
let want = want.parse()?;
|
|
||||||
assert_eq!(tree, want, "\nInput {} Got {} Want {}", input, tree, want);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_split() -> Result<()> {
|
|
||||||
for (input, want) in [
|
|
||||||
("[10,0]", "[[5,5],0]"), //
|
|
||||||
("[0,11]", "[0,[5,6]]"),
|
|
||||||
("[[0,11],0]", "[[0,[5,6]],0]"),
|
|
||||||
("[11,0]", "[[5,6],0]"),
|
|
||||||
("[0,[11,0]]", "[0,[[5,6],0]]"),
|
|
||||||
("[12,0]", "[[6,6],0]"),
|
|
||||||
("[0,12]", "[0,[6,6]]"),
|
|
||||||
] {
|
|
||||||
println!("== test_split: {}", input);
|
|
||||||
let mut tree: Tree = input.parse()?;
|
|
||||||
dbg!(&tree);
|
|
||||||
tree.split();
|
|
||||||
let want = want.parse()?;
|
|
||||||
assert_eq!(tree, want, "\nInput {} Got {} Want {}", input, tree, want);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_magnitude() -> Result<()> {
|
|
||||||
for (input, want) in [
|
|
||||||
("[9,1]", 29),
|
|
||||||
("[1,9]", 21),
|
|
||||||
("[[9,1],[1,9]]", 129),
|
|
||||||
("[[1,2],[[3,4],5]]", 143),
|
|
||||||
("[[[[0,7],4],[[7,8],[6,0]]],[8,1]]", 1384),
|
|
||||||
("[[[[1,1],[2,2]],[3,3]],[4,4]]", 445),
|
|
||||||
("[[[[3,0],[5,3]],[4,4]],[5,5]]", 791),
|
|
||||||
("[[[[5,0],[7,4]],[5,5]],[6,6]]", 1137),
|
|
||||||
(
|
|
||||||
"[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]",
|
|
||||||
3488,
|
|
||||||
),
|
|
||||||
] {
|
|
||||||
let tree: Tree = input.parse()?;
|
|
||||||
assert_eq!(tree.magnitude(), want);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_add_and_reduce() -> Result<()> {
|
|
||||||
for (input, want) in [
|
|
||||||
(
|
|
||||||
r#"
|
|
||||||
[1,1]
|
|
||||||
[2,2]
|
|
||||||
[3,3]
|
|
||||||
[4,4]
|
|
||||||
"#,
|
|
||||||
"[[[[1,1],[2,2]],[3,3]],[4,4]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r#"
|
|
||||||
[1,1]
|
|
||||||
[2,2]
|
|
||||||
[3,3]
|
|
||||||
[4,4]
|
|
||||||
[5,5]
|
|
||||||
"#
|
|
||||||
.trim(),
|
|
||||||
"[[[[3,0],[5,3]],[4,4]],[5,5]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r#"
|
|
||||||
[1,1]
|
|
||||||
[2,2]
|
|
||||||
[3,3]
|
|
||||||
[4,4]
|
|
||||||
[5,5]
|
|
||||||
[6,6]
|
|
||||||
"#
|
|
||||||
.trim(),
|
|
||||||
"[[[[5,0],[7,4]],[5,5]],[6,6]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
r#"
|
|
||||||
[[[[4,3],4],4],[7,[[8,4],9]]]
|
|
||||||
[1,1]
|
|
||||||
"#
|
|
||||||
.trim(),
|
|
||||||
"[[[[0,7],4],[[7,8],[6,0]]],[8,1]]",
|
|
||||||
),
|
|
||||||
] {
|
|
||||||
println!("== 1. test_add_and_reduce: {}", input);
|
|
||||||
let mut num = sum(input.trim());
|
|
||||||
println!("before reduce: {}", num);
|
|
||||||
num.reduce();
|
|
||||||
println!("after reduce: {}", num);
|
|
||||||
assert_eq!(num.to_string(), want);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (l, r, eq) in [
|
|
||||||
(
|
|
||||||
"[[[[4,3],4],4],[7,[[8,4],9]]]",
|
|
||||||
"[1,1]",
|
|
||||||
"[[[[0,7],4],[[7,8],[6,0]]],[8,1]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]]",
|
|
||||||
"[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]",
|
|
||||||
"[[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[4,0],[5,4]],[[7,7],[6,0]]],[[8,[7,7]],[[7,9],[5,0]]]]",
|
|
||||||
"[[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]]",
|
|
||||||
"[[[[6,7],[6,7]],[[7,7],[0,7]]],[[[8,7],[7,7]],[[8,8],[8,0]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[6,7],[6,7]],[[7,7],[0,7]]],[[[8,7],[7,7]],[[8,8],[8,0]]]]",
|
|
||||||
"[[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]]",
|
|
||||||
"[[[[7,0],[7,7]],[[7,7],[7,8]]],[[[7,7],[8,8]],[[7,7],[8,7]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[7,0],[7,7]],[[7,7],[7,8]]],[[[7,7],[8,8]],[[7,7],[8,7]]]]",
|
|
||||||
"[7,[5,[[3,8],[1,4]]]]",
|
|
||||||
"[[[[7,7],[7,8]],[[9,5],[8,7]]],[[[6,8],[0,8]],[[9,9],[9,0]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[7,7],[7,8]],[[9,5],[8,7]]],[[[6,8],[0,8]],[[9,9],[9,0]]]]",
|
|
||||||
"[[2,[2,2]],[8,[8,1]]]",
|
|
||||||
"[[[[6,6],[6,6]],[[6,0],[6,7]]],[[[7,7],[8,9]],[8,[8,1]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[6,6],[6,6]],[[6,0],[6,7]]],[[[7,7],[8,9]],[8,[8,1]]]]",
|
|
||||||
"[2,9]",
|
|
||||||
"[[[[6,6],[7,7]],[[0,7],[7,7]]],[[[5,5],[5,6]],9]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[6,6],[7,7]],[[0,7],[7,7]]],[[[5,5],[5,6]],9]]",
|
|
||||||
"[1,[[[9,3],9],[[9,0],[0,7]]]]",
|
|
||||||
"[[[[7,8],[6,7]],[[6,8],[0,8]]],[[[7,7],[5,0]],[[5,5],[5,6]]]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[7,8],[6,7]],[[6,8],[0,8]]],[[[7,7],[5,0]],[[5,5],[5,6]]]]",
|
|
||||||
"[[[5,[7,4]],7],1]",
|
|
||||||
"[[[[7,7],[7,7]],[[8,7],[8,7]]],[[[7,0],[7,7]],9]]",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"[[[[7,7],[7,7]],[[8,7],[8,7]]],[[[7,0],[7,7]],9]]",
|
|
||||||
"[[[[4,2],2],6],[8,7]]",
|
|
||||||
"[[[[8,7],[7,7]],[[8,6],[7,7]]],[[[0,7],[6,6]],[8,7]]]",
|
|
||||||
),
|
|
||||||
] {
|
|
||||||
let l: Tree = l.parse()?;
|
|
||||||
let r: Tree = r.parse()?;
|
|
||||||
let mut num = l + r;
|
|
||||||
println!("== 2. test_add_and_reduce: {}", num);
|
|
||||||
println!("before reduce: {}", num);
|
|
||||||
num.reduce();
|
|
||||||
println!("after reduce: {}", num);
|
|
||||||
assert_eq!(num.to_string(), eq);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
[[[0,[4,5]],[0,0]],[[[4,5],[2,6]],[9,5]]]
|
|
||||||
[7,[[[3,7],[4,3]],[[6,3],[8,8]]]]
|
|
||||||
[[2,[[0,8],[3,4]]],[[[6,7],1],[7,[1,6]]]]
|
|
||||||
[[[[2,4],7],[6,[0,5]]],[[[6,8],[2,8]],[[2,1],[4,5]]]]
|
|
||||||
[7,[5,[[3,8],[1,4]]]]
|
|
||||||
[[2,[2,2]],[8,[8,1]]]
|
|
||||||
[2,9]
|
|
||||||
[1,[[[9,3],9],[[9,0],[0,7]]]]
|
|
||||||
[[[5,[7,4]],7],1]
|
|
||||||
[[[[4,2],2],6],[8,7]]
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
|
|
||||||
assert_eq!(part1(input)?, 3488);
|
|
||||||
|
|
||||||
let input = r#"
|
|
||||||
[[[0,[5,8]],[[1,7],[9,6]]],[[4,[1,2]],[[1,4],2]]]
|
|
||||||
[[[5,[2,8]],4],[5,[[9,9],0]]]
|
|
||||||
[6,[[[6,2],[5,6]],[[7,6],[4,7]]]]
|
|
||||||
[[[6,[0,7]],[0,9]],[4,[9,[9,0]]]]
|
|
||||||
[[[7,[6,4]],[3,[1,3]]],[[[5,5],1],9]]
|
|
||||||
[[6,[[7,3],[3,2]]],[[[3,8],[5,7]],4]]
|
|
||||||
[[[[5,4],[7,7]],8],[[8,3],8]]
|
|
||||||
[[9,3],[[9,9],[6,[4,9]]]]
|
|
||||||
[[2,[[7,7],7]],[[5,8],[[9,3],[0,2]]]]
|
|
||||||
[[[[5,2],5],[8,[3,7]]],[[5,[7,5]],[4,4]]]
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 4140);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[test]
|
|
||||||
fn test_part2()->Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, usize::MAX);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,469 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
use std::ops::{Add, Sub};
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Default, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
|
||||||
struct Vec3([i64; 3]);
|
|
||||||
|
|
||||||
impl Add for Vec3 {
|
|
||||||
type Output = Self;
|
|
||||||
fn add(self, other: Self) -> Self::Output {
|
|
||||||
Vec3([
|
|
||||||
self.0[0] + other.0[0],
|
|
||||||
self.0[1] + other.0[1],
|
|
||||||
self.0[2] + other.0[2],
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Sub for Vec3 {
|
|
||||||
type Output = Self;
|
|
||||||
fn sub(self, other: Self) -> Self::Output {
|
|
||||||
Vec3([
|
|
||||||
self.0[0] - other.0[0],
|
|
||||||
self.0[1] - other.0[1],
|
|
||||||
self.0[2] - other.0[2],
|
|
||||||
])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Vec3 {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
write!(f, "<{:4},{:4},{:4}>", self.0[0], self.0[1], self.0[2])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Vec3 {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(input: &str) -> std::result::Result<Vec3, Infallible> {
|
|
||||||
let v: Vec<_> = input.split(',').map(|s| s.parse().unwrap()).collect();
|
|
||||||
Ok(Vec3(v.try_into().unwrap()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Scanner {
|
|
||||||
id: usize,
|
|
||||||
offset: Option<Vec3>,
|
|
||||||
points: Vec<Vec3>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Scanner {
|
|
||||||
fn translate(&mut self, distance: Vec3, orientation: [usize; 3], signs: [i64; 3]) {
|
|
||||||
for p in &mut self.points {
|
|
||||||
*p = Vec3([
|
|
||||||
signs[0] * p.0[orientation[0]] + distance.0[0],
|
|
||||||
signs[1] * p.0[orientation[1]] + distance.0[1],
|
|
||||||
signs[2] * p.0[orientation[2]] + distance.0[2],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Scanner {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(input: &str) -> std::result::Result<Scanner, Infallible> {
|
|
||||||
let mut it = input.lines();
|
|
||||||
let id = it
|
|
||||||
.next()
|
|
||||||
.unwrap()
|
|
||||||
.split(' ')
|
|
||||||
.nth(2)
|
|
||||||
.unwrap()
|
|
||||||
.parse()
|
|
||||||
.unwrap();
|
|
||||||
Ok(Scanner {
|
|
||||||
id,
|
|
||||||
offset: None,
|
|
||||||
points: it.map(|l| l.parse().unwrap()).collect(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
|
||||||
struct Match {
|
|
||||||
abs_points: Vec<Vec3>,
|
|
||||||
distance: Vec3,
|
|
||||||
orientation: [usize; 3],
|
|
||||||
signs: [i64; 3],
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns overlap, and in s1 space
|
|
||||||
fn find_overlap(s1: &Scanner, s2: &Scanner) -> Option<Match> {
|
|
||||||
let mut counts: HashMap<(Vec3, [usize; 3], [i64; 3]), Vec<Vec3>> = HashMap::new();
|
|
||||||
let orientations = [
|
|
||||||
[0, 1, 2],
|
|
||||||
[0, 2, 1],
|
|
||||||
[1, 0, 2],
|
|
||||||
[1, 2, 0],
|
|
||||||
[2, 0, 1],
|
|
||||||
[2, 1, 0],
|
|
||||||
];
|
|
||||||
let signs = [
|
|
||||||
[-1, -1, -1],
|
|
||||||
[1, -1, -1],
|
|
||||||
[-1, 1, -1],
|
|
||||||
[1, 1, -1],
|
|
||||||
[-1, -1, 1],
|
|
||||||
[1, -1, 1],
|
|
||||||
[-1, 1, 1],
|
|
||||||
];
|
|
||||||
for v1 in &s1.points {
|
|
||||||
for v2 in &s2.points {
|
|
||||||
for or in orientations {
|
|
||||||
for sign in signs {
|
|
||||||
let [x, y, z] = sign;
|
|
||||||
let v = Vec3([x * v2.0[or[0]], y * v2.0[or[1]], z * v2.0[or[2]]]);
|
|
||||||
let diff = *v1 - v;
|
|
||||||
counts.entry((diff, or, sign)).or_default().push(*v1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(((distance, orientation, signs), list)) =
|
|
||||||
counts.into_iter().find(|(_k, v)| v.len() >= 12)
|
|
||||||
{
|
|
||||||
// s1's points should already be in absolute coords. s2 will be translated in
|
|
||||||
// part1().
|
|
||||||
return Some(Match {
|
|
||||||
abs_points: list,
|
|
||||||
distance,
|
|
||||||
orientation,
|
|
||||||
signs,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse(input: &str) -> Result<Vec<Scanner>> {
|
|
||||||
input.split("\n\n").map(|s| Ok(s.parse()?)).collect()
|
|
||||||
}
|
|
||||||
#[aoc(day19, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let mut scanner = parse(input)?;
|
|
||||||
// Assign the first scanner to the origin (0,0,0).
|
|
||||||
// Put that in a list of recently registered scanners.
|
|
||||||
// In a loop
|
|
||||||
// - For each recently registered scanner, attempt to find overlap with each unregistered
|
|
||||||
// scanner.
|
|
||||||
// - Matches should be translated according to the offsets found during the match. This should
|
|
||||||
// put them in absolute space.
|
|
||||||
// - Each match should be added to the recently registered list for the next iteration.
|
|
||||||
// - Do this until all scanners are registered.
|
|
||||||
scanner[0].offset = Some(Vec3::default());
|
|
||||||
let (mut registered, mut unregistered): (VecDeque<_>, VecDeque<_>) =
|
|
||||||
scanner.into_iter().partition(|s| s.offset.is_some());
|
|
||||||
|
|
||||||
let mut becons = HashSet::new();
|
|
||||||
let mut done = Vec::new();
|
|
||||||
while let Some(reg) = registered.pop_front() {
|
|
||||||
let mut unregs = VecDeque::new();
|
|
||||||
for mut unreg in unregistered {
|
|
||||||
if let Some(mat) = find_overlap(®, &unreg) {
|
|
||||||
unreg.offset = Some(mat.distance);
|
|
||||||
unreg.translate(mat.distance, mat.orientation, mat.signs);
|
|
||||||
println!(
|
|
||||||
"scanner {} @ {:?} found {} hits",
|
|
||||||
&unreg.id,
|
|
||||||
&unreg.offset.unwrap(),
|
|
||||||
mat.abs_points.len()
|
|
||||||
);
|
|
||||||
registered.push_back(unreg);
|
|
||||||
for pt in mat.abs_points {
|
|
||||||
becons.insert(pt);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unregs.push_back(unreg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
done.push(reg);
|
|
||||||
unregistered = unregs;
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("before pass 2: {}", becons.len());
|
|
||||||
for i in 0..registered.len() {
|
|
||||||
for j in i..registered.len() {
|
|
||||||
let s1 = ®istered[i];
|
|
||||||
let s2 = ®istered[j];
|
|
||||||
if let Some(mat) = find_overlap(s1, s2) {
|
|
||||||
for pt in mat.abs_points {
|
|
||||||
becons.insert(pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("after pass 2: {}", becons.len());
|
|
||||||
|
|
||||||
//assert_eq!(done.len(), 12);
|
|
||||||
let mut becons: Vec<_> = becons.iter().collect();
|
|
||||||
becons.sort();
|
|
||||||
dbg!(&becons);
|
|
||||||
Ok(becons.len())
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[aoc(day19, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
todo!("part2");
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_overlap() -> Result<()> {
|
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
|
|
||||||
let input = r#"
|
|
||||||
--- scanner 0 ---
|
|
||||||
404,-588,-901
|
|
||||||
528,-643,409
|
|
||||||
-838,591,734
|
|
||||||
390,-675,-793
|
|
||||||
-537,-823,-458
|
|
||||||
-485,-357,347
|
|
||||||
-345,-311,381
|
|
||||||
-661,-816,-575
|
|
||||||
-876,649,763
|
|
||||||
-618,-824,-621
|
|
||||||
553,345,-567
|
|
||||||
474,580,667
|
|
||||||
-447,-329,318
|
|
||||||
-584,868,-557
|
|
||||||
544,-627,-890
|
|
||||||
564,392,-477
|
|
||||||
455,729,728
|
|
||||||
-892,524,684
|
|
||||||
-689,845,-530
|
|
||||||
423,-701,434
|
|
||||||
7,-33,-71
|
|
||||||
630,319,-379
|
|
||||||
443,580,662
|
|
||||||
-789,900,-551
|
|
||||||
459,-707,401
|
|
||||||
|
|
||||||
--- scanner 1 ---
|
|
||||||
686,422,578
|
|
||||||
605,423,415
|
|
||||||
515,917,-361
|
|
||||||
-336,658,858
|
|
||||||
95,138,22
|
|
||||||
-476,619,847
|
|
||||||
-340,-569,-846
|
|
||||||
567,-361,727
|
|
||||||
-460,603,-452
|
|
||||||
669,-402,600
|
|
||||||
729,430,532
|
|
||||||
-500,-761,534
|
|
||||||
-322,571,750
|
|
||||||
-466,-666,-811
|
|
||||||
-429,-592,574
|
|
||||||
-355,545,-477
|
|
||||||
703,-491,-529
|
|
||||||
-328,-685,520
|
|
||||||
413,935,-424
|
|
||||||
-391,539,-444
|
|
||||||
586,-435,557
|
|
||||||
-364,-763,-893
|
|
||||||
807,-499,-711
|
|
||||||
755,-354,-619
|
|
||||||
553,889,-390
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
let mut abs_points: Vec<Vec3> = r#"
|
|
||||||
-618,-824,-621
|
|
||||||
-537,-823,-458
|
|
||||||
-447,-329,318
|
|
||||||
404,-588,-901
|
|
||||||
544,-627,-890
|
|
||||||
528,-643,409
|
|
||||||
-661,-816,-575
|
|
||||||
390,-675,-793
|
|
||||||
423,-701,434
|
|
||||||
-345,-311,381
|
|
||||||
459,-707,401
|
|
||||||
-485,-357,347
|
|
||||||
"#
|
|
||||||
.trim()
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.parse().unwrap())
|
|
||||||
.collect();
|
|
||||||
abs_points.sort();
|
|
||||||
let orientation = [0, 1, 2];
|
|
||||||
let signs = [-1, 1, -1];
|
|
||||||
let distance = Vec3([68, -1246, -43]);
|
|
||||||
let want = Match {
|
|
||||||
distance,
|
|
||||||
abs_points,
|
|
||||||
orientation,
|
|
||||||
signs,
|
|
||||||
};
|
|
||||||
|
|
||||||
let scanners = parse(input)?;
|
|
||||||
let mut got = find_overlap(&scanners[0], &scanners[1]).unwrap();
|
|
||||||
got.abs_points.sort();
|
|
||||||
assert_eq!(want, got);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
--- scanner 0 ---
|
|
||||||
404,-588,-901
|
|
||||||
528,-643,409
|
|
||||||
-838,591,734
|
|
||||||
390,-675,-793
|
|
||||||
-537,-823,-458
|
|
||||||
-485,-357,347
|
|
||||||
-345,-311,381
|
|
||||||
-661,-816,-575
|
|
||||||
-876,649,763
|
|
||||||
-618,-824,-621
|
|
||||||
553,345,-567
|
|
||||||
474,580,667
|
|
||||||
-447,-329,318
|
|
||||||
-584,868,-557
|
|
||||||
544,-627,-890
|
|
||||||
564,392,-477
|
|
||||||
455,729,728
|
|
||||||
-892,524,684
|
|
||||||
-689,845,-530
|
|
||||||
423,-701,434
|
|
||||||
7,-33,-71
|
|
||||||
630,319,-379
|
|
||||||
443,580,662
|
|
||||||
-789,900,-551
|
|
||||||
459,-707,401
|
|
||||||
|
|
||||||
--- scanner 1 ---
|
|
||||||
686,422,578
|
|
||||||
605,423,415
|
|
||||||
515,917,-361
|
|
||||||
-336,658,858
|
|
||||||
95,138,22
|
|
||||||
-476,619,847
|
|
||||||
-340,-569,-846
|
|
||||||
567,-361,727
|
|
||||||
-460,603,-452
|
|
||||||
669,-402,600
|
|
||||||
729,430,532
|
|
||||||
-500,-761,534
|
|
||||||
-322,571,750
|
|
||||||
-466,-666,-811
|
|
||||||
-429,-592,574
|
|
||||||
-355,545,-477
|
|
||||||
703,-491,-529
|
|
||||||
-328,-685,520
|
|
||||||
413,935,-424
|
|
||||||
-391,539,-444
|
|
||||||
586,-435,557
|
|
||||||
-364,-763,-893
|
|
||||||
807,-499,-711
|
|
||||||
755,-354,-619
|
|
||||||
553,889,-390
|
|
||||||
|
|
||||||
--- scanner 2 ---
|
|
||||||
649,640,665
|
|
||||||
682,-795,504
|
|
||||||
-784,533,-524
|
|
||||||
-644,584,-595
|
|
||||||
-588,-843,648
|
|
||||||
-30,6,44
|
|
||||||
-674,560,763
|
|
||||||
500,723,-460
|
|
||||||
609,671,-379
|
|
||||||
-555,-800,653
|
|
||||||
-675,-892,-343
|
|
||||||
697,-426,-610
|
|
||||||
578,704,681
|
|
||||||
493,664,-388
|
|
||||||
-671,-858,530
|
|
||||||
-667,343,800
|
|
||||||
571,-461,-707
|
|
||||||
-138,-166,112
|
|
||||||
-889,563,-600
|
|
||||||
646,-828,498
|
|
||||||
640,759,510
|
|
||||||
-630,509,768
|
|
||||||
-681,-892,-333
|
|
||||||
673,-379,-804
|
|
||||||
-742,-814,-386
|
|
||||||
577,-820,562
|
|
||||||
|
|
||||||
--- scanner 3 ---
|
|
||||||
-589,542,597
|
|
||||||
605,-692,669
|
|
||||||
-500,565,-823
|
|
||||||
-660,373,557
|
|
||||||
-458,-679,-417
|
|
||||||
-488,449,543
|
|
||||||
-626,468,-788
|
|
||||||
338,-750,-386
|
|
||||||
528,-832,-391
|
|
||||||
562,-778,733
|
|
||||||
-938,-730,414
|
|
||||||
543,643,-506
|
|
||||||
-524,371,-870
|
|
||||||
407,773,750
|
|
||||||
-104,29,83
|
|
||||||
378,-903,-323
|
|
||||||
-778,-728,485
|
|
||||||
426,699,580
|
|
||||||
-438,-605,-362
|
|
||||||
-469,-447,-387
|
|
||||||
509,732,623
|
|
||||||
647,635,-688
|
|
||||||
-868,-804,481
|
|
||||||
614,-800,639
|
|
||||||
595,780,-596
|
|
||||||
|
|
||||||
--- scanner 4 ---
|
|
||||||
727,592,562
|
|
||||||
-293,-554,779
|
|
||||||
441,611,-461
|
|
||||||
-714,465,-776
|
|
||||||
-743,427,-804
|
|
||||||
-660,-479,-426
|
|
||||||
832,-632,460
|
|
||||||
927,-485,-438
|
|
||||||
408,393,-506
|
|
||||||
466,436,-512
|
|
||||||
110,16,151
|
|
||||||
-258,-428,682
|
|
||||||
-393,719,612
|
|
||||||
-211,-452,876
|
|
||||||
808,-476,-593
|
|
||||||
-575,615,604
|
|
||||||
-485,667,467
|
|
||||||
-680,325,-822
|
|
||||||
-627,-443,-432
|
|
||||||
872,-547,-609
|
|
||||||
833,512,582
|
|
||||||
807,604,487
|
|
||||||
839,-516,451
|
|
||||||
891,-625,532
|
|
||||||
-652,-548,-490
|
|
||||||
30,-46,-14
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 79);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[test]
|
|
||||||
fn test_part2()->Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, usize::MAX);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -1,199 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
use std::ops::RangeInclusive;
|
|
||||||
|
|
||||||
struct Image(HashSet<(isize, isize)>);
|
|
||||||
|
|
||||||
impl Image {
|
|
||||||
fn new(input: &str) -> Image {
|
|
||||||
let rows: Vec<_> = input.lines().collect();
|
|
||||||
let width = rows[0].len();
|
|
||||||
Image(
|
|
||||||
rows.iter()
|
|
||||||
.flat_map(|row| row.as_bytes().iter())
|
|
||||||
.enumerate()
|
|
||||||
.filter(|(_i, b)| *b == &b'#')
|
|
||||||
.map(|(i, _b)| ((i % width) as isize, (i / width) as isize))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
fn lookup(
|
|
||||||
&self,
|
|
||||||
x: isize,
|
|
||||||
y: isize,
|
|
||||||
algo: &[bool],
|
|
||||||
odd: bool,
|
|
||||||
x_rng: &RangeInclusive<isize>,
|
|
||||||
y_rng: &RangeInclusive<isize>,
|
|
||||||
) -> usize {
|
|
||||||
assert_eq!(algo.len(), 512);
|
|
||||||
let mut idx = 0;
|
|
||||||
for y_off in -1..=1 {
|
|
||||||
for x_off in -1..=1 {
|
|
||||||
let x_idx = x + x_off;
|
|
||||||
let y_idx = y + y_off;
|
|
||||||
let out_of_bounds = !(x_rng.contains(&x_idx) && y_rng.contains(&y_idx));
|
|
||||||
let val = if (odd && out_of_bounds && algo[0]) || self.0.contains(&(x_idx, y_idx)) {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
idx <<= 1;
|
|
||||||
idx |= val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
idx
|
|
||||||
}
|
|
||||||
fn extents(&self) -> (isize, isize, isize, isize) {
|
|
||||||
self.0.iter().fold(
|
|
||||||
(isize::MAX, isize::MIN, isize::MAX, isize::MIN),
|
|
||||||
|(min_x, max_x, min_y, max_y), (x, y)| {
|
|
||||||
(min_x.min(*x), max_x.max(*x), min_y.min(*y), max_y.max(*y))
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enhance(&self, algo: &[bool], odd: bool) -> Image {
|
|
||||||
let (min_x, max_x, min_y, max_y) = self.extents();
|
|
||||||
let x_rng = min_x..=max_x;
|
|
||||||
let y_rng = min_y..=max_y;
|
|
||||||
let mut new_im = HashSet::new();
|
|
||||||
for y in min_y - 1..=max_y + 1 {
|
|
||||||
for x in min_x - 1..=max_x + 1 {
|
|
||||||
let idx = self.lookup(x, y, algo, odd, &x_rng, &y_rng);
|
|
||||||
if algo[idx] {
|
|
||||||
new_im.insert((x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Image(new_im)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lights(&self) -> usize {
|
|
||||||
self.0.len()
|
|
||||||
}
|
|
||||||
fn crop(&self, min_x: isize, max_x: isize, min_y: isize, max_y: isize) -> Image {
|
|
||||||
let x_rng = min_x..=max_x;
|
|
||||||
let y_rng = min_y..=max_y;
|
|
||||||
Image(
|
|
||||||
self.0
|
|
||||||
.iter()
|
|
||||||
.filter(|(x, y)| x_rng.contains(x) && y_rng.contains(y))
|
|
||||||
.cloned()
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Image {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
let (min_x, max_x, min_y, max_y) = self.extents();
|
|
||||||
writeln!(f, "({}..{})x({}..{})", min_x, max_x, min_y, max_y)?;
|
|
||||||
for y in min_y..=max_y {
|
|
||||||
for x in min_x..=max_x {
|
|
||||||
if self.0.contains(&(x, y)) {
|
|
||||||
write!(f, "#")?;
|
|
||||||
} else {
|
|
||||||
write!(f, ".")?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn process(im: Image, algo: &[bool], num_steps: isize) -> Image {
|
|
||||||
let mut im = im;
|
|
||||||
for step in 0..num_steps {
|
|
||||||
let (min_x, max_x, min_y, max_y) = im.extents();
|
|
||||||
im = im.enhance(algo, step % 2 == 1);
|
|
||||||
im = im.crop(min_x - 1, max_x + 1, min_y - 1, max_y + 1)
|
|
||||||
}
|
|
||||||
im
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day20, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let (algo, im) = input.split_once("\n\n").unwrap();
|
|
||||||
let im = Image::new(im);
|
|
||||||
let algo: Vec<bool> = algo.as_bytes().iter().map(|c| c == &b'#').collect();
|
|
||||||
let im = process(im, &algo, 2);
|
|
||||||
|
|
||||||
dbg!(&im, im.lights());
|
|
||||||
let answer = im.lights();
|
|
||||||
assert!(answer == 5268 || answer == 35);
|
|
||||||
Ok(answer)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day20, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let (algo, im) = input.split_once("\n\n").unwrap();
|
|
||||||
let im = Image::new(im);
|
|
||||||
let algo: Vec<bool> = algo.as_bytes().iter().map(|c| c == &b'#').collect();
|
|
||||||
let im = process(im, &algo, 50);
|
|
||||||
|
|
||||||
dbg!(&im, im.lights());
|
|
||||||
let answer = im.lights();
|
|
||||||
assert!(answer < 19245);
|
|
||||||
Ok(answer)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn lookup() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
|
|
||||||
|
|
||||||
#..#.
|
|
||||||
#....
|
|
||||||
##..#
|
|
||||||
..#..
|
|
||||||
..###
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
let (algo, im) = input.split_once("\n\n").unwrap();
|
|
||||||
let im = Image::new(im);
|
|
||||||
let algo: Vec<bool> = algo.as_bytes().iter().map(|c| c == &b'#').collect();
|
|
||||||
let (min_x, max_x, min_y, max_y) = im.extents();
|
|
||||||
assert_eq!(
|
|
||||||
im.lookup(2, 2, &algo, false, &(min_x..=max_x), &(min_y..=max_y)),
|
|
||||||
34,
|
|
||||||
);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
|
|
||||||
|
|
||||||
#..#.
|
|
||||||
#....
|
|
||||||
##..#
|
|
||||||
..#..
|
|
||||||
..###
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 35);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#
|
|
||||||
|
|
||||||
#..#.
|
|
||||||
#....
|
|
||||||
##..#
|
|
||||||
..#..
|
|
||||||
..###
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 3351);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,171 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
|
||||||
struct Player {
|
|
||||||
tally: usize,
|
|
||||||
score: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Player {
|
|
||||||
fn space(&self) -> usize {
|
|
||||||
(self.tally % 10) + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
struct Die {
|
|
||||||
roll_count: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Die {
|
|
||||||
fn roll(&mut self) -> usize {
|
|
||||||
let val = (self.roll_count % 100) + 1;
|
|
||||||
self.roll_count += 1;
|
|
||||||
val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn take_turn(p: &mut Player, die: &mut Die) -> bool {
|
|
||||||
p.tally += die.roll() + die.roll() + die.roll();
|
|
||||||
p.score += p.space();
|
|
||||||
|
|
||||||
if p.score >= 1000 {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day21, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let mut p: Vec<_> = input
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split_once(": ").unwrap())
|
|
||||||
.map(|(_, space)| space.parse().expect("couldn't parse starting spaceition"))
|
|
||||||
.map(|space: usize| Player {
|
|
||||||
tally: space - 1,
|
|
||||||
score: 0,
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let mut die = Die::default();
|
|
||||||
loop {
|
|
||||||
if take_turn(&mut p[0], &mut die) {
|
|
||||||
return Ok(die.roll_count * p[1].score);
|
|
||||||
}
|
|
||||||
//println!( "Player 1 space {} for a total score of {}.", p[0].space(), p[0].score);
|
|
||||||
|
|
||||||
if take_turn(&mut p[1], &mut die) {
|
|
||||||
return Ok(die.roll_count * p[0].score);
|
|
||||||
}
|
|
||||||
//println!( "Player 2 space {} for a total score of {}.", p[1].space(), p[1].score);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn play_part2(p1: Player, p2: Player) -> (usize, usize) {
|
|
||||||
fn play_part2_rec(
|
|
||||||
mut p1: Player,
|
|
||||||
mut p2: Player,
|
|
||||||
r1: usize,
|
|
||||||
r2: usize,
|
|
||||||
r3: usize,
|
|
||||||
r4: usize,
|
|
||||||
r5: usize,
|
|
||||||
r6: usize,
|
|
||||||
) -> (usize, usize) {
|
|
||||||
//println!( "p1 {} {} p2 {} {} die {} {} {} {} {} {}", p1.score, p1.space(), p2.score, p2.space(), r1, r2, r3, r4, r5, r6,);
|
|
||||||
p1.tally += r1 + r2 + r3;
|
|
||||||
p1.score += p1.space();
|
|
||||||
if p1.score >= 21 {
|
|
||||||
return (1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
p2.tally += r4 + r5 + r6;
|
|
||||||
p2.score += p2.space();
|
|
||||||
if p2.score >= 21 {
|
|
||||||
return (0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut p1_score = 0;
|
|
||||||
let mut p2_score = 0;
|
|
||||||
|
|
||||||
for i in [1, 2, 3] {
|
|
||||||
for j in [1, 2, 3] {
|
|
||||||
for k in [1, 2, 3] {
|
|
||||||
for x in [1, 2, 3] {
|
|
||||||
for y in [1, 2, 3] {
|
|
||||||
for z in [1, 2, 3] {
|
|
||||||
let (p1s, p2s) = play_part2_rec(p1, p2, i, j, k, x, y, z);
|
|
||||||
p1_score += p1s;
|
|
||||||
p2_score += p2s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(p1_score, p2_score)
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut p1_score = 0;
|
|
||||||
let mut p2_score = 0;
|
|
||||||
|
|
||||||
for i in [1, 2, 3] {
|
|
||||||
for j in [1, 2, 3] {
|
|
||||||
for k in [1, 2, 3] {
|
|
||||||
for x in [1, 2, 3] {
|
|
||||||
for y in [1, 2, 3] {
|
|
||||||
for z in [1, 2, 3] {
|
|
||||||
let (p1s, p2s) = play_part2_rec(p1, p2, i, j, k, x, y, z);
|
|
||||||
p1_score += p1s;
|
|
||||||
p2_score += p2s;
|
|
||||||
println!("Running score {} vs {}", p1_score, p2_score);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(p1_score, p2_score)
|
|
||||||
}
|
|
||||||
|
|
||||||
//#[aoc(day21, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let p: Vec<_> = input
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.split_once(": ").unwrap())
|
|
||||||
.map(|(_, space)| space.parse().expect("couldn't parse starting spaceition"))
|
|
||||||
.map(|space: usize| Player {
|
|
||||||
tally: space - 1,
|
|
||||||
score: 0,
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
let (p1_wins, p2_wins) = play_part2(p[0], p[1]);
|
|
||||||
Ok(if p1_wins > p2_wins { p1_wins } else { p2_wins })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
Player 1 starting position: 4
|
|
||||||
Player 2 starting position: 8
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 739785);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
//#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
Player 1 starting position: 4
|
|
||||||
Player 2 starting position: 8
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 444356092776315);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Instruction {
|
|
||||||
on: bool,
|
|
||||||
x_rng: RangeInclusive<i64>,
|
|
||||||
y_rng: RangeInclusive<i64>,
|
|
||||||
z_rng: RangeInclusive<i64>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Instruction {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(input: &str) -> std::result::Result<Instruction, Infallible> {
|
|
||||||
// on x=11..13,y=11..13,z=11..13
|
|
||||||
// off x=9..11,y=9..11,z=9..11
|
|
||||||
let (verb, rest) = input.split_once(' ').unwrap();
|
|
||||||
let on = match verb {
|
|
||||||
"on" => true,
|
|
||||||
"off" => false,
|
|
||||||
_ => unreachable!("unexpected instruction type"),
|
|
||||||
};
|
|
||||||
|
|
||||||
let parts: Vec<_> = rest.split(',').collect();
|
|
||||||
let parse_rng = |s: &str| -> RangeInclusive<i64> {
|
|
||||||
s.split_once('=')
|
|
||||||
.unwrap()
|
|
||||||
.1
|
|
||||||
.split_once("..")
|
|
||||||
.map(|(lo, hi)| (lo.parse().unwrap(), hi.parse().unwrap()))
|
|
||||||
.map(|(lo, hi)| lo..=hi)
|
|
||||||
.unwrap()
|
|
||||||
};
|
|
||||||
let x_rng = parse_rng(parts[0]);
|
|
||||||
let y_rng = parse_rng(parts[1]);
|
|
||||||
let z_rng = parse_rng(parts[2]);
|
|
||||||
Ok(Instruction {
|
|
||||||
on,
|
|
||||||
x_rng,
|
|
||||||
y_rng,
|
|
||||||
z_rng,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn part1_apply(insts: Vec<Instruction>) -> usize {
|
|
||||||
let mut grid = HashSet::new();
|
|
||||||
for inst in &insts {
|
|
||||||
dbg!(&inst);
|
|
||||||
for x in inst.x_rng.clone() {
|
|
||||||
for y in inst.y_rng.clone() {
|
|
||||||
for z in inst.z_rng.clone() {
|
|
||||||
if inst.on {
|
|
||||||
grid.insert((x, y, z));
|
|
||||||
} else {
|
|
||||||
grid.remove(&(x, y, z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
grid.len()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inbounds(r: &RangeInclusive<i64>) -> bool {
|
|
||||||
// lazy but good enough for part1
|
|
||||||
r.start().abs() <= 50
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day22, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
let insts: Vec<Instruction> = input
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.parse().expect("failed to parse instruction"))
|
|
||||||
.filter(|i: &Instruction| inbounds(&i.x_rng) && inbounds(&i.y_rng) && inbounds(&i.z_rng))
|
|
||||||
.collect();
|
|
||||||
dbg!(&insts);
|
|
||||||
Ok(part1_apply(insts))
|
|
||||||
}
|
|
||||||
|
|
||||||
//#[aoc(day22, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
let insts: Vec<Instruction> = input
|
|
||||||
.lines()
|
|
||||||
.map(|l| l.parse().expect("failed to parse instruction"))
|
|
||||||
.collect();
|
|
||||||
dbg!(&insts);
|
|
||||||
for i in insts {
|
|
||||||
if i.x_rng.end()
|
|
||||||
- i.x_rng.start() * i.y_rng.end()
|
|
||||||
- i.y_rng.start() * i.z_rng.end()
|
|
||||||
- i.z_rng.start()
|
|
||||||
== 2758514936282235
|
|
||||||
{
|
|
||||||
println!("magic instructions {:?}", i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
on x=10..12,y=10..12,z=10..12
|
|
||||||
on x=11..13,y=11..13,z=11..13
|
|
||||||
off x=9..11,y=9..11,z=9..11
|
|
||||||
on x=10..10,y=10..10,z=10..10
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 39);
|
|
||||||
|
|
||||||
let input = r#"
|
|
||||||
on x=-20..26,y=-36..17,z=-47..7
|
|
||||||
on x=-20..33,y=-21..23,z=-26..28
|
|
||||||
on x=-22..28,y=-29..23,z=-38..16
|
|
||||||
on x=-46..7,y=-6..46,z=-50..-1
|
|
||||||
on x=-49..1,y=-3..46,z=-24..28
|
|
||||||
on x=2..47,y=-22..22,z=-23..27
|
|
||||||
on x=-27..23,y=-28..26,z=-21..29
|
|
||||||
on x=-39..5,y=-6..47,z=-3..44
|
|
||||||
on x=-30..21,y=-8..43,z=-13..34
|
|
||||||
on x=-22..26,y=-27..20,z=-29..19
|
|
||||||
off x=-48..-32,y=26..41,z=-47..-37
|
|
||||||
on x=-12..35,y=6..50,z=-50..-2
|
|
||||||
off x=-48..-32,y=-32..-16,z=-15..-5
|
|
||||||
on x=-18..26,y=-33..15,z=-7..46
|
|
||||||
off x=-40..-22,y=-38..-28,z=23..41
|
|
||||||
on x=-16..35,y=-41..10,z=-47..6
|
|
||||||
off x=-32..-23,y=11..30,z=-14..3
|
|
||||||
on x=-49..-5,y=-3..45,z=-29..18
|
|
||||||
off x=18..30,y=-20..-8,z=-3..13
|
|
||||||
on x=-41..9,y=-7..43,z=-33..15
|
|
||||||
on x=-54112..-39298,y=-85059..-49293,z=-27449..7877
|
|
||||||
on x=967..23432,y=45373..81175,z=27513..53682
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, 590784);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
//#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
on x=-5..47,y=-31..22,z=-19..33
|
|
||||||
on x=-44..5,y=-27..21,z=-14..35
|
|
||||||
on x=-49..-1,y=-11..42,z=-10..38
|
|
||||||
on x=-20..34,y=-40..6,z=-44..1
|
|
||||||
off x=26..39,y=40..50,z=-2..11
|
|
||||||
on x=-41..5,y=-41..6,z=-36..8
|
|
||||||
off x=-43..-33,y=-45..-28,z=7..25
|
|
||||||
on x=-33..15,y=-32..19,z=-34..11
|
|
||||||
off x=35..47,y=-46..-34,z=-11..5
|
|
||||||
on x=-14..36,y=-6..44,z=-16..29
|
|
||||||
on x=-57795..-6158,y=29564..72030,z=20435..90618
|
|
||||||
on x=36731..105352,y=-21140..28532,z=16094..90401
|
|
||||||
on x=30999..107136,y=-53464..15513,z=8553..71215
|
|
||||||
on x=13528..83982,y=-99403..-27377,z=-24141..23996
|
|
||||||
on x=-72682..-12347,y=18159..111354,z=7391..80950
|
|
||||||
on x=-1060..80757,y=-65301..-20884,z=-103788..-16709
|
|
||||||
on x=-83015..-9461,y=-72160..-8347,z=-81239..-26856
|
|
||||||
on x=-52752..22273,y=-49450..9096,z=54442..119054
|
|
||||||
on x=-29982..40483,y=-108474..-28371,z=-24328..38471
|
|
||||||
on x=-4958..62750,y=40422..118853,z=-7672..65583
|
|
||||||
on x=55694..108686,y=-43367..46958,z=-26781..48729
|
|
||||||
on x=-98497..-18186,y=-63569..3412,z=1232..88485
|
|
||||||
on x=-726..56291,y=-62629..13224,z=18033..85226
|
|
||||||
on x=-110886..-34664,y=-81338..-8658,z=8914..63723
|
|
||||||
on x=-55829..24974,y=-16897..54165,z=-121762..-28058
|
|
||||||
on x=-65152..-11147,y=22489..91432,z=-58782..1780
|
|
||||||
on x=-120100..-32970,y=-46592..27473,z=-11695..61039
|
|
||||||
on x=-18631..37533,y=-124565..-50804,z=-35667..28308
|
|
||||||
on x=-57817..18248,y=49321..117703,z=5745..55881
|
|
||||||
on x=14781..98692,y=-1341..70827,z=15753..70151
|
|
||||||
on x=-34419..55919,y=-19626..40991,z=39015..114138
|
|
||||||
on x=-60785..11593,y=-56135..2999,z=-95368..-26915
|
|
||||||
on x=-32178..58085,y=17647..101866,z=-91405..-8878
|
|
||||||
on x=-53655..12091,y=50097..105568,z=-75335..-4862
|
|
||||||
on x=-111166..-40997,y=-71714..2688,z=5609..50954
|
|
||||||
on x=-16602..70118,y=-98693..-44401,z=5197..76897
|
|
||||||
on x=16383..101554,y=4615..83635,z=-44907..18747
|
|
||||||
off x=-95822..-15171,y=-19987..48940,z=10804..104439
|
|
||||||
on x=-89813..-14614,y=16069..88491,z=-3297..45228
|
|
||||||
on x=41075..99376,y=-20427..49978,z=-52012..13762
|
|
||||||
on x=-21330..50085,y=-17944..62733,z=-112280..-30197
|
|
||||||
on x=-16478..35915,y=36008..118594,z=-7885..47086
|
|
||||||
off x=-98156..-27851,y=-49952..43171,z=-99005..-8456
|
|
||||||
off x=2032..69770,y=-71013..4824,z=7471..94418
|
|
||||||
on x=43670..120875,y=-42068..12382,z=-24787..38892
|
|
||||||
off x=37514..111226,y=-45862..25743,z=-16714..54663
|
|
||||||
off x=25699..97951,y=-30668..59918,z=-15349..69697
|
|
||||||
off x=-44271..17935,y=-9516..60759,z=49131..112598
|
|
||||||
on x=-61695..-5813,y=40978..94975,z=8655..80240
|
|
||||||
off x=-101086..-9439,y=-7088..67543,z=33935..83858
|
|
||||||
off x=18020..114017,y=-48931..32606,z=21474..89843
|
|
||||||
off x=-77139..10506,y=-89994..-18797,z=-80..59318
|
|
||||||
off x=8476..79288,y=-75520..11602,z=-96624..-24783
|
|
||||||
on x=-47488..-1262,y=24338..100707,z=16292..72967
|
|
||||||
off x=-84341..13987,y=2429..92914,z=-90671..-1318
|
|
||||||
off x=-37810..49457,y=-71013..-7894,z=-105357..-13188
|
|
||||||
off x=-27365..46395,y=31009..98017,z=15428..76570
|
|
||||||
off x=-70369..-16548,y=22648..78696,z=-1892..86821
|
|
||||||
on x=-53470..21291,y=-120233..-33476,z=-44150..38147
|
|
||||||
off x=-93533..-4276,y=-16170..68771,z=-104985..-24507
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, 2758514936282235);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
use advent::prelude::*;
|
|
||||||
use aoc_runner_derive::aoc;
|
|
||||||
|
|
||||||
#[aoc(day23, part1)]
|
|
||||||
fn part1(input: &str) -> Result<usize> {
|
|
||||||
todo!("part1");
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[aoc(day23, part2)]
|
|
||||||
fn part2(input: &str) -> Result<usize> {
|
|
||||||
todo!("part2");
|
|
||||||
Ok(0)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part1(input)?, usize::MAX);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[test]
|
|
||||||
fn test_part2()->Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
assert_eq!(part2(input)?, usize::MAX);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
@@ -161,7 +161,8 @@ impl MarkerBoard {
|
|||||||
let m = self.0;
|
let m = self.0;
|
||||||
|
|
||||||
// Bingo horizontally
|
// Bingo horizontally
|
||||||
(m & h == h)
|
false
|
||||||
|
|| (m & h == h)
|
||||||
|| ((m >> 5 & h) == h)
|
|| ((m >> 5 & h) == h)
|
||||||
|| ((m >> 10 & h) == h)
|
|| ((m >> 10 & h) == h)
|
||||||
|| ((m >> 15 & h) == h)
|
|| ((m >> 15 & h) == h)
|
||||||
|
|||||||
158
2021/src/day8.rs
158
2021/src/day8.rs
@@ -116,18 +116,12 @@
|
|||||||
//!
|
//!
|
||||||
//! For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values?
|
//! For each entry, determine all of the wire/segment connections and decode the four-digit output values. What do you get if you add up all of the output values?
|
||||||
//!
|
//!
|
||||||
use std::{
|
use std::collections::{HashMap, HashSet};
|
||||||
collections::HashMap,
|
|
||||||
convert::Infallible,
|
|
||||||
fmt::{Debug, Error, Formatter},
|
|
||||||
ops::BitAnd,
|
|
||||||
str::FromStr,
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use aoc_runner_derive::aoc;
|
use aoc_runner_derive::aoc;
|
||||||
|
|
||||||
#[aoc(day8, part1, original)]
|
#[aoc(day8, part1)]
|
||||||
fn part1(input: &str) -> Result<usize> {
|
fn part1(input: &str) -> Result<usize> {
|
||||||
Ok(input
|
Ok(input
|
||||||
.lines()
|
.lines()
|
||||||
@@ -143,128 +137,72 @@ fn part1(input: &str) -> Result<usize> {
|
|||||||
.sum())
|
.sum())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[aoc(day8, part1, no_result)]
|
fn build_lookup(input: &str) -> Result<HashMap<String, &str>> {
|
||||||
fn part1_no_result(input: &str) -> usize {
|
let mut map = HashMap::new();
|
||||||
input
|
let set: HashSet<_> = input.split(' ').collect();
|
||||||
.lines()
|
for digit in input.split(' ') {
|
||||||
.map(|l| {
|
|
||||||
l.split_once(" | ")
|
|
||||||
.unwrap()
|
|
||||||
.1
|
|
||||||
.split(' ')
|
|
||||||
// 1 | 7 | 4 | 8
|
|
||||||
.filter(|s| matches!(s.len(), 2 | 3 | 4 | 7))
|
|
||||||
.count()
|
|
||||||
})
|
|
||||||
.sum()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day8, part1, flat_map)]
|
|
||||||
fn part1_flat_map(input: &str) -> usize {
|
|
||||||
input
|
|
||||||
.lines()
|
|
||||||
.flat_map(|l| l.split_once(" | ").unwrap().1.split(' '))
|
|
||||||
// 1 | 7 | 4 | 8
|
|
||||||
.filter(|s| matches!(s.len(), 2 | 3 | 4 | 7))
|
|
||||||
.count()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day8, part1, glenng)]
|
|
||||||
fn part1_glenng(input: &str) -> usize {
|
|
||||||
input
|
|
||||||
.split('\n')
|
|
||||||
.flat_map(|line| {
|
|
||||||
let (_, output) = line.split_once(" | ").unwrap();
|
|
||||||
output.split(' ')
|
|
||||||
})
|
|
||||||
.filter(|s| [2usize, 3, 4, 7].contains(&s.len()))
|
|
||||||
.count()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, Hash, PartialEq)]
|
|
||||||
struct Segment(u8);
|
|
||||||
|
|
||||||
impl Debug for Segment {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
write!(f, "{:07b}", self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Segment {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
let mut bits = 0;
|
|
||||||
for b in s.as_bytes() {
|
|
||||||
bits |= 1 << (b - b'a');
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Segment(bits))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BitAnd for Segment {
|
|
||||||
type Output = Self;
|
|
||||||
|
|
||||||
// rhs is the "right-hand side" of the expression `a & b`
|
|
||||||
fn bitand(self, rhs: Self) -> Self::Output {
|
|
||||||
Self(self.0 & rhs.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_lookup(input: &str) -> Result<HashMap<Segment, u8>> {
|
|
||||||
let mut map: HashMap<u8, Segment> = HashMap::new();
|
|
||||||
let set: Vec<_> = input.split(' ').collect();
|
|
||||||
for digit in &set {
|
|
||||||
let s = digit.parse().unwrap();
|
|
||||||
match digit.len() {
|
match digit.len() {
|
||||||
// 1
|
// 1
|
||||||
2 => map.insert(1, s),
|
2 => map.insert("1", digit),
|
||||||
// 7
|
// 7
|
||||||
3 => map.insert(7, s),
|
3 => map.insert("7", digit),
|
||||||
// 4
|
// 4
|
||||||
4 => map.insert(4, s),
|
4 => map.insert("4", digit),
|
||||||
// 8
|
// 8
|
||||||
7 => map.insert(8, s),
|
7 => map.insert("8", digit),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let one = map[&1];
|
let one: HashSet<_> = map["1"].chars().collect();
|
||||||
let four = map[&4];
|
let four: HashSet<_> = map["4"].chars().collect();
|
||||||
|
|
||||||
|
//let seven_int: HashSet<_> = s.intersection(&seven).cloned().collect();
|
||||||
|
//let eight_int: HashSet<_> = s.intersection(&eight).cloned().collect();
|
||||||
|
|
||||||
// 0, 6 or 9 have 6 segments:
|
// 0, 6 or 9 have 6 segments:
|
||||||
// 9 contains 1 and 4
|
// 0 is missing an intersection w/ 4
|
||||||
// 0 intersects w/ 1 but not w/ 4
|
// 6 is missing an intersection w/ 1
|
||||||
// 6 is the left overs.
|
// 9 is the left overs.
|
||||||
set.iter().filter(|s| s.len() == 6).for_each(|d| {
|
set.iter().filter(|s| s.len() == 6).for_each(|d| {
|
||||||
let s: Segment = d.parse().unwrap();
|
let s: HashSet<_> = d.chars().collect();
|
||||||
if s & one == one && s & four == four {
|
let one_int: HashSet<_> = s.intersection(&one).cloned().collect();
|
||||||
map.insert(9, s);
|
let four_int: HashSet<_> = s.intersection(&four).cloned().collect();
|
||||||
} else if s & one == one {
|
if one_int == one && four_int == four {
|
||||||
map.insert(0, s);
|
map.insert("9", d);
|
||||||
|
} else if one_int == one {
|
||||||
|
map.insert("0", d);
|
||||||
} else {
|
} else {
|
||||||
map.insert(6, s);
|
map.insert("6", d);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let nine = map[&9];
|
let nine: HashSet<_> = map["9"].chars().collect();
|
||||||
// 2, 3 and 5 have 5 segments:
|
// 2, 3 and 5 have 5 segments:
|
||||||
// 3 has overlap w/ 1
|
// 3 has overlap w/ 1
|
||||||
// 5 is a subset of 9
|
// 5 is a subset of 9
|
||||||
// 2 is the left overs.
|
// 2 is the left overs.
|
||||||
set.iter().filter(|s| s.len() == 5).for_each(|d| {
|
set.iter().filter(|s| s.len() == 5).for_each(|d| {
|
||||||
let s: Segment = d.parse().unwrap();
|
let s: HashSet<_> = d.chars().collect();
|
||||||
if s & one == one {
|
let one_int: HashSet<_> = s.intersection(&one).cloned().collect();
|
||||||
map.insert(3, s);
|
let nine_int: HashSet<_> = s.intersection(&nine).cloned().collect();
|
||||||
} else if s & nine == s {
|
if one_int == one {
|
||||||
map.insert(5, s);
|
map.insert("3", d);
|
||||||
|
} else if nine_int == s {
|
||||||
|
map.insert("5", d);
|
||||||
} else {
|
} else {
|
||||||
map.insert(2, s);
|
map.insert("2", d);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Swap key/value.
|
// Sort value for use as key, and swap key/value.
|
||||||
Ok(map.into_iter().map(|(k, v)| (v, k)).collect())
|
Ok(map
|
||||||
|
.iter()
|
||||||
|
.map(|(&k, v)| {
|
||||||
|
let mut v: Vec<_> = v.chars().collect();
|
||||||
|
v.sort_unstable();
|
||||||
|
(v.iter().collect(), k)
|
||||||
|
})
|
||||||
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output(line: &str) -> Result<u64> {
|
fn output(line: &str) -> Result<u64> {
|
||||||
@@ -273,10 +211,14 @@ fn output(line: &str) -> Result<u64> {
|
|||||||
Ok(out
|
Ok(out
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(|s| {
|
.map(|s| {
|
||||||
let s: Segment = s.parse().unwrap();
|
let mut s: Vec<_> = s.chars().collect();
|
||||||
|
s.sort_unstable();
|
||||||
|
let s: String = s.iter().collect();
|
||||||
lookup[&s]
|
lookup[&s]
|
||||||
})
|
})
|
||||||
.fold(0, |answer, d| 10 * answer + d as u64))
|
.collect::<Vec<_>>()
|
||||||
|
.join("")
|
||||||
|
.parse()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[aoc(day8, part2)]
|
#[aoc(day8, part2)]
|
||||||
|
|||||||
244
2021/src/day9.rs
244
2021/src/day9.rs
@@ -1,244 +0,0 @@
|
|||||||
//! --- Day 9: Smoke Basin ---
|
|
||||||
//! These caves seem to be lava tubes. Parts are even still volcanically active; small hydrothermal vents release smoke into the caves that slowly settles like rain.
|
|
||||||
//!
|
|
||||||
//! If you can model how the smoke flows through the caves, you might be able to avoid it and be that much safer. The submarine generates a heightmap of the floor of the nearby caves for you (your puzzle input).
|
|
||||||
//!
|
|
||||||
//! Smoke flows to the lowest point of the area it's in. For example, consider the following heightmap:
|
|
||||||
//!
|
|
||||||
//! 2199943210
|
|
||||||
//! 3987894921
|
|
||||||
//! 9856789892
|
|
||||||
//! 8767896789
|
|
||||||
//! 9899965678
|
|
||||||
//! Each number corresponds to the height of a particular location, where 9 is the highest and 0 is the lowest a location can be.
|
|
||||||
//!
|
|
||||||
//! Your first goal is to find the low points - the locations that are lower than any of its adjacent locations. Most locations have four adjacent locations (up, down, left, and right); locations on the edge or corner of the map have three or two adjacent locations, respectively. (Diagonal locations do not count as adjacent.)
|
|
||||||
//!
|
|
||||||
//! In the above example, there are four low points, all highlighted: two are in the first row (a 1 and a 0), one is in the third row (a 5), and one is in the bottom row (also a 5). All other locations on the heightmap have some lower adjacent location, and so are not low points.
|
|
||||||
//!
|
|
||||||
//! The risk level of a low point is 1 plus its height. In the above example, the risk levels of the low points are 2, 1, 6, and 6. The sum of the risk levels of all low points in the heightmap is therefore 15.
|
|
||||||
//!
|
|
||||||
//! Find all of the low points on your heightmap. What is the sum of the risk levels of all low points on your heightmap?
|
|
||||||
//!
|
|
||||||
//! --- Part Two ---
|
|
||||||
//! Next, you need to find the largest basins so you know what areas are most important to avoid.
|
|
||||||
//!
|
|
||||||
//! A basin is all locations that eventually flow downward to a single low point. Therefore, every low point has a basin, although some basins are very small. Locations of height 9 do not count as being in any basin, and all other locations will always be part of exactly one basin.
|
|
||||||
//!
|
|
||||||
//! The size of a basin is the number of locations within the basin, including the low point. The example above has four basins.
|
|
||||||
//!
|
|
||||||
//! The top-left basin, size 3:
|
|
||||||
//!
|
|
||||||
//! 2199943210
|
|
||||||
//! 3987894921
|
|
||||||
//! 9856789892
|
|
||||||
//! 8767896789
|
|
||||||
//! 9899965678
|
|
||||||
//! The top-right basin, size 9:
|
|
||||||
//!
|
|
||||||
//! 2199943210
|
|
||||||
//! 3987894921
|
|
||||||
//! 9856789892
|
|
||||||
//! 8767896789
|
|
||||||
//! 9899965678
|
|
||||||
//! The middle basin, size 14:
|
|
||||||
//!
|
|
||||||
//! 2199943210
|
|
||||||
//! 3987894921
|
|
||||||
//! 9856789892
|
|
||||||
//! 8767896789
|
|
||||||
//! 9899965678
|
|
||||||
//! The bottom-right basin, size 9:
|
|
||||||
//!
|
|
||||||
//! 2199943210
|
|
||||||
//! 3987894921
|
|
||||||
//! 9856789892
|
|
||||||
//! 8767896789
|
|
||||||
//! 9899965678
|
|
||||||
//! Find the three largest basins and multiply their sizes together. In the above example, this is 9 * 14 * 9 = 1134.
|
|
||||||
//!
|
|
||||||
//! What do you get if you multiply together the sizes of the three largest basins?
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
collections::{HashSet, VecDeque},
|
|
||||||
convert::Infallible,
|
|
||||||
fmt::{Debug, Error, Formatter},
|
|
||||||
ops::Index,
|
|
||||||
str::FromStr,
|
|
||||||
};
|
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use aoc_runner_derive::{aoc, aoc_generator};
|
|
||||||
|
|
||||||
struct HeightMap {
|
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
pixels: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for HeightMap {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
write!(f, "{}", self[(x, y)])?;
|
|
||||||
}
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl HeightMap {
|
|
||||||
fn low_points(&self) -> Vec<u8> {
|
|
||||||
let mut pts = Vec::new();
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
let c = self[(x, y)];
|
|
||||||
|
|
||||||
if (x == 0 || c < self[(x - 1, y)])
|
|
||||||
&& (y == 0 || c < self[(x, y - 1)])
|
|
||||||
&& (x == self.width - 1 || c < self[(x + 1, y)])
|
|
||||||
&& (y == self.height - 1 || c < self[(x, y + 1)])
|
|
||||||
{
|
|
||||||
pts.push(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pts
|
|
||||||
}
|
|
||||||
|
|
||||||
// counts number of neighbors not 9.
|
|
||||||
fn flood_fill(&self, initial: (isize, isize), coords: &mut HashSet<(isize, isize)>) {
|
|
||||||
// This is an iterative implementation of what would be nice to do recursively. Rust
|
|
||||||
// stack overflows on the final dataset if written recursively.
|
|
||||||
let mut q = VecDeque::new();
|
|
||||||
q.push_back(initial);
|
|
||||||
while let Some((x, y)) = q.pop_front() {
|
|
||||||
// Can be negative or outside the width,height, Indeximpl will return 9.
|
|
||||||
let c = self[(x, y)] as usize;
|
|
||||||
if c == 9 {
|
|
||||||
// Don't count 9's that are neighbors and don't explore their neighbors.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if coords.insert((x, y)) {
|
|
||||||
q.push_back((x - 1, y));
|
|
||||||
q.push_back((x, y - 1));
|
|
||||||
q.push_back((x + 1, y));
|
|
||||||
q.push_back((x, y + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn basins(&self) -> Vec<usize> {
|
|
||||||
let mut bs = Vec::new();
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
let c = self[(x, y)];
|
|
||||||
|
|
||||||
if (x == 0 || c < self[(x - 1, y)])
|
|
||||||
&& (y == 0 || c < self[(x, y - 1)])
|
|
||||||
&& (x == self.width - 1 || c < self[(x + 1, y)])
|
|
||||||
&& (y == self.height - 1 || c < self[(x, y + 1)])
|
|
||||||
{
|
|
||||||
let mut coords = HashSet::new();
|
|
||||||
self.flood_fill((x as isize, y as isize), &mut coords);
|
|
||||||
bs.push(coords.len());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Index implementation that panics if x or y are greater than width or height.
|
|
||||||
impl Index<(usize, usize)> for HeightMap {
|
|
||||||
type Output = u8;
|
|
||||||
fn index(&self, (x, y): (usize, usize)) -> &Self::Output {
|
|
||||||
&self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Index implementation that returns 9 for out of range requests.
|
|
||||||
impl Index<(isize, isize)> for HeightMap {
|
|
||||||
type Output = u8;
|
|
||||||
fn index(&self, (x, y): (isize, isize)) -> &Self::Output {
|
|
||||||
if x < 0 || y < 0 || x > self.width as isize - 1 || y > self.height as isize - 1 {
|
|
||||||
return &9;
|
|
||||||
}
|
|
||||||
&self.pixels[x as usize + y as usize * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for HeightMap {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
let rows: Vec<_> = s.lines().collect();
|
|
||||||
let width = rows[0].len();
|
|
||||||
let height = rows.len();
|
|
||||||
let pixels = rows
|
|
||||||
.iter()
|
|
||||||
.flat_map(|row| row.as_bytes().iter().map(|b| b - b'0'))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(HeightMap {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc_generator(day9)]
|
|
||||||
fn parse(input: &str) -> Result<HeightMap> {
|
|
||||||
Ok(input.parse()?)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day9, part1)]
|
|
||||||
fn part1(input: &HeightMap) -> Result<u64> {
|
|
||||||
Ok(input.low_points().iter().map(|b| (*b + 1) as u64).sum())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[aoc(day9, part2)]
|
|
||||||
fn part2(hm: &HeightMap) -> Result<usize> {
|
|
||||||
let mut sizes = hm.basins();
|
|
||||||
sizes.sort_unstable();
|
|
||||||
Ok(sizes[sizes.len() - 3..].iter().product())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part1() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
2199943210
|
|
||||||
3987894921
|
|
||||||
9856789892
|
|
||||||
8767896789
|
|
||||||
9899965678
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
let hm = parse(input)?;
|
|
||||||
assert_eq!(hm.low_points(), vec![1, 0, 5, 5]);
|
|
||||||
assert_eq!(part1(&hm)?, 15);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_part2() -> Result<()> {
|
|
||||||
let input = r#"
|
|
||||||
2199943210
|
|
||||||
3987894921
|
|
||||||
9856789892
|
|
||||||
8767896789
|
|
||||||
9899965678
|
|
||||||
"#
|
|
||||||
.trim();
|
|
||||||
let hm = parse(input)?;
|
|
||||||
assert_eq!(hm.basins(), vec![3, 9, 14, 9]);
|
|
||||||
assert_eq!(part2(&hm)?, 1134);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +1,11 @@
|
|||||||
pub mod day1;
|
pub mod day1;
|
||||||
pub mod day10;
|
|
||||||
pub mod day11;
|
|
||||||
pub mod day12;
|
|
||||||
pub mod day13;
|
|
||||||
//pub mod day14;
|
|
||||||
pub mod day15;
|
|
||||||
pub mod day16;
|
|
||||||
pub mod day17;
|
|
||||||
//pub mod day18;
|
|
||||||
pub mod day19;
|
|
||||||
pub mod day2;
|
pub mod day2;
|
||||||
pub mod day20;
|
|
||||||
pub mod day21;
|
|
||||||
pub mod day22;
|
|
||||||
//pub mod day23;
|
|
||||||
pub mod day3;
|
pub mod day3;
|
||||||
pub mod day4;
|
pub mod day4;
|
||||||
pub mod day5;
|
pub mod day5;
|
||||||
pub mod day6;
|
pub mod day6;
|
||||||
pub mod day7;
|
pub mod day7;
|
||||||
pub mod day8;
|
pub mod day8;
|
||||||
pub mod day9;
|
|
||||||
|
|
||||||
use aoc_runner_derive::aoc_lib;
|
use aoc_runner_derive::aoc_lib;
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,29 @@
|
|||||||
use advent::prelude::*;
|
use std::{
|
||||||
use aoc_runner_derive::aoc;
|
fmt::{Debug, Error, Formatter},
|
||||||
|
num::ParseIntError,
|
||||||
|
ops::{Index, IndexMut},
|
||||||
|
str::FromStr,
|
||||||
|
};
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use aoc_runner_derive::{aoc, aoc_generator};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
#[aoc_generator(dayX)]
|
||||||
|
fn parse(input: &str) -> Result<Vec<u64>> {
|
||||||
|
todo!("parse");
|
||||||
|
Ok(Vec::new())
|
||||||
|
}
|
||||||
|
|
||||||
#[aoc(dayX, part1)]
|
#[aoc(dayX, part1)]
|
||||||
fn part1(input: &str) -> Result<usize> {
|
fn part1(input: &[u64]) -> Result<u64> {
|
||||||
todo!("part1");
|
todo!("part1");
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#[aoc(dayX, part2)]
|
#[aoc(dayX, part2)]
|
||||||
fn part2(input: &str) -> Result<usize> {
|
fn part2(input: &[u64]) -> Result<u64> {
|
||||||
todo!("part2");
|
todo!("part2");
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
@@ -24,7 +38,7 @@ mod tests {
|
|||||||
let input = r#"
|
let input = r#"
|
||||||
"#
|
"#
|
||||||
.trim();
|
.trim();
|
||||||
assert_eq!(part1(input)?, usize::MAX);
|
assert_eq!(part1(&parse(input)?)?, u64::MAX);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +48,7 @@ mod tests {
|
|||||||
let input = r#"
|
let input = r#"
|
||||||
"#
|
"#
|
||||||
.trim();
|
.trim();
|
||||||
assert_eq!(part2(input)?, usize::MAX);
|
assert_eq!(part2(&parse(input)?)?, u64::MAX);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|||||||
16
Cargo.toml
16
Cargo.toml
@@ -1,16 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "advent"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = "1.0.45"
|
|
||||||
aoc-runner = "0.3.0"
|
|
||||||
aoc-runner-derive = "0.3.0"
|
|
||||||
pretty_assertions = "1.0.0"
|
|
||||||
thiserror = "1.0.30"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "advent"
|
|
||||||
@@ -1,2 +1 @@
|
|||||||
imports_granularity = "Crate"
|
imports_granularity = "Crate"
|
||||||
format_code_in_doc_comments = true
|
|
||||||
|
|||||||
95
src/image.rs
95
src/image.rs
@@ -1,95 +0,0 @@
|
|||||||
use crate::prelude::*;
|
|
||||||
|
|
||||||
pub struct Image {
|
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
pixels: Vec<u8>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Image {
|
|
||||||
fn kernel3x3<F>(&mut self, (x, y): (usize, usize), func: F)
|
|
||||||
where
|
|
||||||
F: Fn(u8) -> u8,
|
|
||||||
{
|
|
||||||
if x > 0 {
|
|
||||||
self[(x - 1, y)] = func(self[(x - 1, y)]);
|
|
||||||
if y > 0 {
|
|
||||||
self[(x - 1, y - 1)] = func(self[(x - 1, y - 1)]);
|
|
||||||
}
|
|
||||||
if y < self.height - 1 {
|
|
||||||
self[(x - 1, y + 1)] = func(self[(x - 1, y + 1)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if y > 0 {
|
|
||||||
self[(x, y - 1)] = func(self[(x, y - 1)]);
|
|
||||||
}
|
|
||||||
self[(x, y)] = func(self[(x, y)]);
|
|
||||||
if y < self.height - 1 {
|
|
||||||
self[(x, y + 1)] = func(self[(x, y + 1)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if x < self.width - 1 {
|
|
||||||
self[(x + 1, y)] = func(self[(x + 1, y)]);
|
|
||||||
if y > 0 {
|
|
||||||
self[(x + 1, y - 1)] = func(self[(x + 1, y - 1)]);
|
|
||||||
}
|
|
||||||
if y < self.height - 1 {
|
|
||||||
self[(x + 1, y + 1)] = func(self[(x + 1, y + 1)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for Image {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.width == other.width && self.height == other.height && self.pixels == other.pixels
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Debug for Image {
|
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
|
|
||||||
writeln!(f)?;
|
|
||||||
for y in 0..self.height {
|
|
||||||
for x in 0..self.width {
|
|
||||||
write!(f, "{:2}", self[(x, y)] as char)?;
|
|
||||||
}
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Image {
|
|
||||||
type Err = Infallible;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
let rows: Vec<_> = s.lines().collect();
|
|
||||||
let width = rows[0].len();
|
|
||||||
let height = rows.len();
|
|
||||||
let pixels = rows
|
|
||||||
.iter()
|
|
||||||
.flat_map(|row| row.as_bytes().iter())
|
|
||||||
.map(|b| *b)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(Image {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
pixels,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Index<(usize, usize)> for Image {
|
|
||||||
type Output = u8;
|
|
||||||
fn index(&self, (x, y): (usize, usize)) -> &Self::Output {
|
|
||||||
&self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IndexMut<(usize, usize)> for Image {
|
|
||||||
fn index_mut(&mut self, (x, y): (usize, usize)) -> &mut Self::Output {
|
|
||||||
&mut self.pixels[x + y * self.width]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
18
src/lib.rs
18
src/lib.rs
@@ -1,18 +0,0 @@
|
|||||||
pub mod prelude {
|
|
||||||
pub use std::{
|
|
||||||
collections::{HashMap, HashSet, VecDeque},
|
|
||||||
convert::Infallible,
|
|
||||||
fmt::{Debug, Display, Error, Formatter},
|
|
||||||
io::Read,
|
|
||||||
num::ParseIntError,
|
|
||||||
ops::{Index, IndexMut, RangeInclusive},
|
|
||||||
str::FromStr,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub use anyhow::Result;
|
|
||||||
pub use thiserror::Error;
|
|
||||||
|
|
||||||
pub use crate::image::Image;
|
|
||||||
}
|
|
||||||
|
|
||||||
mod image;
|
|
||||||
Reference in New Issue
Block a user