Compare commits

...

49 Commits

Author SHA1 Message Date
ddcf072281 I'm not sure why I'm awake, so I'll do this tomorrow. 2024-12-07 01:57:47 -05:00
David Vereb
156f1e7dac Retried 2023 Day 1 Part 2 after Becky mentioned we never did it. It isn't optimized, but it's done. 2024-12-06 16:49:48 -05:00
David Vereb
86476f7ff0 Initial work done on part 2, but I'm not sure I'll keep the method I'm using. I might have to refactor it out into a function so that it can be called with any particular direction so that when I'm testing potential pathways I can change directions, too. 2024-12-06 16:23:50 -05:00
David Vereb
f9c90b42de Day 6 Part 1. 2024-12-06 10:07:14 -05:00
David Vereb
f0a86a6479 Day 5 Part 2. 2024-12-05 15:34:20 -05:00
David Vereb
80555c4d9c Added solution to Day 5 Part 1. 2024-12-05 09:51:02 -05:00
David Vereb
8fb1a7d95c Day 4 was MUCH easier than REGEX DAY 3. 2024-12-04 11:16:51 -05:00
David Vereb
c4d14c613d Fixed issue where newlines in the data would reset the multiplying flag. 2024-12-04 10:54:49 -05:00
David Vereb
2317ec628a Work on 3. 2024-12-03 18:10:04 -05:00
David Vereb
f3e0917a38 Oops. .end() is one past the end, so get rid of the -1. 2024-12-03 09:45:29 -05:00
David Vereb
40c9bd5e50 WIP 2024-12-02 17:47:56 -05:00
David Vereb
f7083ef726 Added some missing old files and new day2 of 2024. 2024-12-02 14:07:39 -05:00
David Vereb
450b9c790b Added 11 to repo, empty. 2022-12-20 15:46:56 -05:00
David Vereb
f80787cadb Refactored a bit to get the answer for part 2, day 10. 2022-12-20 15:30:39 -05:00
David Vereb
37c1fb045f Part 1 complete. 2022-12-20 15:10:39 -05:00
03b991a582 Added day 10, but then the queue popped in FACEIT. 2022-12-18 23:34:18 -05:00
ad3e9e42bb Added part 2. 2022-12-17 14:51:01 -05:00
68552d259d Part 1 of day 9 complete. 2022-12-17 14:02:12 -05:00
b9cb43378c Finished day 8. 2022-12-17 12:40:42 -05:00
575b9e8aed I'm not proud of this, but it works. lol. (day 8). 2022-12-11 16:59:56 -05:00
39111a9d6a Day 8 attempt 1 is proof that I should get some sleep. I totally forgot about a couple things and this is hack-n-slashed together nonsense. 2022-12-08 23:57:49 -05:00
2139a01252 Refactored #7 out into class files like I should have to begin with. 2022-12-08 23:21:16 -05:00
7ef32aafcb #7 part 2 on my first try, too. Daaaang. 2022-12-08 23:02:53 -05:00
ce7229c13c #7 part 1 works on the first try. 2022-12-08 22:52:31 -05:00
fff4541aca Starting work on #7. 2022-12-08 22:39:30 -05:00
David Vereb
b1a4398782 Added day 6 (two programs. had to rewrite for the second problem). Added starter files. 2022-12-08 08:42:07 -05:00
6b2e3aeab5 Finished part 2. 2022-12-07 21:13:01 -05:00
ada1f27620 First star of 2022 #5. 2022-12-07 21:08:09 -05:00
David Vereb
87161b6375 Added day 4, part 1 and 2. 2022-12-06 08:56:28 -05:00
David Vereb
be4347ab5f Added day 2 and 3, but didn't do them in rust like I wanted to. 2022-12-05 11:08:48 -05:00
David Vereb
209aa39edb Part one of day 2, 2022, but I don't have time to finish this at the moment. 2022-12-02 17:01:07 -05:00
David Vereb
79a6123526 2022 begins. 2022-12-01 14:11:53 -05:00
David Vereb
7717713bde Finished day 11. 2021-12-13 13:59:07 -05:00
David Vereb
4b4b083bd4 Day 10. 2021-12-10 09:10:33 -05:00
David Vereb
a31f009abe Day 9. 2021-12-09 16:53:29 -05:00
David Vereb
d4204d5c8d Commented out some testing stuff and added remainder of line to list that helps us decode. 2021-12-09 16:53:23 -05:00
443b33e863 w.i.p. 2021-12-08 22:08:19 -05:00
David Vereb
d25d35f287 d8p2 wip 2021-12-08 16:37:51 -05:00
dc6f4d995e Added a readme :) 2021-12-08 14:51:22 -05:00
David Vereb
da794f1967 Day 8 Part 1. 2021-12-08 13:50:24 -05:00
David Vereb
9c1dcaeece Day 7 2021-12-07 15:51:22 -05:00
David Vereb
dbaab6e787 Cleaned up code for part two of day 6. 2021-12-07 15:01:25 -05:00
David Vereb
35da01d66a Easier math for part 2. 2021-12-07 14:50:37 -05:00
David Vereb
ff4ebd9f66 Day 6 part 1. 2021-12-07 14:28:54 -05:00
David Vereb
81a9fdfc86 Added day 5. 2021-12-07 12:04:34 -05:00
David Vereb
e13effbe75 bugfix 2021-12-07 09:25:57 -05:00
David Vereb
db91c72db1 Finally finished the second half of day 3. 2021-12-07 09:23:03 -05:00
David Vereb
e28632c743 Merge branch 'master' of ssh://gitea.dvereb.com:1128/dvereb/Advent-of-Code 2021-12-07 08:27:41 -05:00
David Vereb
ca9f84df58 And now I'm done with the first half of day 3, though the second half will take a bit more time. 2021-12-06 15:38:56 -05:00
117 changed files with 79948 additions and 1 deletions

3
.gitignore vendored
View File

@@ -1,2 +1,3 @@
*~
*a.out
*main

98
2021/10/data Normal file
View File

@@ -0,0 +1,98 @@
{<[[<<<[[{[[<<()()>>[([]<>){{}{}}]]]<(<{{}<>}{{}{}}><{<>[]}[{}{}]>)({(())}<[(){}][(){}]>)>}]<<<(<<{}
{[({({([({(((<[]()>[()<>]){[<>[]](<>[])})<<<[]()}>(<()()>)>)}[{((<{}[]>{<>()}){[<>{}]<<><>>})(({[]()}<<>()>)<
(((([{{{<{<[[<()<>><<>{}>]]{<(<>())>}>{<[([]<>)<{}{}>][[<><>][<>[]]]>[{(<>{})[<>()]}<<()[]>[[]<
<<[<([[{{{[({<<>()>}<<<>[]>([]())>){{{{}[]}<(){}>)}]{{[(()())[(){}]]<<[]{}>({}[])>}({<<><>>}<([]<>){()[]}>)}
<[(({[({<<[[[{<>{}}(<><>))<(<>[])[{}[]]>]<[([][])[(){}]]>]([<[()()](<>[])>]<(<{}()>[{}<>])({<>[
(<[[{[[[(<((<<{}{}><[]<>>><[{}<>][<>[]]>)<(<{}<>><{}{}>)[{()[]}<<>()>]>)>[(<{({}{})}[{()[]}{[]<>}]>){<(([]
(([[({{{(<([({[]{}}){{[][]]}])>)[<([[[{}]{(){}}][([]())]]([{[][]}{<>()}](({}()){<>{}})))[{({
{(<<([([(<<[{((){})([]<>)}]<{{{}{}}{{}[]}}<{(){}}{()[]})>><([<[]{}>([]<>)](<()<>>)){<([]<>
{[<<[<{{((({<[[]{}]{{}}>{<{}<>>[<>[]]}})<{[(<><>><{}<>>][{[]{}}]}[[[[][]]<<>{}>]{[[]()][[]<>]}]>)[(
({<(<([{<{<[(((){}){(){}})]>}[{{{{()()}<[]()>}{{<>()}<{}{}>}}[[{{}{}}[<><>]]{({}[]>[[]{}]}]}({{{()()
{[[{([{<<{<(<<{}()>[()]>)<{{()()}}[<[][]>(<>{})]>>{[<{<>()){()<>}>{{()()}[<>()]}][[[{}[]]]<{{}[]}<()(
{{<<<<<[[([{<[{}[]]{()<>}>{<<>()>{{}<>}}}<<{{}()}{()()}>{[()<>]({}[])]>]{[(<{}{}>)<({}[])>]<{({}<>)}{({}())
({(<<{[<<{<(<[<>()][[][]]><[{}<>]({}[])>)[[[<>[]][[]()]]<{[]{}}[{}{}]>]>{[(<[]()>{<>{}})][<{{}}<{
(<<<[[({<[[(<<[]{}>>[(()<>)[<>{}]])<{(<>[])}(<<>()>[[]{}])>]<[({[]()}{{}{}})<{{}()}<{}<>>>]>][[({<<>()>{[]()}
{{{[<[([<(<{[([][])[{}[]]]{[()()]{{}()}}}><[<([][])(<>())><{()[]}({}<>)>]<<<(){}><<><>>>((()()){
[(((([{({<(<(<[]<>>{()[]})><{(<><>){{}[]}}{(()<>)([][])}>)>})}][({{[[{<(<><>){{}()}>((<>()){<>[]
([{<{<({(<[(<({}<>)><{[]}[{}[]]>)(<[[][]]{[]{}}>{{[]}((){})})]{(((()){{}()})(([][])({}{})))[(<()[]><(
[([{{<{(<[{{((()())<[]{}>){{{}<>}<<><>>}}[<([]())>[(()[])<{}{}>]]}{[({(){}}{(){}])<<[]()>{{}()}>
(<[<{{[<<({<<{<><>}><<()[]>[<><>]>>}{[(((){}){()<>}}<<[]()>{(){}}>]{{{{}[]}[{}<>]}[{{}{}}<(){}>]}}){{({
<([([[<[({<<{{[][]}<{}[]>}<<()[]>[()<>]>>>})((<(<[[]]((){})>{([]()){<><>}})>)(<<<<[]<>>[[]()])>>([[
[<<{<(<<{{[({<<>()><{}[]>})<{[<>()](<><>)}[{{}()}{[]()}]>]}}({<[{<()<>>}[<<>>]]((<[][]>{[][
{{(<({[((<([({()<>})[{{}[]}(()<>))]{[{[]<>}][{()<>}]})([({<><>}{{}()})])>)({<(((()<>)(<><>)))>((
[(<{({[<{<[<([{}()](<>{}))>]([([[]<>]<()<>>){<()>}]{{[[]()]{{}{}}}[{[]}{{}<>}]})>}<([<[<<>[]>]{<(){}>{
[[[[<(<({<[[<{()}{{}[]}><[<><>]<()[]>>](<([]{})[{}]>)]>}<[{[[{(){}}]{(<><>)}][<<[][]>{(){}
{(({({[{{((<[([]())((){})]>){[{(<>[])}<([]{})[[]<>]>]({<()<>>[[]<>]}[<()>{<>[]}])})({<([[][]]((){}))([<>{}])
<(<(<<{[<<{<<[()[]][[]()]><([][])<{}()>>}}>[<<<<{}<>>>{[{}][{}{}]}>[<[()()]{{}[]}>[{[][]}([])]]>[[<<[][]>(
<<{{({<<(([{{([][])(()<>)}}(<<[]{}>>)])([{[(()[])]}<{{<><>}<[]<>>}[<{}<>><[]<>)]>]{{<[{}[]]
({[[[[(([[[{<({})([]())>{{<>{}}}}][[<<[]>[<>()]>]{[[[]<>][<>{}]]{[<>[]]}})][[<(<(){}>{()[]})><[[()[
(((((([{{{(<<(<>{}){<>}><(()[])<()[]>>>{[<{}<>>(<>())}<{{}()}>})((([(){}]{<>})[{[]{}}{{}[]
(([([(((<[(({[<>()]{[][]}})[{{[]()>[[]{}]}(<<>{}><{}<>>)]){[({[]}(<>[]))([()()][<>{}])]({({}
[(<({{([[<(((<<>()>[[]<>])({{}()}<()<>>))[[{[]()}<()<>>][{()()}<{}[]>]])>({(<({}{})<()[]}>[{()
{{{[([<{{{([<<<>{}>{()<>}>{<{}()><<><>>}]([{()}]))<{[<()()>{()[]}]{({}[])[<>()]}}>}}}({<(({({
[([([<[<(<[{{{<>()}{()[]}}({()[]}[{}<>])}{[{<>}]([[][]]<(){}>)}]>[[{<[<>()][{}()]>(((){}>[<>[]])}{{{<>(
{{[{{[[<{(<([[[][]]([]<>)])>)<{<<{<>()}[<>()]><((){})<<><>>>>([<<><>>(()<>)]([(){}}{[]<>}))}>}(({{{{[]}{
[[[[({[<({{[[(<><>)]{<<>[]>([]{})}]<[{[]}{()()}]([<>()]([]<>>)>}})>{{<([{<{}{}>{()}}])({<[<>()](<><>)>
{[({<[({[{[({[{}()][[]<>]}((()<>)<{}<>>))<[{{}}({}{})]>]{[<<<>[]>[[][]]>(({}[])(()[]))>{(([]{})({}[]))([
[<<([{{(<<[<[[{}[]]](<[]{}>[<>{}])>[[<{}[]>(<>[])]{([][])[()[]]}]][[{{()[]}[<>{}]}(<<>{}>[[]
<[(([{([([<{[[(){}]<<>{}>]}[[[()()]{{}<>}]]>[[{({}{})[()()]}([()()][<>[]])]{<[[]<>][[][]]>}]]{{<{[<>
[<[[[[([[{[[<[{}{}]([]<>)>[({}[])<[]<>>]][<{()()}[<>[]]>([[]]<<><>>)]]}([<{{{}[]}}{(()<>>({}[
<[<{[(<{({[<[[[][]]([][])]<([]){{}<>}>>[({<>{}}<[]>)]]([[([]{})[[]()]][[[]{}]({}{})]](<[{}<>
({[<([(<[[<([[(){}]<<>{}>])({[[]{}]<()[]>}<<[]<>>{[][]}>)>{<[<[]()><{}[]>]([<>()]({}[]))><(
({<<<{<({[[{[{<>{}}[<><>]]}{(({})[()()])<<()<>>([]{})>}]]]{<{{([[]<>](<>[]))[[{}()]({}())]}}>((<([{}<>])>{{<[
[{([{[[{{<{<[{[]()}<[]{}>]>({<{}[]>{<>[]}})}[(({{}<>}<{}<>]){[[]{}]({}[])})]>}}]({([[([<()()>{[]
<[{([([{[{<(([<>[]]{<>()})<{{}<>}>){([<><>])<(()[])<<>{}>>}><{{[{}<>]{<>}}[(())[()<>]]}<{[{}{}]{{}{}}}<{{}<>
[{<<([{{(((<{<<>()>[{}()]}>{<<<>[]><[]()>>}){[(([][])([]()))<{{}[]}[[]()]>][[{{}<>}({}{})]{({}{})(<
{({[((<([[[{{([])[()()]}({{}{}}))<(<[]<>>[()[]])>]<<([[]<>])<[<>()][[]<>]>>({[<><>]{{}[]}}({()[]
{[(<(<{[({[(<<[]>{<>{}}>[{<><>}([]())])(<[[][]]<()<>>>[(()[])])]<{[{()[]}[<>{}]]}[{<(){}>(<>{})}<<<>()>>]
(<{<[<({{{{([({}{})[[]{}]]({{}<>}<()[]}))}(<<{<>()}{()<>}>{[<>{}][()[]]}>{<<[][]>{<>()}><(<>{})<{}[]>>})}
{(<<{[({<<[(<{{}{}}<[]<>>>((<>())([]<>)))]>><<({<{[]<>}([]<>)>{[()()]}}<<{{}<>}<()()>>(<()()
<([([<(<[({[[({}()){()<>}](({}{})(<><>))][{({}<>)<{}{}>}{([]){(){}}}]})]>)<[[{<{{(()){<>[]}}({{}()}
<<<([{[({{{((<{}()>{()()})[[<>()]])[[[{}()]<{}()>]{{[]<>}{{}())}]}<<{<<>><<><>>}[{{}[]}(<><>)
<([<[<{[[[{[{[<><>][{}<>]}(<[]{}>)]}([{{<>()}<{}[]>}{([]<>)[(){}]}]<{((){})<[]()>}[<[]()><()[]>]>
[([[[[[({{[(<[{}<>]<{}()>><[<><>]{<>()}>)]}<{(<(()<>)<{}{}>>{{()<>}(()()}})}>})(<[<([<<>[]>((){})]([[]<>]<()
{(<[[{(((([[([{}()]<{}()))[({}{}){[]}]](<<<>[]>>([<>{}]))][(<({}{})<()[]>><<[]{}><{}[]>>)])(<([([][])[
({(([{{<{{{<[<<>[]>{()<>}][([][]){()<>}]>([<()>(<><>)]<{<><>}<[]>>)}<{[[<>[]][<>{}]]<{<>()}{[][]
{[([[[(([<{<{[[]<>]<<>()>}<<()()>([]{})>>[<<()[]>(<>())>[(()<>)]]}>]{{({{{{}[]}({})}<{{}<>}[[]()]>}((
[<([[<[{{{[[[<<>{}>]{<()[]>{[]<>}}]{([[]{}]({}()))}]}}}(<{<[[({}{})<()()>]]({({}<>)[[]]}{[<><>]{<>{}}})>(<[
<<(<<{{(({<[<<[]{}>{()()}}[[()[]]]]{[(<>{}){<>}]{[{}](<>)}}><{<(()())<[]<>>>[<(){}>(<>[])]
{<(<[<[(((<{((()[])([]<>))([[]<>]({}[]))}><<([<>())<[]<>>)(<{}[]>({}<>))>[[([]())]({()()}{{}<>})
[[((<[[[{{<{<{{}()}[{}()]>{{[]{}}[<><>]}}>}<{[<[(){}]<<><>>]([{}<>]<<><>>)]}(<<[{}<>]<<>{}>
<[{{[[{<[{(({[(){}]({}{})})[([{}<>][()()])[<[][]><{}<>>]])}](<({(([]<>){()[]})[([]())((){})]}{{{<>{}}<[]()>}<
<{((<([[{<<[(<{}()><{}[]>)]>[([{<>()}<()()>]<{()[]><()[]>>){<[{}[]]>[{[][]}(<><>)]}]>{{[{{{}<>}{<>}}[[(){}]<(
{<[({(<{{[([{{[]{}}((){})}[[{}[]]<{}()>]]((<[]<>>)<([]()){{}[]}>))(<<{()[]}{[]})>[[(()())]{[()<>][<>(
<<{[[[[{<({<[[{}()]]{{[]<>}{[]}}><{{{}()}({}{})}>}{([({}[])({}())](({}[])))[<{[]<>}[<>()]><<[]<>>(<>[])>]}
[(([<<[{[{<({{()[]}<<><>>})[[([]())[[]{}])(<<>{}>)]>(<{{[][]}[{}()]}([{}{}][(){}])>((<<>[]>(()
[({<<[[<{[<<({[]()}<()<>>)>]]{{<[[[]][{}<>]]>}{([[<>{}][{}{}]]<((){})(()[])>)}}}([{((<{}[]>)[<{}[]><{}()>])}
{[[((<[{<<([{<<><>>([]{})}<(<><>)<<>()>>][{[[]{}]{()()}}<({}{})([][])>])><<{({<>{}}[<>()])((
[[[<{{(<((([{<[]{}>({}<>)}[<<>()>]]<<(()[]){{}[]}>{(()<>){{}<>}}>){{{(()())[<><>]}[[[]<>]{<>[]}]}}))[
(<({[({[[({{<{<>{}}<()[]>>[{(){}}<<>[]>]}[[<[][]><()<>>]({<>{}}{[]()})]}{(([[]<>][{}[]])(<[]<>>([
{([<{[<({{{({[[][]][()()])[<<>()><[][]>])}<{{{[]()}[{}()]}{{<>()}{<>}}}((({}())<{}{}>){(<>{})[<>{}]})>}})(((
([[[[[[{(((((<<>()>[[]<>])<{()()}[()<>]>){<[()[]]<<>[]>>(<<>{}}{{}[]})}))<<[([()()][[]()])[{()[]}([]())]][<([
({{((((<{<[{[(<>{})][<()()>[[]()]]}]{({(<>())[[]()]}{<[][]><[][]>})}>}>{<<{{(({}())[<>])((()[])<[]<>>)}}[
<(<[[[<<{([<<[[]<>]{<>[]}><{()()}([]<>)>>]{<{(<>())((){})}{[{}{}]<<>{}>}>})({([[{}{}]])[(<<>()>[
{[(<{<[[{<{{(<()[]><<>{}>){[()<>]<{}<>>}}[[[<>{}][[]<>]]]}<[[({})<<>[]>]]{{<()<>><<>[]>}<{()[]}((){}
({[{(<<{[<{({[()()]{{}}}<({}{}){()()}>)}<{(({}{})[<>[]]){([]())[[][]]}}{(<[]<>)[()])[[<>()]]}>>
(({<<[<[<<<({<{}[]>({}{})}{<{}[]><{}[]>})>>(<<(<()()>{[]{}})({()<>}[()()])>[{[{}()][[]]}({<>()}}]>(
<<(<(<[{([{<[[<>{}]<{}<>>]>{<(()[])(()())><{<>[]}{()()}>}}([{({}<>){<>{}}}{{<>[]}[{}{}]}]([<[]()>((){})
{[{([({[[<<<{{[]{}}<[]{}>}[<()[]><[]<>>]>([{{}[]][[][]]]{{(){}}({}[])})>(<{[<>{}](()<>)}>{[<[]()>
([[[<(<{[({<({()()}{<>()})((<>[])<[]<>>)>}<{<<{}()><<>>>}({{{}[]}}[(()[])[()<>]])>)<[<((()())[<>{}])(
{<(((<[((((({<[]>[[]{}]}))[(<[[][]][{}{}]>){{[<>()][[]<>]}([()()](<><>))}])){(<[{[<>()][{}()]
({([{<(((<{[<[{}[]]<<>>>({{}[]}[[]()])]([<(){}>])}{<[{<>[]}{[]<>}][<<><>){<>{}}]>[<((){})([]{})>[[{}{}][()
<[{[<[{[({{<(({}<>}[[]()])>({{[][]}}<[(){}](()[])>)}})([[{{<<>()>([]{})}[<<>{}>[<><>]]}]])]
{(<{([{[[({[(<[]{}>)({{}[]}{()()}))<{(()[])}[[()()]{{}[]}]>}<{<(()<>)>{{[]{}}({}())}}({{{}[]}{<
[<<{<{<<(<([<(<>()){[]()}>[({}<>)({}<>)]][(([]{}){()[]})[{{}()}(()())]])>{([{{()[]}<<>[]>}<{<>[
{{[[(([([({([([]<>)(()())][{<>()}{(){}}])})])]([{{[<{{{}<>}(<>())>{[()()]<<>[]>}>[{(()){{}[
[({({({(({{(<[()()][{}<>]>[[{}()]{(){}}])<[<<>[]>][<{}>(<>{})]>}(((({}())({}{}))){{(()[])<[][
<(<(<[([<[{[<(()<>)<()[]>><(<>())([][])>]{<[{}<>]{{}()}>{[[]{}](<>{})}}}<[<([]{})><{{}<>}([]())>]>]>
<<<(<<[({{{<{({}<>)<()[]>}<[()<>]{(){}}>><{[[]()]<[]{}>}[({}{})<(){}>]>}(<[<<>[]>{()[]}]>)}[<{[<{}>[{}{
{(<((<[{{[[[[<{}{}]<{}()>]][{({}{})<<>{}>}[<()[]>(()())]]]{([<[]()><[]{}>](<{}()>))({<<><>>(<>())}{
{({{[[<[{<{{(<<>>)(<[]()>[()])}([({}<>)])}[[{[()<>][()[]]}]({<[]<>>{<>()}})]><<(<<{}()>{<>[]
{{{[{[<<{[[{[{{}<>}<[][]>]{(()[])<<>()>}}[<{()()}[(){}]><<()[]>>]]{<((<>{})({}()))[<(){}>([][])]>{({{}[]}<
<{{[<{({{{[<{{<>()}{{}()}}>]<{<[()[]](<><>)><[<>[]]{(){}}>}<([(){}]<{}{}>){(())}>>}[([{[[]<>][{}<>]}[{()}(
[<<[{{(({({<{{{}{}}{<>[]}}({[][]}{<>[]})>[{[{}<>][<>[]]}[({}[])[[]<>]]]})}))<(<[[<(({}()))[<<>()>{(
{<<([<{({[{{[({}[])<<>{}>]([()<>]<(){}>)}<([{}[]]({}{}))>}[<<<<>{}>[[][]]>{<<>[]><()>}>[<<<>><[][]>
[({(<({[<[{{[<<>[]>[()[]]]<<<>[]>>}}<{([{}[]](<>{}))[{<>}{{}<>}]}(<<[][]>>[{[]<>}])>]>[(<(({<>[]}{<><>}))(<
{<[[{{<<{(<(<([]<>)[[][]]>[([]{})[<>{}]])<[{<>()}{[]<>}]>>>[{(({()()}[<>[]]){({}())<[]<>>})}[(<{<>
{[[{{{<[<[{<(({}{})[{}()])[(<><>)({}())]>}{[<{[]{}}[()[]]>]<{[()()]<[]()>}<[[][]]>>}]>{{({{{()[]}{{}(
<{[<([{{[[<(<{<><>}[{}{}]><((){})>){[[()()][()[]]]{[[]<>]}}>]<<(<({}[])<{}[]>>{(<><>)<[]()>}){(<

10
2021/10/example_data Normal file
View File

@@ -0,0 +1,10 @@
[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]

34
2021/10/main.py Normal file
View File

@@ -0,0 +1,34 @@
openers = ['(', '[', '{', '<']
closers = [')', ']', '}', '>']
points = [3, 57, 1197, 25137]
score = 0
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
stack = []
for ch in line.strip():
line_score = 0
if(ch in openers):
stack.append(ch)
elif(len(stack) == 0):
try:
i = closers.index(ch)
line_score += points[closers.index(ch)]
except ValueError: # not a closer
pass
else:
try:
i = closers.index(ch)
last = stack[-1]
stack.pop()
if(last != openers[i]):
line_score += points[i]
score += line_score
print(last, '!=', openers[i])
break
except ValueError: # not an opener or closer!
pass
score += line_score
print(score)

33
2021/10/main2.py Normal file
View File

@@ -0,0 +1,33 @@
openers = ['(', '[', '{', '<']
closers = [')', ']', '}', '>']
points = [3, 57, 1197, 25137]
scores = []
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
stack = []
corrupt = False
for ch in line.strip():
if(ch in openers):
stack.append(ch)
else:
try:
i = closers.index(ch)
last = stack[-1]
stack.pop()
if(last != openers[i]):
corrupt = True
break
except ValueError: # not an opener or closer!
pass
if(not corrupt and len(stack)):
line_score = 0
for ch in reversed(stack):
line_score *= 5
line_score += openers.index(ch) + 1
scores.append(line_score)
scores.sort()
print('scores[int(', len(scores), '/ 2 )]')
print(scores[int(len(scores) / 2)])

10
2021/11/data Normal file
View File

@@ -0,0 +1,10 @@
1254117228
4416873224
8354381553
1372637614
5586538553
7213333427
3571362825
1681126243
8718312138
5254266347

10
2021/11/example_data Normal file
View File

@@ -0,0 +1,10 @@
5483143223
2745854711
5264556173
6141336146
6357385478
4167524645
2176841721
6882881134
4846848554
5283751526

42
2021/11/main.py Normal file
View File

@@ -0,0 +1,42 @@
grid = []
to_flash = []
for line in open('data', 'r'):
grid_line = []
for ch in line.strip():
grid_line.append(int(ch))
grid.append(grid_line)
flashed = 0
for step in range(0, 100):
# Step 1: Increment
for y in range(0, len(grid)):
for x in range(0, len(grid[y])):
grid[y][x] += 1
if(grid[y][x] > 9):
to_flash.append(tuple([y, x]))
if(len(to_flash) == len(grid) * len(grid[0])):
print('all flash step #', step + 1)
# Step 2: Flash
while(len(to_flash)):
cell = to_flash[-1] # take the last one
to_flash.pop() # remove
flashed += 1 # count
for y in range(-1, 2):
new_y = cell[0] + y
if(new_y >= 0 and new_y < len(grid)): # in bounds
for x in range(-1, 2):
new_x = cell[1] + x
if(new_x >= 0 and new_x < len(grid[y])): # in bounds
grid[new_y][new_x] += 1
if(grid[new_y][new_x] == 10): # JUST flashed
to_flash.append(tuple([new_y, new_x]))
# Step 3: Reset (if flashed)
for y in range(0, len(grid)):
for x in range(0, len(grid[y])):
if(grid[y][x] > 9):
grid[y][x] = 0
print('Step #', (step + 1), ': ', flashed)

49
2021/11/main2.py Normal file
View File

@@ -0,0 +1,49 @@
grid = []
to_flash = []
for line in open('data', 'r'):
grid_line = []
for ch in line.strip():
grid_line.append(int(ch))
grid.append(grid_line)
flashed = 0
step = 0
#for step in range(0, 100):
while(True):
# Step 1: Increment
for y in range(0, len(grid)):
for x in range(0, len(grid[y])):
grid[y][x] += 1
if(grid[y][x] > 9):
to_flash.append(tuple([y, x]))
# Step 2: Flash
prior_flash = flashed
while(len(to_flash)):
cell = to_flash[-1] # take the last one
to_flash.pop() # remove
flashed += 1 # count
for y in range(-1, 2):
new_y = cell[0] + y
if(new_y >= 0 and new_y < len(grid)): # in bounds
for x in range(-1, 2):
new_x = cell[1] + x
if(new_x >= 0 and new_x < len(grid[y])): # in bounds
grid[new_y][new_x] += 1
if(grid[new_y][new_x] == 10): # JUST flashed
to_flash.append(tuple([new_y, new_x]))
# PART TWO ANSWER
if(flashed - prior_flash == len(grid) * len(grid[0])):
print('all flash step #', step + 1)
break
# Step 3: Reset (if flashed)
for y in range(0, len(grid)):
for x in range(0, len(grid[y])):
if(grid[y][x] > 9):
grid[y][x] = 0
print('Step #', (step + 1), ': ', flashed)
step += 1

102
2021/14/data Normal file
View File

@@ -0,0 +1,102 @@
ONHOOSCKBSVHBNKFKSBK
HO -> B
KB -> O
PV -> B
BV -> C
HK -> N
FK -> H
NV -> C
PF -> K
FV -> B
NH -> P
CO -> N
HV -> P
OH -> H
BC -> H
SP -> C
OK -> F
KH -> N
HB -> V
FP -> N
KP -> O
FB -> O
FH -> F
CN -> K
BP -> P
SF -> O
CK -> K
KN -> O
VK -> C
HP -> N
KK -> V
KO -> C
OO -> P
BH -> B
OC -> O
HC -> V
HS -> O
SH -> V
SO -> C
FS -> N
CH -> O
PC -> O
FC -> S
VO -> H
NS -> H
PH -> C
SS -> F
BN -> B
BF -> F
NC -> F
CS -> F
NN -> O
FF -> P
OF -> H
NF -> O
SC -> F
KC -> F
CP -> H
CF -> K
BS -> S
HN -> K
CB -> P
PB -> V
VP -> C
OS -> C
FN -> B
NB -> V
BB -> C
BK -> V
VF -> V
VC -> O
NO -> K
KF -> P
FO -> C
OB -> K
ON -> S
BO -> V
KV -> H
CC -> O
HF -> N
VS -> S
PN -> P
SK -> F
PO -> V
HH -> F
VV -> N
VH -> N
SV -> S
CV -> B
KS -> K
PS -> V
OV -> S
SB -> V
NP -> K
SN -> C
NK -> O
PK -> F
VN -> P
PP -> K
VB -> C
OP -> P

18
2021/14/example_data Normal file
View File

@@ -0,0 +1,18 @@
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

45
2021/14/main.py Normal file
View File

@@ -0,0 +1,45 @@
str = ''
data = {}
letters = []
with open('data', 'r') as fp:
for line in fp:
if(' -> ' in line):
pair = line.strip().split(' -> ')
data[pair[0]] = pair[1]
elif(len(line) > 1):
str = line.strip()
for ch in str:
if(not ch in letters):
letters.append(ch)
letters.sort()
# # DEBUG(dev):
# print(data)
# print(str)
# print(letters)
for step in range(0, 40):
print('BEFORE:', str)
new_str = ''
for i in range(0, len(str) - 1):
lookup = str[i:i+2]
print(lookup)
if(lookup in data.keys()):
new_str += str[i] + data[lookup]
else:
new_str += str[i]
new_str += str[-1]
str = new_str
counts = {}
for ch in str:
if(ch in counts):
counts[ch] += 1
else:
counts[ch] = 1
counts_list = list(counts.values())
counts_list.sort()
print(counts_list[-1] - counts_list[0])

45
2021/14/main2.py Normal file
View File

@@ -0,0 +1,45 @@
str = ''
data = {}
letters = []
with open('data', 'r') as fp:
for line in fp:
if(' -> ' in line):
pair = line.strip().split(' -> ')
data[pair[0]] = pair[1]
elif(len(line) > 1):
str = line.strip()
for ch in str:
if(not ch in letters):
letters.append(ch)
letters.sort()
# # DEBUG(dev):
# print(data)
# print(str)
# print(letters)
for step in range(0, 40):
new_str = ''
for i in range(0, len(str) - 1):
lookup = str[i:i+2]
if(lookup in data.keys()):
new_str += str[i] + data[lookup]
else:
new_str += str[i]
new_str += str[-1]
str = new_str
print('Step ', step+1, ', length', len(str))
# NOTE(dev): un-indent this (take it out of the for loop) for just a final answer
counts = {}
for ch in str:
if(ch in counts):
counts[ch] += 1
else:
counts[ch] = 1
counts_list = list(counts.values())
counts_list.sort()
print(counts_list, counts_list[-1] - counts_list[0])

100
2021/15/data Normal file
View File

@@ -0,0 +1,100 @@
9165985876154699219988192797299938946759548993842382179897895847959995468789384779887969965834298757
9998264799399739852669159899969915752881369928979589425659869512849898348591988899941938989958981368
8899439372928798295981284899995498957198997822776999766989269673341115866632499916582179985999797178
9421373314798816327241583824298987799745811978869899899899999689988933652499891999899718759652641398
9949959989598519929632977671926983547787167773939739198988988851889519228348573848979828599971727943
2989192448779756984992587956689999842746119939998567894718899918799954281648927282191699499764931166
9536499426969676189784443598979559899499773119978188394689557995599331996979736693529419681251956996
1751936936954979779895998917863998697858138691879749999727789764741997539275579593798975539798818972
7274746616894977772987689459988988891794769772199789185982726479992789563994126143759648659653627929
9768211178649269995923493912176968666679999859829913848396992289798892197419967914777851877899477278
9548265381888989898295865115497574817515178999881998168798969539989897979118423366393898169329939816
5346816194398971492996938739782725986596757996472498951666679779287752997484725936582558299359964812
2169889968977588483272986596967998729999883958728879796999737989942928997399898577324799379798165679
5756791285489939716695977945746649394898965799971791856215827997699758829299499895496993375817688889
1189911823962199612255959754716953775367595418858921381973577497988994381699599376948136788285998274
6979939299876267486998569159464199464965974658469723835541132825855912999935783995325776519991867869
7829881839997878488734339898145124968389716637926975397882799631985728918519668146942356911683694975
4973997156985297758563699888285794535932928974966978296562139199889893476728999942416259889912711471
9534797994999788999759474799734844192166842694971197691854895641895188586895455192589986798997913693
2819784988295365719599997589858664998979399989735399884134499895873389479651295996498866989999839974
6129944129969453989699888866976269999128469799982997963676678293639494188967181417362922546475281598
9716591619494494558731969871917781639763288288691962634219628479989988828962651246459129568974491171
7894482759988943587818779691955666934841799931371572868778856815865991124376396974593984947897442991
1858394839149329949299818139987736884848178995897668499996188998667699618978779495959989927996996397
9917119977481935978699197129381282957978683881779735689583195993458959989897975199999285945815997999
1699128644295779552889817864638995225998895287579281281998594696644213479297199692979781937997179875
8289472999575769888986161678994171392789714988719932799199558696689379278929798887977551878788398787
9175199787918919864185866129967892999898318993291829953849829788999738939999469848949591989149962712
6199185639948988878676462732119197225882925435874993975768952939825978994996892549999699984912695356
3396488583898545189449831859997919671368765298895692847986994925119921865818912189499168979958896494
9938398336984195997576689194134985999635325783571526493894394589917988793989755746999698829649589393
6985999497989855798918845568728129349777627978979362788359497952698956998292996918648692699694349887
1983998898992942689898989791697792913121476987631657959299998868769559979688918876893688862439185197
7357776772998794811999929459919571597899775797198394831478974157594549666253368399586349899987699999
7959339994696971922632949191545959757987989979787788169979748972545188912811999284691666989915589771
9759961834557989443271499976572889278289319995879484972649589489199519573998999779383692242897767588
9179641759649515678926897874488858988897787895855979191899776967749898123692484838554413919817918963
6839761379993114699928685489349481791394595895995488717149328139993956495742445794747189959976877649
7719888678899926948979191678165949542927483596385943836398298659699148778343914768999898197267997991
8769727958885176392169934146934172488871783986753744485932511888999799159194751538987186924419884479
8991999992999929999897984599767977994699827768813861298818993288386943869782797583698682188885283399
7618891897968939798498999399278379698962758659288163913969875574557443483997692961986999939899819481
8879168556577788339549879912587944289995777798881688244889799389891799876819699576957557971877898128
9291695492736749179768777989972456198819896897386591181956469899994155718299785968686938589318979479
7795999789358882518386787487224292238877893956695912892699678996798249199324897986249725799479399977
7157587585956489829119899759896997988918879818491999931184192141949199172799356679472486896195864474
8369998998796539973399979987949986863639829688617494995142799799778639869918868177475771699198897648
6597979998999646797717999135983617949772192975367951599248888799957499785994774771558359664883693989
8494399497884369731998936499887638658943929616778716995355827188745777858983426799559721799739362629
7988688889359569698815957687229757873596999199938929146584679599188685439814466838789683219554419476
9247298485768968989794782295879689497761879956994316114992795924987262939579993889586584967699911179
9585318399982677997578979671589977319169586337196999959189521499887711992343851295981988819951696391
9688419987598317988779256198579659993398274893319912676925791429994831998147985462785322692958417991
9162526572947889939619891135679859992512868978725888837198497899147199825914711544192984934699878858
9997992172487298739215471619688889939819838188921969391991648949979166298795194179866892977317488668
4342969513889787361777751972798659462495119377122327857968869995779944989446988786669168689799978198
9991989792887933999782849992885388199539897175961949179928388186994694998865752811971681796835228899
9689884899572994167989994913659819996941825788877898819911788969419991277989227389959829597962878797
9919879157714445923163829999735888889724892834556637899899999974386932299127993655996239789769999544
8158429263197997788393974998999939783878693949897825898975995959979986635699272784592895953298769979
6933156399191389719992767671896649494989689977121886269912939799779176467784638649979932992778611947
9937886748328953482685979758934658999819989845699372899934596991259755741819979779889881397565568579
6628287411551868899648999511774894539834357749799788481594933187788979179772699757813897655969637759
1681758889993977881987844998586378799289969999542735618971489988849699628668119898999679199493949189
7756952966791755589777886975949697297729368719914568929921989979278297994486928996985666791996513546
7959939142776881868999785876799728991368773296952962918971941199687791336941297836969992566198117899
9919799591383641992451999795686291882995991159937526287799259396499782592953878378919512331399769295
9979988697799299993248298599458499952548969526718987894849849961566959196296836979299696595499951269
8989115299788834687596939899183482448889849883899881337161943668283395379982966119363885868799817686
3917979748934696925996487991958936699899582264499928897937594999993391587881813378359971812919779972
7798825938413749319999785941489868587674397449269738978317389938919984622199581498529938819682972471
7749948181969657924978787838596695869966969369158962427829991499668977295896254897998989743989952389
6398998955793159938819887788968371888968395499298999755899949268632898528951445886293997299392969779
9539983773686993498991392899889572558299175987819981797981886747694169489893727157979378595839496298
9599999287193787789729986389617989992374479972959749982818939999895692869845931449861767839389829149
4889176836968695418797941267779399488818276299865898498649489796971967884999112828966259271689857259
7139139187955994831738585298962698949981181887589699969919418116293969946431635243579918986885919619
7935837589876972417397869798312741789988882795986987744696696629647813993997762979599189148298958581
8791284382878199766798982957837371997961791491996313339915819373928948979938596612197699691473969914
1372974376943738718696489825854989786382983999879965536283589995655483569334269859559761199879679291
9719671746885959293824693968698399315424948599622489865269469961617669916732853892695261177787994496
7849319899791243818799879975258532467699699999398269787199341236894749619399991856788917729181194197
9148263323757681139949799197198549259446781912979561927929891898923997238737858757915394778591127667
1945591989843987198391756487965892217958111951642219915715439797998675786222936815998966826782589594
5254778838276178988551266998775337643868756772978159294191819424888551874271745598136847865594999289
3998557499888479397893111869792537426834985941959185929798919875628859952429849886849639853349182496
8958877677623879221669563361998988956937492798913659491897715599879989983979859984661929198589817564
9989969281947994946512996153988898382127889834868897498898867797998892148557494839482788798269898496
9779851919689459958899912662756981619298821434879339749956713988385759469959788279765789991925947918
4196471827218751217999955385399979199189581896987488518319752529829892282899638773984698854832217793
5968399569814182278918739959691249997958587277596698779311494824187981838837892479347738267879912541
8659894118598996577145167494795592898597175979829589886499183913197276893979278479678988218798894991
6649277899864442637895792699719172999998662937819979979769821897696686788719291967114346689819212978
6699889979874997773889958977455779952988466968759738452847569993821963796198741514377779188577811889
1173976886399735895884999486498511998399588328832288555979166889776686858695414825689877994898917949
9629147139882191719857926675389957799296279989442991999622669639755767892922474778888299984452999898
4391879947595258989144156986799899833458894496218777872997391217987623967998848296898891312888421579
9362699299759899879589911968947655251988997896874791778876389919939496782959848979971163281597161779
1652179878596567755189593919723287659886989991199789326995581692999815373488857495418291969165215199
9788389477191759669998798979888832998683445278988415997594187969167388689899997659918914818788982937

10
2021/15/example_data Normal file
View File

@@ -0,0 +1,10 @@
1163751742
1381373672
2136511328
3694931569
7463417111
1319128137
1359912421
3125421639
1293138521
2311944581

12
2021/15/main.py Normal file
View File

@@ -0,0 +1,12 @@
class Point:
shortest_path = []
data = []
for line in open('example_data', 'r'):
data_row = []
for ch in line.strip():
data_row.append(ch)
data.append(data_row)
for row in data:
print(row)

1000
2021/3/data Normal file

File diff suppressed because it is too large Load Diff

48
2021/3/main.py Normal file
View File

@@ -0,0 +1,48 @@
bits = []
gamma = 0
epsilon = 0
gamma_str = ''
epsilon_str = ''
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for i in range(0, len(fp.readline().strip())):
bits.append(0)
# # DEBUG(dev):
# test = fp.readline()
# for i in range(0, len(test)):
# print test[i]
for line in fp:
for i in range(0, len(line.strip())):
if(line[i] == '1'):
bits[i] = bits[i] + 1
else:
bits[i] = bits[i] - 1
for i in range(0, len(bits)):
ch = '1'
if(bits[i] < 0):
ch = '0'
gamma_str = gamma_str + ch
# # DEBUG(dev):
# for i in range(1, len(gamma_str)+1):
# print gamma_str[-i]
# NOTE(dev): Have to do (i+1) because we're going backwards, which starts at -1
for i in range(0, len(gamma_str)):
if(gamma_str[-(i+1)] == '1'):
gamma = gamma + pow(2,i)
else:
epsilon = epsilon + pow(2,i)
# print " bits: ", bits
print " gamma: ", gamma
print "epsilon: ", epsilon
print " POWER: ", gamma * epsilon

133
2021/3/main2.py Normal file
View File

@@ -0,0 +1,133 @@
bits = []
gamma = 0
epsilon = 0
gamma_str = ''
epsilon_str = ''
lines = []
oxy = []
co2 = []
def NarrowDown(oxy, co2, index):
# # DEBUG(dev):
# print len(oxy), ", ", len(co2)
# print ""
if(len(oxy) > 1): # if we already found it, just move along
# Look at `index` in each remaining value; count how many have a ZERO vs. a ONE:
num_ones = 0
num_zeros = 0
new_oxy = []
for i,o in enumerate(oxy):
if(o[index] == '1'):
num_ones = num_ones + 1
else:
num_zeros = num_zeros + 1
# Oxy needs the majority, keeping the ONEs if there's a tie:
if(num_ones < num_zeros):
for o in oxy:
if(o[index] == '0'):
new_oxy.append(o)
else:
for o in oxy:
if(o[index] == '1'):
new_oxy.append(o)
oxy = list(new_oxy)
if(len(co2) > 1): # if we already found it, just move along
# Look at `index` in each remaining value; count how many have a ZERO vs. a ONE:
num_ones = 0
num_zeros = 0
new_co2 = []
for i,o in enumerate(co2):
if(o[index] == '1'):
num_ones = num_ones + 1
else:
num_zeros = num_zeros + 1
# Co2 needs the minority, keeping the ZEROs if there's a tie:
if(num_ones < num_zeros):
for c in co2:
if(c[index] == '1'):
new_co2.append(c)
else:
for c in co2:
if(c[index] == '0'):
new_co2.append(c)
co2 = list(new_co2)
# if we're down to one number in BOTH LISTS, we're done
if(len(oxy) == 1 and len(co2) == 1):
return oxy[0],co2[0]
# otherwise, pass both remaining lists on, move over one index, and continue narrowing down:
return NarrowDown(oxy, co2, (index + 1))
#### MAIN EXECUTION ####
with open('data', 'r') as fp:
for line in fp:
lines.append(line.strip())
# NOTE(dev): We assume all lines are the same length
for i in range(0, len(lines[0])):
bits.append(0)
# # DEBUG(dev):
# test = fp.readline()
# for i in range(0, len(test)):
# print test[i]
for line in lines:
for i in range(0, len(line.strip())):
if(line[i] == '1'):
bits[i] = bits[i] + 1
else:
bits[i] = bits[i] - 1
for i in range(0, len(bits)):
ch = '1'
if(bits[i] < 0):
ch = '0'
gamma_str = gamma_str + ch
# # DEBUG(dev):
# for i in range(1, len(gamma_str)+1):
# print gamma_str[-i]
# NOTE(dev): Have to do (i+1) because we're going backwards, which starts at -1
for i in range(0, len(gamma_str)):
if(gamma_str[-(i+1)] == '1'):
gamma = gamma + pow(2,i)
else:
epsilon = epsilon + pow(2,i)
# print " bits: ", bits
print " gamma: ", gamma
print "epsilon: ", epsilon
print " POWER: ", gamma * epsilon
oxy = list(lines)
co2 = list(lines)
oxy_str,co2_str = NarrowDown(oxy, co2, 0)
oxy_value = 0
co2_value = 0
# convert binary string representation to decimal
for i in range(0, len(oxy_str)):
if(oxy_str[-(i+1)] == '1'):
oxy_value = oxy_value + pow(2,i)
# convert binary string representation to decimal
for i in range(0, len(co2_str)):
if(co2_str[-(i+1)] == '1'):
co2_value = co2_value + pow(2,i)
print "oxy: ", oxy_value
print "co2: ", co2_value
print " : ", oxy_value * co2_value

View File

@@ -599,3 +599,4 @@
68 36 4 24 71
43 31 60 19 95
52 55 13 83 78

View File

@@ -56,6 +56,9 @@ with open('data', 'r') as fp:
else:
# add the next array of numbers to the temporary board object
temp_board.append(line.strip().split())
if(len(temp_board)):
print('ERROR: You must have an empty line at the end of your data.')
exit()
winning_number,winning_board_index = FindWinner(numbers)
print('Winning Number:', winning_number, ', Winning Board Index: ', winning_board_index)

500
2021/5/data Normal file
View File

@@ -0,0 +1,500 @@
424,924 -> 206,706
467,565 -> 432,565
722,827 -> 794,899
256,172 -> 810,172
160,853 -> 148,853
292,525 -> 292,699
108,139 -> 108,187
889,789 -> 889,554
226,79 -> 371,79
12,485 -> 265,232
917,864 -> 917,157
710,30 -> 710,988
459,969 -> 459,812
158,961 -> 330,961
146,791 -> 146,220
56,595 -> 24,563
873,233 -> 873,764
969,156 -> 847,278
741,363 -> 621,363
244,162 -> 244,170
288,411 -> 288,668
696,73 -> 696,743
60,966 -> 974,52
236,681 -> 200,681
424,253 -> 56,253
379,407 -> 784,407
177,335 -> 765,923
69,115 -> 921,967
92,11 -> 92,644
311,543 -> 311,106
89,904 -> 661,332
898,342 -> 576,342
369,66 -> 140,295
968,14 -> 511,471
862,420 -> 343,939
857,578 -> 181,578
745,438 -> 243,940
201,693 -> 201,151
20,29 -> 973,982
852,11 -> 852,95
529,960 -> 357,960
317,97 -> 967,747
847,373 -> 321,373
115,863 -> 850,128
79,946 -> 836,189
937,484 -> 937,839
567,774 -> 557,774
192,348 -> 192,630
552,647 -> 272,367
918,573 -> 710,573
896,580 -> 896,305
989,358 -> 775,358
484,833 -> 869,448
966,273 -> 884,355
944,45 -> 171,45
824,228 -> 593,228
19,18 -> 893,892
360,954 -> 417,954
37,14 -> 960,937
18,888 -> 742,888
339,264 -> 339,848
601,532 -> 601,628
540,280 -> 540,615
962,751 -> 255,44
611,135 -> 611,934
988,619 -> 778,409
388,77 -> 388,266
526,656 -> 526,341
942,306 -> 942,309
32,49 -> 931,948
653,866 -> 306,866
141,500 -> 235,500
96,108 -> 883,108
383,242 -> 106,242
557,366 -> 340,366
315,85 -> 262,85
411,115 -> 867,115
517,654 -> 517,735
265,18 -> 807,560
171,426 -> 449,426
507,680 -> 507,823
141,504 -> 141,578
358,970 -> 358,599
304,287 -> 245,287
625,917 -> 625,555
747,987 -> 456,987
673,316 -> 71,316
135,563 -> 95,563
913,677 -> 819,677
17,417 -> 100,417
524,727 -> 767,970
619,87 -> 695,87
748,425 -> 607,425
11,179 -> 770,938
756,869 -> 756,44
647,763 -> 376,763
980,18 -> 32,966
805,780 -> 54,29
923,874 -> 164,115
765,910 -> 765,697
574,588 -> 574,717
323,581 -> 362,581
749,843 -> 749,814
915,841 -> 221,841
252,650 -> 252,959
73,980 -> 73,904
846,37 -> 846,864
899,663 -> 834,663
512,90 -> 512,253
889,979 -> 28,118
650,617 -> 95,62
842,511 -> 429,511
875,136 -> 875,202
123,99 -> 618,594
848,818 -> 848,546
251,342 -> 251,696
263,919 -> 263,512
905,181 -> 905,293
770,674 -> 770,963
554,587 -> 554,190
528,602 -> 528,962
22,901 -> 913,10
685,736 -> 569,736
378,331 -> 361,331
301,339 -> 123,339
556,436 -> 887,767
488,963 -> 488,510
117,495 -> 467,495
884,184 -> 901,184
27,430 -> 27,94
426,505 -> 426,869
292,717 -> 378,717
154,790 -> 769,790
476,154 -> 408,154
391,937 -> 819,937
449,388 -> 449,677
420,183 -> 725,488
235,428 -> 235,468
515,357 -> 515,312
493,337 -> 76,337
416,343 -> 416,456
713,979 -> 713,253
812,51 -> 812,696
395,659 -> 486,750
68,636 -> 752,636
620,680 -> 620,769
610,549 -> 516,549
316,461 -> 316,248
455,424 -> 227,424
49,23 -> 943,23
13,932 -> 876,69
966,116 -> 966,775
802,763 -> 892,763
617,161 -> 617,379
661,228 -> 661,50
872,913 -> 872,610
792,441 -> 877,441
611,676 -> 611,968
297,271 -> 127,101
276,586 -> 276,981
630,778 -> 289,778
892,849 -> 78,35
201,857 -> 726,857
363,876 -> 78,876
813,190 -> 184,819
984,20 -> 33,971
591,451 -> 718,578
548,235 -> 981,235
51,317 -> 359,317
179,244 -> 751,244
864,976 -> 541,976
707,675 -> 707,45
248,565 -> 306,565
302,629 -> 302,125
383,477 -> 383,388
533,663 -> 848,348
566,124 -> 81,609
479,391 -> 365,391
33,971 -> 243,971
129,14 -> 798,683
335,777 -> 790,322
780,817 -> 351,388
732,306 -> 732,730
642,884 -> 953,884
912,488 -> 977,553
437,309 -> 437,330
646,306 -> 646,632
41,822 -> 41,672
758,238 -> 678,238
610,79 -> 940,79
746,473 -> 467,752
121,723 -> 635,723
46,645 -> 321,920
843,558 -> 518,233
84,81 -> 659,656
976,280 -> 320,936
833,881 -> 174,881
988,49 -> 72,965
262,51 -> 262,654
82,518 -> 716,518
502,168 -> 502,151
596,125 -> 375,125
953,936 -> 120,103
471,451 -> 586,451
571,740 -> 571,30
601,866 -> 789,866
446,527 -> 928,527
212,417 -> 296,417
879,117 -> 189,807
949,435 -> 369,435
116,971 -> 136,971
493,265 -> 86,672
442,379 -> 143,678
981,343 -> 981,978
656,218 -> 656,428
538,233 -> 538,196
771,632 -> 771,29
81,908 -> 960,29
251,514 -> 446,709
747,294 -> 147,894
838,77 -> 43,872
347,292 -> 347,516
135,262 -> 135,987
913,184 -> 225,872
485,773 -> 790,773
499,201 -> 499,167
895,115 -> 895,422
54,77 -> 54,240
23,63 -> 799,839
470,631 -> 241,402
731,307 -> 722,298
966,578 -> 431,578
327,391 -> 348,391
889,687 -> 268,687
262,153 -> 649,540
349,91 -> 349,566
460,281 -> 460,551
887,195 -> 887,253
365,631 -> 456,540
411,941 -> 260,790
252,757 -> 125,757
548,894 -> 953,489
348,953 -> 215,953
145,474 -> 145,941
65,34 -> 894,863
442,496 -> 123,177
92,123 -> 257,123
840,548 -> 840,969
620,878 -> 311,878
378,865 -> 834,409
221,549 -> 985,549
478,517 -> 70,517
968,975 -> 14,21
36,380 -> 274,142
258,555 -> 258,601
386,434 -> 386,675
215,240 -> 215,224
445,170 -> 445,659
848,476 -> 750,574
895,665 -> 589,665
73,210 -> 441,210
17,559 -> 17,599
344,205 -> 932,205
305,760 -> 305,924
93,517 -> 93,960
911,737 -> 782,737
804,590 -> 303,89
927,239 -> 927,891
19,121 -> 885,987
667,529 -> 852,714
121,668 -> 74,715
33,426 -> 33,130
184,170 -> 978,964
316,859 -> 700,475
791,719 -> 791,241
528,178 -> 510,178
317,146 -> 949,146
113,981 -> 855,239
948,895 -> 758,895
768,43 -> 768,963
61,223 -> 61,97
609,737 -> 609,333
521,492 -> 447,566
844,446 -> 830,446
880,48 -> 49,879
349,931 -> 560,931
333,773 -> 333,476
660,956 -> 241,956
479,682 -> 136,682
324,351 -> 324,604
71,736 -> 71,344
579,349 -> 579,340
639,748 -> 639,23
634,235 -> 961,235
205,131 -> 205,542
570,584 -> 570,486
37,33 -> 589,585
747,585 -> 747,477
801,840 -> 719,922
375,582 -> 809,582
397,331 -> 163,331
898,592 -> 898,119
239,589 -> 57,589
172,156 -> 172,499
956,108 -> 367,697
144,350 -> 644,350
934,44 -> 934,327
609,38 -> 609,75
120,428 -> 79,428
976,963 -> 120,107
275,103 -> 275,549
414,221 -> 414,921
970,986 -> 14,30
453,947 -> 404,947
284,803 -> 806,803
321,781 -> 321,476
942,560 -> 760,378
499,564 -> 499,654
458,445 -> 458,416
128,39 -> 723,634
899,355 -> 518,736
914,155 -> 380,155
594,618 -> 594,65
676,361 -> 667,361
624,421 -> 624,617
645,950 -> 613,950
218,347 -> 218,733
239,357 -> 239,178
366,552 -> 677,552
657,95 -> 203,549
789,552 -> 396,552
27,956 -> 981,956
814,115 -> 814,620
497,661 -> 497,583
843,743 -> 843,707
910,708 -> 910,132
147,806 -> 147,491
638,889 -> 305,556
37,43 -> 949,955
526,495 -> 432,495
44,970 -> 44,329
368,130 -> 368,761
202,621 -> 319,504
627,710 -> 159,242
256,457 -> 267,457
85,438 -> 169,438
580,866 -> 584,866
504,307 -> 17,794
942,977 -> 24,59
903,588 -> 903,234
276,551 -> 276,783
365,306 -> 454,306
535,852 -> 961,852
211,253 -> 211,888
989,10 -> 11,988
45,461 -> 45,922
250,721 -> 72,721
74,795 -> 74,457
543,175 -> 185,175
680,935 -> 105,360
337,13 -> 637,313
13,37 -> 939,963
23,951 -> 935,39
976,927 -> 441,392
962,630 -> 626,630
847,931 -> 321,405
21,220 -> 419,220
196,660 -> 196,58
846,462 -> 657,462
395,279 -> 395,844
164,311 -> 43,190
775,629 -> 567,421
274,195 -> 657,195
169,810 -> 963,16
473,880 -> 216,880
354,953 -> 473,953
35,490 -> 843,490
740,577 -> 740,846
841,967 -> 889,919
927,610 -> 474,610
838,30 -> 27,841
211,543 -> 650,543
541,274 -> 441,174
438,30 -> 438,642
16,492 -> 16,529
984,783 -> 280,79
95,673 -> 819,673
516,777 -> 516,253
544,819 -> 544,777
729,669 -> 103,669
618,353 -> 618,796
259,449 -> 743,933
407,151 -> 407,316
811,975 -> 155,975
167,625 -> 71,529
298,563 -> 298,197
385,324 -> 385,21
957,204 -> 957,808
10,27 -> 943,960
412,979 -> 279,979
668,930 -> 569,930
466,827 -> 141,827
924,214 -> 471,667
773,149 -> 976,352
977,736 -> 977,543
162,814 -> 265,711
106,62 -> 106,552
263,872 -> 434,872
692,632 -> 352,632
24,53 -> 24,300
722,774 -> 722,580
605,129 -> 605,841
275,206 -> 648,579
92,950 -> 940,102
500,101 -> 500,891
278,832 -> 826,832
681,837 -> 681,23
369,661 -> 278,661
883,14 -> 498,14
725,158 -> 826,158
770,451 -> 634,451
343,905 -> 742,905
203,193 -> 86,193
662,340 -> 378,624
980,151 -> 980,848
536,650 -> 531,650
730,415 -> 180,965
220,930 -> 220,507
358,598 -> 126,598
251,381 -> 80,552
786,133 -> 113,133
466,443 -> 203,443
478,859 -> 890,447
281,279 -> 281,585
735,605 -> 735,610
570,856 -> 545,856
254,162 -> 677,585
689,566 -> 689,836
678,179 -> 563,179
617,334 -> 133,818
639,327 -> 639,352
697,95 -> 697,961
953,240 -> 304,889
739,477 -> 846,477
542,131 -> 97,576
497,360 -> 497,66
48,917 -> 942,23
743,313 -> 930,313
540,415 -> 623,415
599,499 -> 519,499
415,908 -> 415,561
989,36 -> 60,965
532,943 -> 445,943
216,719 -> 214,719
961,698 -> 261,698
228,883 -> 132,787
385,283 -> 180,283
278,293 -> 278,41
113,698 -> 113,779
139,456 -> 456,456
227,662 -> 855,34
596,112 -> 87,112
773,221 -> 51,943
588,529 -> 169,529
574,106 -> 302,106
85,73 -> 810,73
371,271 -> 447,195
797,208 -> 45,208
22,700 -> 934,700
523,700 -> 523,247
829,212 -> 829,229
470,415 -> 577,415
53,522 -> 53,585
387,978 -> 387,745
932,261 -> 549,644
34,634 -> 559,109
887,181 -> 887,881
77,779 -> 356,779
862,121 -> 14,969
226,779 -> 226,358
945,157 -> 945,658
808,103 -> 914,209
360,640 -> 364,640
567,406 -> 213,760
284,30 -> 139,30
940,977 -> 940,656
635,624 -> 926,333
837,712 -> 837,414
193,230 -> 193,582
592,621 -> 592,41
986,921 -> 986,836
404,640 -> 933,111
914,309 -> 289,934
537,83 -> 537,389
208,564 -> 208,683
120,191 -> 893,964
18,37 -> 969,988
134,976 -> 134,689
187,842 -> 187,235
526,455 -> 590,455

73
2021/5/main.py Normal file
View File

@@ -0,0 +1,73 @@
lines = []
with open('data', 'r') as fp:
for line in fp:
temp = line.split(' ')
point_a = temp[0].split(',')
point_b = temp[2].split(',')
lines.append([[int(point_a[0]), int(point_a[1])], [int(point_b[0]), int(point_b[1])]])
map = {}
for line in lines:
# # DEBUG(dev):
# print line
if(line[0][0] == line[1][0]): # vertical
range_limits = [line[0][1], line[1][1]]
range_limits.sort()
range_limits[1] += 1 # inclusive
for y in range(range_limits[0], range_limits[1]):
if(tuple([line[0][0], y]) in map.keys()):
map[tuple([line[0][0], y])] = map[tuple([line[0][0], y])] + 1
else:
map[tuple([line[0][0], y])] = 1
elif(line[0][1] == line[1][1]): # horizontal
range_limits = [line[0][0], line[1][0]]
range_limits.sort()
range_limits[1] += 1 # inclusive
for x in range(range_limits[0], range_limits[1]):
if(tuple([x, line[0][1]]) in map.keys()):
map[tuple([x, line[0][1]])] = map[tuple([x, line[0][1]])] + 1
else:
map[tuple([x, line[0][1]])] = 1
# else:
# print('skip')
# # DEBUG(dev):
# min_x = 1000
# max_x = 0
# min_y = 1000
# max_y = 0
# for key in map:
# if(key[0] < min_x):
# min_x = key[0]
# elif(key[0] > max_x):
# max_x = key[0]
# if(key[1] < min_y):
# min_y = key[1]
# elif(key[1] > max_y):
# max_y = key[1]
# print(min_x, max_x)
# print(min_y, max_y)
total = 0
extra = 0
for key,value in map.items():
# # DEBUG(dev):
# print(key,value)
if(value > 1):
total = total + 1
else:
extra = extra + 1
print(total, total + extra)
# # DEBUG(dev):
# test = []
# row = []
# for x in range(0, 150):
# row.append('.')
# for y in range(0, 150):
# test.append(row)
# for key,value in map.items():
# if(key[0] < 150 and key[1] < 150):
# test[key[1]][key[0]] = value
# print(test)

111
2021/5/main2.py Normal file
View File

@@ -0,0 +1,111 @@
lines = []
with open('data', 'r') as fp:
for line in fp:
temp = line.split(' ')
point_a = temp[0].split(',')
point_b = temp[2].split(',')
lines.append([[int(point_a[0]), int(point_a[1])], [int(point_b[0]), int(point_b[1])]])
map = {}
for line in lines:
# # DEBUG(dev):
# print line
if(line[0][0] == line[1][0]): # vertical
range_limits = [line[0][1], line[1][1]]
range_limits.sort()
range_limits[1] += 1 # inclusive
for y in range(range_limits[0], range_limits[1]):
if(tuple([line[0][0], y]) in map.keys()):
map[tuple([line[0][0], y])] = map[tuple([line[0][0], y])] + 1
else:
map[tuple([line[0][0], y])] = 1
elif(line[0][1] == line[1][1]): # horizontal
range_limits = [line[0][0], line[1][0]]
range_limits.sort()
range_limits[1] += 1 # inclusive
for x in range(range_limits[0], range_limits[1]):
if(tuple([x, line[0][1]]) in map.keys()):
map[tuple([x, line[0][1]])] = map[tuple([x, line[0][1]])] + 1
else:
map[tuple([x, line[0][1]])] = 1
else: # per spec, must be 45 degree
amount = abs(line[0][0] - line[1][0]) + 1
values = []
for i in range(0, amount):
values.append([0,0])
range_limits_x = [line[0][0], line[1][0]]
# make inclusive in correct direction:
step = 1
if(range_limits_x[1] < range_limits_x[0]):
step = -1
range_limits_x[1] -= 1
else:
range_limits_x[1] += 1
i = 0
for x in range(range_limits_x[0], range_limits_x[1], step):
values[i][0] = x
i = i + 1
range_limits_y = [line[0][1], line[1][1]]
# make inclusive in correct direction:
step = 1
if(range_limits_y[1] < range_limits_y[0]):
step = -1
range_limits_y[1] -= 1
else:
range_limits_y[1] += 1
i = 0
for y in range(range_limits_y[0], range_limits_y[1], step):
values[i][1] = y
i = i + 1
# # DEBUG(dev):
# print('RANGES', range_limits_x, range_limits_y)
# print(values)
for value in values:
if(tuple(value) in map.keys()):
map[tuple(value)] = map[tuple(value)] + 1
else:
map[tuple(value)] = 1
# # DEBUG(dev):
# min_x = 1000
# max_x = 0
# min_y = 1000
# max_y = 0
# for key in map:
# if(key[0] < min_x):
# min_x = key[0]
# elif(key[0] > max_x):
# max_x = key[0]
# if(key[1] < min_y):
# min_y = key[1]
# elif(key[1] > max_y):
# max_y = key[1]
# print(min_x, max_x)
# print(min_y, max_y)
total = 0
extra = 0
for key,value in map.items():
# # DEBUG(dev):
# print(key,value)
if(value > 1):
total = total + 1
else:
extra = extra + 1
print(total, total + extra)
# # DEBUG(dev):
# test = []
# row = []
# for x in range(0, 150):
# row.append('.')
# for y in range(0, 150):
# test.append(row)
# for key,value in map.items():
# if(key[0] < 150 and key[1] < 150):
# test[key[1]][key[0]] = value
# print(test)

59108
2021/5/test Normal file

File diff suppressed because one or more lines are too long

1
2021/6/data Normal file
View File

@@ -0,0 +1 @@
3,1,4,2,1,1,1,1,1,1,1,4,1,4,1,2,1,1,2,1,3,4,5,1,1,4,1,3,3,1,1,1,1,3,3,1,3,3,1,5,5,1,1,3,1,1,2,1,1,1,3,1,4,3,2,1,4,3,3,1,1,1,1,5,1,4,1,1,1,4,1,4,4,1,5,1,1,4,5,1,1,2,1,1,1,4,1,2,1,1,1,1,1,1,5,1,3,1,1,4,4,1,1,5,1,2,1,1,1,1,5,1,3,1,1,1,2,2,1,4,1,3,1,4,1,2,1,1,1,1,1,3,2,5,4,4,1,3,2,1,4,1,3,1,1,1,2,1,1,5,1,2,1,1,1,2,1,4,3,1,1,1,4,1,1,1,1,1,2,2,1,1,5,1,1,3,1,2,5,5,1,4,1,1,1,1,1,2,1,1,1,1,4,5,1,1,1,1,1,1,1,1,1,3,4,4,1,1,4,1,3,4,1,5,4,2,5,1,2,1,1,1,1,1,1,4,3,2,1,1,3,2,5,2,5,5,1,3,1,2,1,1,1,1,1,1,1,1,1,3,1,1,1,3,1,4,1,4,2,1,3,4,1,1,1,2,3,1,1,1,4,1,2,5,1,2,1,5,1,1,2,1,2,1,1,1,1,4,3,4,1,5,5,4,1,1,5,2,1,3

1
2021/6/example_data Normal file
View File

@@ -0,0 +1 @@
3,4,3,1,2

30
2021/6/main.py Normal file
View File

@@ -0,0 +1,30 @@
def SimulateFish(days_until_next_fish, total_days_left):
print('SimulateFish(', days_until_next_fish, ',', total_days_left, ')')
# If we're past the final date, don't count any more:
if(total_days_left - days_until_next_fish <= 0):
# add 1 for THIS fish
return 1
total = 0
# Add up all the totals of the fish this one is going to spawn
for i in range(total_days_left - days_until_next_fish, 0, -7):
total += SimulateFish(9, i)
# Add this fish, as well
total += 1
# Return grand total from this fish (INCLUDING this fish)
return total
#### MAIN EXECUTION ####
fish = []
with open('data', 'r') as fp:
fish = fp.readline().strip().split(',')
grand_total = 0
for i in range(0, len(fish)):
grand_total += SimulateFish(int(fish[i]), 80)
print(grand_total)

35
2021/6/main2.py Normal file
View File

@@ -0,0 +1,35 @@
# "constants":
total_fish = 0
# intialize shared data:
fish_reproducing_on_day = []
# functions:
def SimulateFishByDay(current_day):
fish_reproducing_on_day[current_day + 7] += fish_reproducing_on_day[current_day]
fish_reproducing_on_day[current_day + 9] += fish_reproducing_on_day[current_day]
return fish_reproducing_on_day[current_day]
def Simulate(days):
# reset data in case of multiple simulations:
fish_reproducing_on_day.clear()
for i in range(0, days + 9):
fish_reproducing_on_day.append(0)
for i in range(0, len(fish)):
fish_reproducing_on_day[int(fish[i])] += 1
grand_total = total_fish # starting fish count
for i in range(0, days):
grand_total += SimulateFishByDay(i)
return grand_total
#### MAIN EXECUTION ####
fish = []
with open('data', 'r') as fp:
fish = fp.readline().strip().split(',')
total_fish = len(fish)
print(Simulate(80))
print(Simulate(256))

1
2021/7/data Normal file
View File

@@ -0,0 +1 @@
1101,1,29,67,1102,0,1,65,1008,65,35,66,1005,66,28,1,67,65,20,4,0,1001,65,1,65,1106,0,8,99,35,67,101,99,105,32,110,39,101,115,116,32,112,97,115,32,117,110,101,32,105,110,116,99,111,100,101,32,112,114,111,103,114,97,109,10,82,1266,26,290,428,9,676,880,16,340,1578,839,23,32,721,88,837,118,543,198,836,870,105,44,214,184,52,330,213,1224,1211,481,1707,409,78,1096,995,420,808,50,65,635,1186,228,5,359,290,1241,757,323,11,447,522,8,170,265,632,321,9,1707,1005,1194,466,137,982,905,373,158,601,247,373,202,432,168,694,785,568,144,576,1006,143,1506,298,1790,146,182,535,895,42,296,278,469,118,292,1375,206,235,1545,63,81,49,1405,660,41,1009,226,133,324,1250,113,10,687,223,78,10,745,21,55,1041,149,519,57,589,123,901,416,200,112,35,6,873,353,539,665,75,207,80,787,322,1026,178,19,630,12,263,1136,71,220,143,688,101,88,1600,16,141,55,64,436,19,889,267,470,884,31,546,846,601,15,84,399,83,1054,4,1417,766,525,162,640,73,2,110,189,494,85,44,263,618,583,263,591,1139,21,1593,187,115,520,142,887,3,12,565,78,88,114,803,157,307,1007,1365,1063,1481,431,410,125,19,1123,3,433,73,273,25,438,314,111,369,1188,526,516,509,1,186,143,1335,689,436,1002,260,791,12,36,380,80,306,173,45,24,856,1892,255,11,12,1221,422,8,1214,327,851,85,375,115,325,213,725,720,669,465,577,1,28,331,123,297,267,1586,478,259,572,204,365,461,618,364,5,630,377,26,259,331,956,164,89,115,1328,823,48,625,922,236,577,1113,251,156,846,261,500,73,1607,281,267,64,2,392,115,682,1833,861,1093,1165,52,1643,59,180,787,298,274,304,381,196,511,352,793,1043,984,30,85,190,109,276,303,251,1601,939,726,5,213,915,235,780,43,1212,1466,353,364,507,129,1109,1307,113,109,342,756,898,1015,63,949,127,887,175,91,409,1069,88,600,101,434,1021,477,1073,22,549,145,712,730,160,7,123,27,566,689,172,1496,543,154,345,442,3,860,47,69,319,487,17,1086,1305,329,788,738,688,421,139,1629,499,824,276,13,1033,885,522,140,328,113,311,297,252,33,168,1059,94,469,1816,2,107,149,652,350,200,173,367,100,229,219,400,43,283,1551,752,278,99,648,190,190,337,44,191,462,454,544,261,142,1204,231,924,209,858,768,211,223,186,1452,687,320,343,444,94,1231,285,324,431,36,309,705,672,69,1082,83,269,515,369,117,951,489,117,249,47,350,1408,93,203,800,1151,526,785,721,240,74,605,501,533,512,337,12,720,787,1521,894,112,187,170,1020,339,77,565,691,1141,129,1020,60,505,1383,178,1262,1302,750,743,1108,43,634,135,738,810,628,1807,938,530,61,1384,42,79,276,336,1434,1286,393,145,9,94,945,113,76,88,856,78,1750,499,994,527,1102,266,1164,796,143,726,480,357,577,910,460,448,379,402,1576,1353,257,1044,651,1206,44,126,353,1099,934,892,379,710,988,1041,367,116,377,546,1222,830,259,10,6,385,856,343,793,490,165,367,1022,1065,95,135,426,184,270,227,456,673,90,1363,1127,387,93,138,202,184,1071,134,15,813,134,200,80,144,128,1502,574,868,487,118,42,48,1135,1107,57,418,1093,1508,229,26,154,652,94,1254,171,502,407,276,1098,18,1000,345,150,123,211,1517,1005,590,1413,63,80,510,502,76,476,47,405,186,143,344,286,1277,934,64,512,12,1026,264,68,1420,10,245,10,352,6,585,567,48,428,816,1525,180,346,350,34,100,42,1354,699,265,445,1719,425,8,604,129,111,71,110,1170,703,36,317,198,104,655,95,1046,327,161,853,400,224,797,1221,794,684,321,1279,1,95,1253,671,203,43,220,55,90,1606,359,52,775,76,422,403,305,614,196,244,102,519,122,451,1610,79,709,336,1374,735,478,1123,658,906,615,688,561,518,39,1084,608,54,739,416,1648,1838,1280,1039,35,552,299,142,56,1217,1356,30,12,102,731,1343,224,452,304,1808,546,583,710,33,149,1126,565,314,745,22,115,263,813,113,52,308,944,981,441,544,129,1258,299,885,717,536,253,3,612,29,130,1099,1455,38,501,578,13,347,729,166,772,230,518,488,430,1093,140,16,120,1603,794,174,1361,1657,825,444,176,815,1353,469,264,191,988,12,104,11,1518,1096,347,606,350,18,1376,430,182,1229,131,111,731,174,111,304,715,35,410,701,78,46,390,291,1008,1779,620,2,1378,199,331,334,708,446,1141,773,159,702,716,13,582,161,259,90,180,607,539,611,312,622,151,522,921,150,522,273,421,842,111,21,159,148

1
2021/7/example_data Normal file
View File

@@ -0,0 +1 @@
16,1,2,0,4,2,7,1,2,14

13
2021/7/main.py Normal file
View File

@@ -0,0 +1,13 @@
values = []
with open('data', 'r') as fp:
values = fp.readline().strip().split(',')
for i in range(0, len(values)):
values[i] = int(values[i])
values.sort()
index = int(len(values) / 2)
total = 0
for i in range(0, len(values)):
if(i != index):
total += abs(values[i] - values[index])
print(total)

43
2021/7/main2.py Normal file
View File

@@ -0,0 +1,43 @@
values = []
with open('data', 'r') as fp:
values = fp.readline().strip().split(',')
for i in range(0, len(values)):
values[i] = int(values[i])
values.sort()
index = int(len(values) / 2)
total = 0
for i in range(0, len(values)):
if(i != index):
total += abs(values[i] - values[index])
print(total)
min = min(values)
max = max(values)
possible = []
for i in range(min, max):
# # DEBUG(dev):
# print()
total = 0
for j in range(0, len(values)):
distance = abs(values[j] - i)
total += distance * ((distance + 1) / 2)
# # DEBUG(dev):
# print(values[j], '-', i, distance * ((distance + 1) / 2))
# # DEBUG(dev):
# print(total)
possible.append(total)
min_i = 0
min = possible[min_i]
for i in range(1, len(possible)):
if(possible[i] < min):
min = possible[i]
min_i = i
print(min_i, values[min_i], min)

200
2021/8/data Normal file
View File

@@ -0,0 +1,200 @@
gbdfcae ebcg cfg gc facegb fecab acfge cbfgda fedag caebfd | ecbg bfcagd faegc gcf
eacgf efcab fgc fedagc gdeaf cged aebfgd adcgfbe gc bdgcaf | fgbacd cfega ecdg cg
dfgae gcadef efb eb dcabf bgde edfba bcfaeg egcdfab fbgade | bged eafdb eb gfdea
aefdb cafdgeb egdfac egdcba fcbd efd eadcb caefbd df aegbf | cfadeg abfedgc fde bfcd
dc deafg ecd dbaefc adcfeg cfged ecbfg acdg cafdegb gfeadb | dcga edc adfebcg ecgfb
befdc bcfge befad degfab cde aecbfd gcedaf eafcgdb dc bcad | bdeafc cde ebdcafg daebgcf
cd egdacfb fdc fecgb gabdf fbcdg fcgdeb gdcfea debc ecfbga | gfecb fbgecd bcgef dc
fagcdbe gec gbdea ce bgedc aecd cgbeaf cfbdg gebcda dbfgae | cfbaged cgbeaf ceg gadfbe
gcbaf gfdb bdafc df adf adcbefg dcfeag cebad adfgcb faecgb | afd agfedc dcbfa gdfabc
fbae cef fecdbg afbcg cefbga fe acdfgb gadce fbdacge fcage | fe abef gfbac cef
cfdebg bg beg cabfeg fbgd acged ecgbd fdcbe cfbeda cebgadf | fbedc gadce gdaec bcfed
gba ab fgbcd gedaf bcadge afbdgc cdgfbe agdfcbe bcfa bdfga | gab gdbfc ba fgdbcae
fabdgce bfdgac cbaed dcb bgade fbaec fcde edbfac gfabec cd | dc cefd dc cd
afc dbecafg fagce fbega fbgc edgca agecbf bafged eacdfb cf | cf bfdcaeg gfbc gfbc
gedcb ebda cgbdfa fcaeg gab bfgdce ba agbce bdgecfa dgebca | bdgfce cebagd cbdgfae dcfbeg
egbacf acdfe gfecb egdfcb dfgaceb dfb dgcb fdbce db bdeafg | fdb db db bdf
cfeg eabcf gdefcab bef geabc bfcad egbadf cfgbae egcdba fe | fgec gaecfdb cagbef ef
bafde dbgeac feacgbd cbaef bed bfgaed gafecd bgdf bd eafgd | db cfgdae caegdfb fabed
afg bacg cdbgf gcdfab fdcae gafdeb dbgfce ga dcafg cedabfg | gaf bdafgc agbc ga
edgca bafdcg acbdg cbdeag dce fgcea gdcfeb aebd ed gfdabce | ebgcad daeb edcga ced
agecf abfegc dbefcga ad dafc fegdb adg afgde bdcega ecagdf | fadeg dfac dga da
ceagdb gedac acfdbg cda bgecafd adgeb dcefg ca beac abgfde | aegbd baegd bdcagf abcdeg
egaf bagdce dcgabf ea eab cgbfa cdfebga fbcae dfcbe fgbace | gdfaceb gfea dbcfe eba
cfbega bge eg cgdebaf gedbc adeg bceadg bfadcg agbcd cdefb | ge ge cfedb fbgadec
afc ca cabe gbefcd aebcgdf acedf gbafdc eagfd edcfab dfbce | gbfdcea fca aecbfd ceba
af bcdag agbfde fdbca ebdfc adf dbefcga abedfc aefc dbgcfe | af acfe adf adcfbe
badfe agebd gfaced gbdcafe aecfd fab dbfc geacbf adbcfe bf | fb ebagfc beadf dface
bfeda gabefd agbedc ec fcadeb dfbaecg cea fdec afceb agfcb | fbcae cfde eac fedc
ebcf eafgcb egdfba dfcag bacge faceg afe gdceab ef dgcbaef | fcbe febc bcaeg cbfe
dafbc afdebg egfc ce eagbcd ceafgbd fgeba cbefa eac fcgeba | afegb cdagbe cbdaf gfaeb
ecd dface cdgafe gcabfd edbgcfa gdacf fecg cdbaeg ec efbad | edbaf gcafd dcgbaf dafgceb
gd fagbec bdfg gde cfgbe cefdbg gbdeacf agdcef bdceg bcdea | dg gcfeba dg ebdcg
bg bgdeac abdg cgb fcbade gdbceaf fbdgce dbeca gaebc aegfc | cgb befgdc fedgcb gbc
gac cgeda egcbafd gfdbce fadec ag degbca agecbf dagb gebcd | cdegb degcbaf cedaf edafc
ecfab bfacdg bdga gb cfgba bfg gefdacb cegdfb fagdc cafedg | bfg cefba gb aedbcgf
dgfce aeg cfbdgae acfgeb ebcafd ag gafed gaebfd bdga dbfea | gae cfbdae abedfg bgfdae
cgbad cbaf fbgeda dfgcab fdcebg dbfcg decag cdagbfe bga ab | dfcabg cbfa fcedgab adfcbeg
cegbadf edfgba cafeg dc agdebc dbgfe cdbefg dec dbcf edfcg | bdfc facdegb adfegb egbfd
bedf cefadg ced ed bcegd gefabc agcdbfe cdgab gcfbe fgcdbe | ed cde bdgec dbecfg
egfcab debfa ecd bfgec cdgb cd bdcef dgebcf ecdabgf egcadf | becfd cbgd gcdb fcbed
bc dbfge gbecf caefdg gefabc abgdcf bfc baec efcag cebgafd | baec fegbc agfec cgbef
bacegfd fbdgca egbcf fabce bdaefc dcaef dagefc ba dbae cab | daeb cbefa cab ab
fgab cgdfae fcgebd gb bcg dbaegcf cabed gadcb gcafd gbfadc | gbc adcgf dgecbf cgb
gdaeb df cgaebdf dfbe cbdagf eabdcg gfd aecgf aefdgb agedf | dfg gfcea febd ebdag
ecbaf cagfdb aecgf gac ebga defagcb baedfc gfcde ag gfbeca | cadbfg gaecbf agbfec fecba
edbgaf fbd egdbfca dagf gabde bdfge fd bgcfe efbcda eacdbg | fbd ebcdaf dbgaefc gefbda
acdbg aefcdg cdg cegb acebfd abgdf cg fbegadc gcbdae eabdc | gc edafbcg gadbc cg
fgcd bgdafe bacge dg facgde acfde agdec gdefbca deg aebcfd | gd eagdc ged ged
egfa efdcba dfbgc cbfea ga abcfg edgcab bga fecgdab aebfcg | bga faegcbd bfeadc badcge
bfeda ceagdb bf ebfacd edacb acefbdg begcdf bafc agfde feb | fb fb fbac bcegad
bfdcea dcbgaf cbega dbage cea ce cbafg gefc bgacfed bfecag | abgfc ec cegf acdefb
adgfce cdag cd fgecab cfgae ced fdbae gebdfc agbcefd ecafd | dfcae dc fdcae ebafcg
dbeag begfad bfdegac dcb cb gcfda ecdgfb ceab gcabd dcebag | cbd cb cegbda bgcdef
cdfaeb fgebad ea dcbgfa gcaebdf cegbd bdcae fabcd cfae eba | caef bafdce afec gfdbea
bcfega gcbea bdfgeca gabcd bd gdcabe dafcg ecdb dba ebfadg | fceadbg fbaceg db bd
gadcbe dgb debcaf fabgcd bcgfe bdgcf acfedbg gd cafdb gdaf | eafdcb bcfade badceg bdacfg
gafce cabde cdf aefbdgc efacgd fgeacb ceafd df efgd badfgc | edfg acbegf dfc gedf
afgce gbdecf bae adebcgf bgedca abecg abcd baefgd ba gbdec | ab dfagcbe gbeca ab
de dcgaf gcfbed gdebfca acegb cde bcgafe abed gdacbe gecda | ed afgcedb deagc gcdaf
gcdef ebfadc da dabefg daf fbaeg gaefcb dfeag gbdfcea bgad | gadfbe bafgce dgba afd
bdfeg gecf fc egdfcb gcbedaf bfc dfcbe cbdfga baced abedfg | fcge fgdecb dcgfabe fgdeb
bdf acbdfg bdaefg aefgbc abcde dagebfc fd dfcg cabdf cgfab | bfadc cabfg gfcdab fbaegc
af cdfbega edbfac dfbgc fac adef adecb becagd acdfb efcbga | bcagfde bdfcae gfdecab eacbd
egfcad bdgeac fdac fed cdage fd gcbfed baegf gfedcab gedfa | adceg fd afebg egdca
fegba ecbafgd cfegba cgdab efbgad ec fadcge ecg bcef cegba | bgadc ce fecgdba baceg
bdfaeg abgedc efadg bafd gfeba fcdebga adg aecgbf da ecfdg | ad ad dfba befcgad
efadcg dacfb cfgab bfde eafdc decfbag decbfa bd bcd acebgd | debf cafde gcdafe fcgebad
agd cgadef gcdebfa gd facge bdfgea eagbfc dcgaf cafdb ecdg | cbgfae ebfcga agcef bfdeag
dfbge abefgd aefbcg dcfegb ba fgbad gedafbc bdea fba dcafg | agfdb fab fba fcbgde
fcdab agbecd eacgfb gc fgeabd gdabc dgbea cbfdeag cag dceg | fcadb fbcad degba gca
eag cbefg dfeagbc cdfbga egcba dcegba dace agedbf ae gadbc | cegba age agbdc dbcafg
cdbag gfb dgceba cbfa gfdbac faebcgd deafg dgbaf fbegcd bf | eagdf febgcd fbdag gdfbce
cdbgf afcebg acfdbe ed ced bdefagc dcgbea fbeac cbdfe adef | cfbde de dec ecd
dfc fbcde dfcbga ecbgd egbdca fd eabfc edbfgc efdg cdfegab | df dgef fgbaedc df
fcg egcbd gacefb dfgbc abfcgde bfdga cfed cf gdebac gbecdf | bfdcg fgc fbcdg agdbf
fcabg acfbedg bfcgde ecbad agef ecfgba ecf fe dafbgc baecf | aegfbc cfe dbace fec
edbagc cefbda bfdeg af agcf gfebdca fgdcab dgcba baf fabdg | bcadef dfgcab abdcfe gedfb
acegf efbgcd dgbefac cgd bedga cbad agcedb dc egadc feagdb | badcgef cd dcgbfae cd
bfc cdafeb bcega gdcf afgdbe egbfd caebfdg gcefb cf debcgf | gcebf bgedf dfbgea fc
dgfaceb gcdf dabcg fd dfgba aefcbd bdacge gfabe afd dcagbf | daecgfb gbecda dacbfe gdcba
fbgedc bfcda cfg dafbge fecdbag cagfd aecg agfde cg adgcfe | ecdfagb gfceda gaebdf gbfdea
afbe gfa gfdcb af febcadg faegcb bcgea aedcbg eagfcd afgcb | bagcf gfdeca abfe af
caefg efd fd abedc fcgd egdcaf egafbd gfcbea dafec abgedcf | gaebcf fcedga def egcafbd
dcfab gefdcb bda da baefc baedcfg gfda dbceag cbfagd fbgdc | cdebga efdgbc fbcgead beafc
bgfed fdaegcb bedagc da bdacfg gda eacfgb cadf dafgb cabgf | dgceab da dfbeg bcegad
cedab fc adbfec faegcb adbgf cfa ecdf ebagcfd dcbfa ecgabd | becdaf cefd abdfc efcd
cdgbea aeg agdec dafgbc gbed aegbcf ge aecfbgd cagbd cafde | ceafd bagcd gacdb cgbad
dgfeb bedag cgdefa df gfdaeb cbdega gfdceba gbfec dafb gfd | fabecdg bdfa bdaf dfba
gdfe acdbf ed bdegcf cegbfa cebfd deb badegfc fbcge bgaced | ebd efgcabd bfcda dfeg
abfcedg gec fcgdbe gaebc gebfac efbdca gfea acbfe gbdca ge | agfe cge cdbgfe bcfdea
fgbaed dacegb dacef egafd aecbgf adfcebg bdfg ged agfbe gd | agdfceb gd dg fbgd
egdb acgbef edfac bd fgecb gbadfec bcafgd bcd bedcf gdecbf | bdc bedg gdbe efbgc
cagbef acgbf fgcabde cgd gbda dg dbfgec ecafd dgfca dagbcf | agbcfe dcgfa dbagcf cgdafeb
cb efbgc cgfae cgb gceafd beca fbcgae gefdb cbgadf dcfabeg | bgeacf bacedfg cbdgfa dfgbe
cgbedf facgdb agfdc cga cafed gfcbd gcdbeaf degacb fbag ag | gbaf acfed gafcd cgfda
egbdfca cadf bdafgc cbgfea cbgde bdcfg gfc cf fdbag gebdfa | eacdgfb fcda dfac adefcgb
fdgea abcd ac cfabge cdbfeg gdebac acg gcdebaf gadce bcedg | gac abefgc ac gcaed
eafdc eafbc agbe begcadf ba gcefba fgcbda gdbfce cba ecbgf | ba ab abeg adcgbf
afg ga bdafe eadfg dagc gefcab edbcgf ceagfd ecgdf aedcbfg | agdc daefb debcafg fdaeb
baf cbdgf afbecd gdcabfe dcfabg fadeg gbac gbadf ab cedgbf | fcdeba cbga afbdg bgca
ebdfgca ebfdag gb bgf fdeagc gdbe cdfgba egfab abcef agdfe | gb gfbdea gdeb eafbg
agbcdf fe gebad fea becf ecfbga cgabf aegfb fedgca acgbedf | ebgda ebdgacf fcbe aef
gdbef bgfadec gfeab eab gdcfbe ab bfadeg fdab dcaebg acgfe | fgadbe fbedgc dgefb aeb
adcbf fbdg bcf dcbag fecad cgafbd fb acdefgb bgefac dgcabe | dfcab cfb bf cdeaf
dfgbca cdebagf cfe fcbga aefdg geafc bdecgf ce bgefac aceb | bace aebc gfbac efc
adfegcb gcbaf fa adgcb acf efgacb fgcbed eadfbc agef fbgce | aefg acf gafe cfa
fdegbc fcbad ec ebgaf gecfdba feacb caefgb degfba ecb geac | ecb ecb cfadb ebafc
fegabc ebcgafd gfacde ge fcgeb ceg bagcf dcfbe ebga bdcfga | cefabdg fdceb abgcf gfeadc
fdabcg bgafc fcbeag edbfg gadfceb ad adb dfca dcbgae dfabg | bdegf faedbcg da caegfbd
cgfae gdbeca decaf fd dfbc fad dabegf daebc bedafgc efbcda | decfa fgcbdae fcbead dbegcaf
dbeaf cb fabecdg bcfda gabfdc cbfg agdfce abc edgcba cgadf | bcdefag bcgf dafbc badcgf
gbdcfa becfdg fdbcgea fgc cg fecdg efdgb ecadf gceb gadefb | gcbe fgcebda daecgbf aebcfgd
cdega dgcaeb cbgea egdcaf gfacedb begfda cebfg cbda bag ba | ab egdac beafdcg faegcdb
gab cgfab cfage fbaedc bcdg gb gacfbd defcagb gdebaf fadbc | bg fbacde gfabc dceagbf
ge ebg cgdfb cedba bedgc ecag deagcb bfceda gdcfeab egdbfa | bge beg bafged cadbeg
eabd ebacf ecd fdcbg dbafegc ed ceagdf fgceab ecfbda cdbef | dec dfcabe dec befca
afbgdec cedb dc agdbf cegbf bfcedg cdg bdgfc baecgf ecfdag | cd dgefbc fdgcb cd
gebdaf dgfae afe gafcbed agcfd febd edabg gbfeca bcdega fe | ebdag fedb egafd aegcbf
gebdcf abefdcg deg bgdfc fcde gbfea gedabc edbgf ed bgfcda | efdbg fedacbg gbfacd fbdeg
bcgd edagc gaebd bcdaeg fabedc bgefa fcadge agbfcde db adb | cgbdfae bdagcef badegc dab
df fdb bfadceg bgeadf afbdce efdg dgbae dafbg cafbg abdgec | gdfe afcgb ebcgafd fbgacde
gabce gdfaeb bcad cebdgfa fgcbae efgcd dga da cgdea cdeabg | ad agd gda gfedc
fcabge edbfg fcaebd ea dcbagef gace gafcdb bafcg eaf fgbea | dcfbage aceg afbdceg ebcafd
bafe egfcda be bfgaec gbe egcfbad fcaeg bdcaeg bgecf cfbdg | fabgced bfea gbcef gcfeb
badfeg fgecb af cgaebd acfdbge gaf afcged gfaeb dfab egbad | fa fga abfd gabde
afceg bcdfge fcaebg baegdcf cfg eabcdg bgfa efcad gcabe fg | abfg gf fbgecd acebgd
acbedgf fb efgdc bgf gbcfd bgfdac dagcb fdbeag ebcdga fcab | bf gdebaf fb bf
aecf cgbdefa bacged efbcga fdgcab febag af agf dgfeb ecabg | bcgdaf af cadfbge efca
egfda fgceab acd bfcadeg dc dcega bfdcea gcdb cdbega eacbg | gabecd cd befgcad gdcb
gecda dfegacb cgfae cdbfag fcbeag afg gf fbge dafecb caebf | dfaebc cfeab gf agdfbc
gdafe cdgaeb egfdba da bfdgec gbfed eagcf egdbafc fbad dag | agfde dga dcgbfe abcdfeg
acgdb gadfce cbefdga becad bcegdf bacgdf afbg ga dag dbcgf | abdgc gdeacf acdfbg ecdab
gdfa eadbc gcafe dgc dg fcagde bcgfea decgfb egcda fbecagd | cegda cgdea gd dg
ga egdbcfa aegcb cag egbcd gadceb gbcefd decafg badg cabfe | bagd cagfed gacdfeb cbegd
cb deafc bcgd agfceb dbfega ecb deacb aebgd cbafdge ebdacg | dcgb adceb edgba ceb
edgfab acgb becfdag bgf cgbdf cgfad dacbfg bg ecdbf afegdc | gfb bg gcfade gfbdeac
caebg cgaf acgdfbe begcaf cf fdgeb agedcb ebgfc cfe fbcdea | dbfeagc cfe fbeagdc cf
ageb bg adcbfge fcgea cbgaef cbdfa gfb fedacg bfgca fdcgeb | fbg afdcb ecgbdfa cgfdbe
dgbfe aeg ea dcea dbeagfc fbacgd ecbdag gadbc bcafge adgbe | aedc ae gbdef daec
dbafcg dbgaefc adfc egdab fdg df agefbc bdgcfe fbacg gdfba | bedgacf gcbaef cdfgab cafd
eg fdgcabe gcadbe aebdc gced bagfde gea gbeac afbcg ecdbaf | agfbc fgdabe fcdgaeb feabcd
fedb gfe defabgc caedg cgadbf feagd bdagfe fgbda efagbc ef | fe fgcbea ef dbfe
bc agcb dfceg bafgdc gfabd fbdcg bcd ecgfbda ebadgf fbaedc | cbd fabcgd cgbfd bc
ebfgc dbeg ed gefdc cde gfbecd fgdca caedfb gdbafec gefcab | fgdecb dgfce fbecg cabgfe
ab ebda bfagdc becgd aecfg bag daecgb ebcag gbacdfe cfgbde | abedgc eafgc ebacg ab
ecdbag dagbfe badef fcaed adc cd efbagdc cafge cfaebd dfbc | dcfb dca acd gcdabe
cedbgaf ecbfg dagfec dgbea bdca gfdaeb ecgbd dbecga cd edc | ecbdga cde edbag dc
egbfcd gbcafe ed defga dbgfa bcgdeaf cdea def eacdgf gacfe | bgfad ecda gbfad gcdefb
dafge cea fdace agdc dbgfea ebdfgca dcbfe acedfg abecfg ca | defac gcad ac ca
ecdba fbac eabcdf beadgfc acd efacgd ac agedbf bfdea ecgbd | aecbd agbefd bdgec dgebc
bfegda bdage gdf gfdae bdfgace fgeb afdec fgdacb gf deagcb | fbaegcd fegb aedgb dfg
cdaf fd bcdfge agebf dcgfae gfead baedcg gdcea egdbacf dgf | efgab df eagfd afgbe
egfca egcb ceafdb fbc fbcaeg dgbfa cdfeagb fgcba agdcef cb | cb gcdfae eabgfc fgbca
gdbca fdecba gdecfb feagbd ceb adfbgec bdgec ec efgdb cfge | ec ecbgd dacefb abfged
edbcag cabd ecfdgb aegfd eagfcbd ac cga feagcb ebdgc dgeca | acfbdeg dfgea cga dgeca
ebgacf adcf bcgedfa gdcabe abedf aef edabc fa befgd bfdaec | aefdb af cebad fae
dageb de gde dgfbce cgdba gabefd afbge cgdebfa aefd ceafbg | efgbda agbdecf bfaegcd edg
ce dec becf efdgb edfgcb ecbdag gdaefb beafgdc dagfc fecgd | ce fdbage gcdfeba gbcadef
ecgfa ebadcf ed gcdfab cdefa gfdaeb dbec dbfgace cdbfa dfe | dceb cdfab ed ceagf
cadg efgcdb gbcfad feabc agfcb afcdgbe dgbfa gcb fagbde gc | gdecbf adfgbc fbcgade gafbc
gdcefa gefdb bcfeg eabc fagdbc ecagf bcf afcebg cb bfgaedc | fcgdba agbecf fcgeba fgdceab
afgbc be cbeaf gfeb ebcdfag cfdbag cdfae cfegba cbeagd abe | gdecbaf cagfb bfgaec cabfdge
eb egdb dcagb abe gcdabe agbce dgabcf fedbca fdcebag gfeca | gdbe agdcb gfcae cgadbf
dbagc bcaedfg gade cadeb efgabc cabedg gca fgdbc ecafdb ag | dage cagdb dgcaeb cdgab
gbecd eacdg cgb egacdbf gfdbec efbg bfced bg bdfcea bafgdc | acbfde bg gb gb
fgbadc fbdag dbecg fbae dacgef ega ae afcbged ebgfad bgaed | ae bacfgd bfea agdbef
dacfeg gecfd ad gadbfe gadbfec gda acde fcedgb acbfg fdcag | gefcd cdegf agd ad
caegbd cfdeba edbac cfbegad fe fbea fdagc cef acdef bedgcf | ef cdafgeb fce edfca
dgcae cedbfag facbdg fdc eacdbf bfegda dfcae fdbae cf cfeb | cf febgcda dfc cdf
edfag dbeacg dbecafg agc gcefa gc bcfea cdfg fbdgae gefadc | dfacge fagbecd feacbdg bfaged
abefdg fgdec ecadf efcdab ac dbeaf acdb acf cdegfab gecbfa | fca fdbega decaf cgafdeb
bceafd fegcad edcagbf dbcage decba bafd df fcd bcfge cbfed | ebgfc eacbdf gadebc df
egba cgdafbe begfc gacdfb dceaf cefbdg gfa ag gcebaf aecfg | acbgfd gabe fbgeac agfec
cdgeb fdecag agdbefc gefbac cdaf ade fegdab cgead ad caefg | ecbgdaf dgceb cfgae dea
cafbde fbgac edcg agdfeb eg dacgef fgcea aefdc dceagfb eag | afgec fbcga ceafgd bgceadf
cefbg ceabd gd edbacgf aedfbc gaedcb cdbeg abfdcg gdc gead | cgd dgea gd cebad
fadbg dagecf fea fbecga adce ae bedfcg egacbdf fdgec fdage | dcae caed dbefcg adgfb
acged aec efgdcb ac fagc abdge abfdegc fdeacg cfaedb gedfc | egbcafd gaefcdb cae cagdfe
fcbdage bafgec cab fcbae ac abdegf dbfec fbgae eagc cbfadg | acb dafegb acb bfeagdc
af egfda gebdf gebdfa aefcdbg fbecda fgba daf cdeag dgbcfe | eagdc cefbgda daf daf
dgebcf gcf agcbd fbecd fbcdg ebacgf aebfcd fdeg fegdabc fg | dacgb dfge fcdbe gedf
bfacdg gafcb gefbd cd dgcfb dagc bdfagec bceadf fagceb bdc | begfd gbdfe afgcdbe fbeacgd
bagf afe bdcaeg fdcbe af dafbe cbedgaf gfebad gdaeb aefcdg | baedcgf fa af cgadbef
acdgf becgfa acd cagbf agcdbe fdba da bdcfag gfdec dcgafeb | bagfc da dca fdbacg
cdabfe adbfc ecbaf cdae cdbfge dabgfc bfgae bec ce gadcbef | faecbd beadcfg dcae cgfedab
bceag agd aced gdbafce bcfgae agdeb ad fabdcg fdbge egcbad | gaceb agd bdagec da
cag dfgbeac ecdbgf ag gfabc ebag fabgec deafgc adcfb fcegb | dgaecf aebg bgea dcbfa
afdb degbc agedcf da aed beacfg dgfecba efcab bdface cbdea | fbeca aecbd gdecaf ade
cafebg afedcb gfeabcd fgcb cfa afdeg fc ecgab dacebg cfeag | bcgf bgcae gdfea bgcf
feg gfcaed cfabdge gf degafb fdegc edfcab edgbc agcf cfade | gf gf gacf egf
ceadf ecdgf eacbd cebagd dcabfge eaf fdceab fbad fgebca af | cefadb cefad bfad abedc
gefabd cabdfeg dgceab dagef bdfacg egfdc edgab af feba fda | geadcb dagfceb fda af
dfcea adgce dfebc gecfdba fadgbe dcefga cfga aebcdg efa fa | fa fae af gaedbf
agbfd acbgedf faecb cegbad dgabfe gbc fcdg cfagb gc afdbgc | cg cg dfgbae cdfg
efg bfacg feab efcagd fe bcagedf edgbc ebgcf afbegc bcfgda | dgecfa ef fgcba efba
aebfdc bcfage dgbacf gface gbaecfd dfgce geab acfbg ea eac | cabfg ea cfagb eagb
gba gdcea cdbfg acgdb gbecadf bfgecd dgcfab abfc ba fdeagb | ab febagdc dfgbac fdagcb
dfcb gcebd dfgaec efdgc eagcb dfaebg afedcbg gbd gbcfde bd | gadebfc db febdga bgd
eabd adcbg ceafg ecb be eacdbg acegb gbfcde adgcbf ecfdgba | cgfebad cbe ebacg dfgceb
cefbgd cgdfa bagfced dabe fgceab abfeg gdbaef gbfad db gdb | aefdgb bd abdfegc fgabed

10
2021/8/example_data Normal file
View File

@@ -0,0 +1,10 @@
be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | fdgacbe cefdb cefbgd gcbe
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | fcgedb cgb dgebacf gc
fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | cg cg fdcagb cbg
fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | efabcd cedba gadfec cb
aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | gecf egdcabf bgf bfgea
fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | gebdcfa ecba ca fadegcb
dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | cefg dcbef fcge gbcadfe
bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | ed bcgafe cdgba cbgef
egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | gbdfcae bgc cg cgb
gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | fgae cfgab fg bagce

29
2021/8/main.py Normal file
View File

@@ -0,0 +1,29 @@
# 0: 1: 2: 3: 4:
# aaaa .... aaaa aaaa ....
# b c . c . c . c b c
# b c . c . c . c b c
# .... .... dddd dddd dddd
# e f . f e . . f . f
# e f . f e . . f . f
# gggg .... gggg gggg ....
# 5: 6: 7: 8: 9:
# aaaa aaaa aaaa aaaa aaaa
# b . b . . c b c b c
# b . b . . c b c b c
# dddd dddd .... dddd dddd
# . f e f . f e f . f
# . f e f . f e f . f
# gggg gggg .... gggg gggg
total = 0
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
line = line.split(' | ')[1]
vals = line.split()
for val in vals:
if(len(val) in [2, 3, 4, 7]):
total += 1
print(total)

130
2021/8/main2.py Normal file
View File

@@ -0,0 +1,130 @@
# IDEAS(dev):
# - You might not have to determine all the positions if the numbers to decode don't use them
# e.g. while(number to decode NOT IN numbers decodable) { do everything }
# -
# NOTES(dev):
# - It looks like the codes are NOT always printed in the same order. For example, if one shows up
# as 'cg', it might also later show up as 'gc' in the same line.
# 0: 1: 2: 3: 4:
# aaaa .... aaaa aaaa ....
# b c . c . c . c b c
# b c . c . c . c b c
# .... .... dddd dddd dddd
# e f . f e . . f . f
# e f . f e . . f . f
# gggg .... gggg gggg ....
# 5: 6: 7: 8: 9:
# aaaa aaaa aaaa aaaa aaaa
# b . b . . c b c b c
# b . b . . c b c b c
# dddd dddd .... dddd dddd
# . f e f . f e f . f
# . f e f . f e f . f
# gggg gggg .... gggg gggg
# initialize shared data:
possibilities = {}
all_possibilities = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g' ]
# functions:
def ResetData():
possibilities.clear()
for letter in all_possibilities:
possibilities[letter] = list(all_possibilities)
def RemoveImpossibleLetters(good_letters, good_positions):
# generate inverse list of good_positions
bad_positions = list(all_possibilities)
for position in good_positions:
bad_positions.remove(position)
# first, get rid of the other letters from the positions used
for position in good_positions: # positions used
to_remove_list = []
for l in possibilities[position]:
if(not (l in good_letters)):
to_remove_list.append(l)
for to_remove in to_remove_list:
if(to_remove in possibilities[position]):
possibilities[position].remove(to_remove)
# second, get rid of the good letters from all the other positions
for position in bad_positions: # positions not used
for to_remove in good_letters:
if(to_remove in possibilities[position]):
possibilities[position].remove(to_remove)
def ParsePossibilities(text):
text_len = len(text)
# The easy ones first:
if(text_len == 2):
good_letters = list(text)
good_positions = ['c', 'f']
RemoveImpossibleLetters(good_letters, good_positions)
if(text_len == 3):
good_letters = list(text)
good_positions = ['a', 'c', 'f']
RemoveImpossibleLetters(good_letters, good_positions)
if(text_len == 4):
good_letters = list(text)
good_positions = ['b', 'c', 'd', 'f']
RemoveImpossibleLetters(good_letters, good_positions)
# This one straight up doesn't help:
# if(text_len == 7):
# good_letters = list(text)
# good_positions = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
# RemoveImpossibleLetters(good_letters, good_positions)
# The harder ones second:
# if(text_len == 5):
# Could be 2, 3, or 5
# MUST contain positions 'a', 'd', and 'g' in any 5-position number
# MIGHT contain positions 'b' and 'f' for FIVE
# 'c' and 'e' for TWO
# 'c' and 'f' for THREE
# if one of them is found with two others, it's either c or f
# if one of them is not found with two others, it could be b or e
# if(text_len == 6):
# Could be 0, 6, or 9
# MUST contain positions 'a', 'b', 'f', and 'g' in any 6-position number
# MIGHT contain positions 'c' and 'd' for NINE
# 'c' and 'e' for ZERO
# 'd' and 'e' for SIX
total = 0
with open('example_data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
ResetData()
split_line = line.split(' | ')
data = split_line[0].split()
# print(data)
codes = split_line[1]
data += codes
for val in codes.split():
if(len(val) in [2, 3, 4, 7]):
total += 1
for text in data:
ParsePossibilities(text.strip())
asdf = possibilities.items()
asdf = list(asdf)
asdf.sort()
print(asdf)
# part 1 answer:
print(total)
# # DEBUG(dev):
# print(possibilities)

100
2021/9/data Normal file
View File

@@ -0,0 +1,100 @@
5434456789899876598943212349988734679896554212468998765634987654567895454569876745567898765987654678
4421345997789997987894103458976521398765432101457897664529876543988987353478965434456799974398766789
3210237896698999876789214567895320129878543212346987543212989432499976212389876521234589867219878999
8732456934567987655678925679976543234999657323657898952101296521276895423467987420145678954323989987
7545678923979996544367899899997665379898775454767899843212398730145789439999876521266789765439896895
8656989019899985431257912978989876456789896569898998754324579821234679598787987632348999976598765434
9767893198769876542349943969878987567891987678959799867465679932348789987656899973467898899989754325
9899954599356987653567899858767898998910198789345689879876898655459892199767898765989987678978965434
0949765983245898974567986745656789429963239891256998989987998798767891019898999899899876569867896645
1239899874123798765678965432345678998754356999969897896998919999898942129919899989798765432956789896
2456999763235679976789876521012899569896567987898776645789423998989763298901698978679654321987899987
3567998654345789697894997863246789345989679976897655434678999887678954397992497761598767210198989999
4568998767658994598932987654959896559878998965689543212789989756545895986789986550349989321239878934
5679109978767893459891098799898998698766987654599652101299876542136789975498765431256999932349867995
6789299989878932398789129988797789797654598543688943212389987651012898996329765432367899893998656789
7898989899989321239679939878646678976543987654567894345678999954123456789319876783456987679899543454
8987674789996510398567898965434567895432398769878997656789298893256567892101989865597976545788932123
9876543668897932987678987654325478999421239878989989897892196799347878943212399876789876434567893015
6976542456789893498789798843412345678910129989095678998943985978958989954323498989899854323479992134
5988764567898789999895699752103456989321298792134578949959874567899699895434597898998769436589789645
3299985998976679891934987653212367895433397654236689939898765878934598789545986567899898998995679756
4399876789765456790949998654354567976564579864346789795789876989423987678959876456789987999754598967
5989987898874345689898998765667678987678679875467997674898997893219876579898965345699876899643457999
9874399987654234889767249879799899398788799986578998543456789979101985498787976458798765678952348688
9965456798982124678954123998989921299899899897789019432349892356919876987656897569987654569861234567
9878767899971012567893299897678930987943945798899929656478901237895988995434789978999543498990195688
4989879998753223456789987684567899876542134689967898767567892348954599986523678989898921987989989789
3292998987654345567899876543454979987698745798756789888678943456795678987434567898797990196578878990
5101997699865456878999987952123567898987656987645999999799764789989799398646678987686789987458767891
3219876439876767989789854321018798909998789398739898998999875699978989109798789999575679654345656789
4923987421988878994698765432134689212999899219898787887689987898967878919899899998434598743212345699
9894996210199989543569876987656789329896998998997645986567898987657567894902999896565679754103456999
8789765434567896532979987899769895498785987987987432345457899996543456793219899789678998765214667898
7679987545698987649899998959878999597654596576796541012345678987532345789398798698989439886356778987
6567899756789498998787899543999788999869989435987782134456989997431234678987654587892129987487899876
1456789987891349987656987682101677896998764324598943245667892986520345679976743476789098987598989988
2367891098942998876435699899323456795109875455799876368998901975421234567895432125678987798679769899
3458932989959897652123799998754789894298989569899965467999219876532345689984321014789976689789543767
6567899876798789943254889879875678989997898698999876567894334998765456796975432423899865579899632156
7678999865987656798765679765996899569876679987987987678999549769976789895496676534998784465978943234
8789489954698747899898789894597943456965569876756798989998998756987899932398987545797653234567894965
9896567893497656789989899989698952349893457954348899999867897645698998651239998676789543123456789896
4989678912399788997678969878999876599789569943235978987656798434569679962345999987898654234567898797
3479989101989899234579953967899997987679979754101567896546795320197599843469899998939764346678999689
2567893219876920123498842545798798996589898765243489998657896431989987654598788999323976487989898567
1457954998985431245987721234989659987456799876756678998798986549879999867998687896534987578998766456
0345699877896545679876510129878943298589890987987899989899598698768899979896556789649898789789654233
1258789565987656798765431298967892129678992999398987667965498797658789998787445679998769897698763101
3879895434598767899876532987656789098789979893219898548994349988546698987674324567898756989549874222
4989999323569899987989749876545699989898767689456798656789239975234567896532014687996545678934965434
5699888912479959876599898765434598878989954597997959897891098754123458976432123456789436789029896945
6789767893569542987456999876523987654567893456789542998943987653012369897643234797897647892198789896
7996556789698959898968998765219876543478932345698951019995698432123456797654365698998758943987668689
8954345678987998759979897654327989657899321234567892129889997643264567899895776789019869959876547567
9543287567896789543499789876456798798999872345678963498769898965459678999976798997998999898954323458
8762123456795678932987678976578979899698765456789954989656789878678989689987899756987889767895444767
6571012387894239321998489987678967989459889578997899876545995989789996577998987645986563456976655678
8432123456943145939876569998989345678967998789756798765634894399898895456879995429876432356897779899
7543234579432019899998678989492235678979679897645987654329795210956789327467896539994321237998989931
8654345678973298799659989976320136789989536965534598965418689632345893214357987698789435398949995432
9765566899954989578945698765431246789997645984323459876324596543456789301236798797698945459539876543
9878987899869876457936789987543657894987659876775767988765797786569895212545679987567896579321997654
9989398998998765346897894697654769923498767987899878999896789897678954323598789498678987678932398895
9899459987679976456789923498767878939999989998910989999987894998789765499989892349989698989993979976
8798967943568989769893212459878989998791299879322398989998943769999876987878991234596439498789765987
7667899652456899878976493967989399876689399965443987878999542356789989776456789949697321334599654598
6545678943597956989987989898996598985545989987559876769897669467894597654345699898989210123498963239
9436789894989439997899876789987987694234567897698765458789798978932987543248998767678933234987892134
8997898789878998876799985689998975543123458998789987345678997989321997654367999856577894549876789045
6889997679767897545989654567899984321012567899898753234789986899439898765456897845456789698765692156
5679986545656989439876543678920995443227679998999864565699875778999789996567986434345698799754589267
4798765434745778924987762399439876654535789587998765699789564567987678987698954323236789988643678979
3987654321434567995699843489597987765678996476899876789895423459876569299899875210127999876512889989
2398776410123456789987654578976598978789875345789987899964312346975489101999986321239899974323690198
1459898531234587898798767678965439989999954234598798979975423769876594312398765432349798765434569297
2699876542346678997649878789432123499999876345987659567897569878987694324569898543498659896565678956
9989987843656789989432989896543034578989985456798741456898689989299789455689987654987545987876789245
8978998654567897678921299987652145989979876787899432346789799892109896596798998965696534698987992123
7767899765678976567932349998543267898765998998989753456899896789512987989987899878987623499698993434
6456789878789995478945678997654379987654989999978999567899945695423499879876789989998834988549889645
2348995999998989599656789998765459998769877898765688979998956789534598766545679199876549876534678956
1256893212987876989767899869876567899898756987654567999986899899976987655326989298987698765423459867
2367999323986765878998987656987878998999967898323457899875798999897898543201399987598789879210678978
3478998939765654569999896545698989667989899999212345899964567898799939954912568898449899984321289989
4989997898754343456789765434349893459879798987463456789643456789688929899893456789234989965434567896
5678976798773212345899984321256789599965667896554569896532567894567998789789598894345679876565778965
6899995987654301236789876532367899987654356987789678997321013789679876545699679965956789987876789954
8987989998765312447897987688456789998543234598898789398432123678989999433488989989897999998998899895
9766767989876493558965499786567896987652105679999891298743454569999878521367893198769899899899966789
7654555679997989967894329897898945698543212589899999987655677678998765310456789976556789765732455894
6553334899989879898965469989999334987654323456789678998766788889429896321367899896345678954621234932
5432124578978956789876598976989219999768454579894599659877899995434975433698998765234579543210129891
6543023569864345699997986745878998789879767699923589547998998989565986844589987654357897654521656790
9632123479983234567898965434567899667989888789013478936669987879976987865679999866468999865632347891
8743244569874347689999874323456965456795999993123569425459986567899898979789899998567899876774458942
8654456798765456790198765201597896568954987654256989312398765458968799989897789219778945988765667899
9987587899976569891239877332387899878943298965345993201239954349355689997956678909899434199876789978
1098788998988789932545976545456956989652129876556789713498765693234598766434567899974321019998893459
3129999987699896543489988758969139898761034987679899654569876789345679654323489998765432198779902345
4534567898799987654578999767878956789432156798789998775678987895468798765434591249976545698654323456

5
2021/9/example_data Normal file
View File

@@ -0,0 +1,5 @@
2199943210
3987894921
9856789892
8767896789
9899965678

44
2021/9/main.py Normal file
View File

@@ -0,0 +1,44 @@
data = []
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
data_line = []
for ch in line.strip():
data_line.append(int(ch))
data.append(data_line)
total = 0
for y in range(0, len(data)):
for x in range(0, len(data[y])):
sub_total = 0
all_four = 0
# above
if(y > 0):
if(data[y-1][x] > data[y][x]):
all_four += 1
else:
all_four += 1 # skip
# below
if(y < len(data) - 1):
if(data[y+1][x] > data[y][x]):
all_four += 1
else:
all_four += 1 #skip
# left
if(x > 0):
if(data[y][x-1] > data[y][x]):
all_four += 1
else:
all_four += 1 #skip
# right
if(x < len(data[y]) - 1):
if(data[y][x+1] > data[y][x]):
all_four += 1
else:
all_four += 1 #skip
if(all_four == 4):
total += data[y][x] + 1
print(total)

95
2021/9/main2.py Normal file
View File

@@ -0,0 +1,95 @@
data = []
low_points = []
with open('data', 'r') as fp:
# NOTE(dev): We assume all lines are the same length
for line in fp:
data_line = []
for ch in line.strip():
data_line.append(int(ch))
data.append(data_line)
total = 0
for y in range(0, len(data)):
for x in range(0, len(data[y])):
sub_total = 0
all_four = 0
# above
if(y > 0):
if(data[y-1][x] > data[y][x]):
all_four += 1
else:
all_four += 1 # skip
# below
if(y < len(data) - 1):
if(data[y+1][x] > data[y][x]):
all_four += 1
else:
all_four += 1 #skip
# left
if(x > 0):
if(data[y][x-1] > data[y][x]):
all_four += 1
else:
all_four += 1 #skip
# right
if(x < len(data[y]) - 1):
if(data[y][x+1] > data[y][x]):
all_four += 1
else:
all_four += 1 #skip
if(all_four == 4):
total += data[y][x] + 1
low_points.append(tuple([y,x]))
print('Part 1:', total)
bin_sizes = []
for point in low_points:
points_to_check = [point]
checked_points = []
while len(points_to_check):
p = points_to_check.pop()
checked_points.append(p)
cur_y = p[0]
cur_x = p[1]
# check left
if(cur_x > 0):
if(data[cur_y][cur_x - 1] < 9):
left = tuple([cur_y, cur_x - 1])
if(not (left in checked_points) and not (left in points_to_check)):
points_to_check.append(left)
# check right
if(cur_x < len(data[0]) - 1):
if(data[cur_y][cur_x + 1] < 9):
right = tuple([cur_y, cur_x + 1])
if(not (right in checked_points) and not (right in points_to_check)):
points_to_check.append(right)
# check above
if(cur_y > 0):
if(data[cur_y - 1][cur_x] < 9):
above = tuple([cur_y - 1, cur_x])
if(not (above in checked_points) and not (above in points_to_check)):
points_to_check.append(above)
# check below
if(cur_y < len(data) - 1):
if(data[cur_y + 1][cur_x] < 9):
below = tuple([cur_y + 1, cur_x])
if(not (below in checked_points) and not (below in points_to_check)):
points_to_check.append(below)
bin_sizes.append(len(checked_points))
bin_sizes.sort()
total = 1
for i in range(len(bin_sizes) - 1, len(bin_sizes) - 4, -1):
total *= bin_sizes[i]
print(total)

2238
2022/1/data.txt Normal file

File diff suppressed because it is too large Load Diff

57
2022/1/main.cpp Normal file
View File

@@ -0,0 +1,57 @@
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Couldn't open file." << std::endl;
return -1;
}
static bool last_line_blank = false;
std::vector<long> numbers;
long total = 0;
long most = 0;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
{
if(!last_line_blank)
{
numbers.push_back(total);
if(total > most)
most = total;
total = 0;
}
last_line_blank = true;
}
else
{
last_line_blank = false;
total += std::atoi(line.c_str());
}
}
std::cout << "Most: " << most << std::endl;
std::sort(numbers.begin(), numbers.end());
if(numbers.size())
{
int three = 3;
long total_total = 0;
for(int i = numbers.size() - 1; i >= 0; i--)
{
if(three-- > 0)
total_total += numbers[i];
}
std::cout << "Top 3: " << total_total << std::endl;
}
return 0;
}

38
2022/1/main.rs Normal file
View File

@@ -0,0 +1,38 @@
use std::fs;
fn main()
{
let contents = fs::read_to_string("data.txt")
.expect("Could not find data.txt.");
let mut numbers = Vec::new();
let mut total = 0;
let mut max = 0;
for line in contents.split('\n')
{
if line == ""
{
if total > max
{
max = total;
}
numbers.push(total);
total = 0;
}
else
{
let i = line.parse::<i32>().unwrap();
total += i;
}
}
println!("Max: {max}");
numbers.sort();
let mut top_three = 0;
for amt in &numbers[numbers.len() - 3..numbers.len()]
{
top_three += amt;
}
println!("Top Three: {top_three}");
}

2
2022/10/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

146
2022/10/data.txt Normal file
View File

@@ -0,0 +1,146 @@
addx 1
addx 4
noop
noop
noop
noop
addx 6
addx -1
noop
addx 5
noop
addx 5
noop
noop
noop
addx 1
addx 3
addx 1
addx 6
addx -1
noop
noop
noop
addx 7
noop
addx -39
noop
noop
noop
addx 7
addx 3
addx -2
addx 2
noop
addx 3
addx 2
addx 5
addx 2
addx -8
addx 13
noop
addx 3
addx -2
addx 2
addx 5
addx -31
addx 36
addx -2
addx -36
noop
noop
noop
addx 3
addx 5
addx 2
addx -7
addx 15
addx -5
addx 5
addx 2
addx 1
addx 4
noop
addx 3
noop
addx 2
addx -13
addx -16
addx 2
addx 35
addx -40
noop
noop
addx 7
noop
noop
noop
addx 5
noop
addx 5
addx 10
addx -10
noop
noop
noop
addx 3
noop
addx 16
addx -9
noop
noop
noop
addx 3
noop
addx 7
addx -32
addx 35
addx -38
addx 22
addx 10
addx -29
addx 2
noop
addx 3
addx 5
addx 2
addx 2
addx -12
addx 13
noop
noop
addx 7
addx 5
noop
noop
noop
addx 7
addx -6
addx 2
addx 5
addx -38
addx 1
noop
noop
addx 2
noop
addx 3
addx 5
noop
addx 4
addx -2
addx 5
addx 2
addx 1
noop
addx 4
addx 4
addx -14
addx 16
noop
addx -13
addx 18
addx -1
noop
noop
noop

146
2022/10/larger.txt Normal file
View File

@@ -0,0 +1,146 @@
addx 15
addx -11
addx 6
addx -3
addx 5
addx -1
addx -8
addx 13
addx 4
noop
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx -35
addx 1
addx 24
addx -19
addx 1
addx 16
addx -11
noop
noop
addx 21
addx -15
noop
noop
addx -3
addx 9
addx 1
addx -3
addx 8
addx 1
addx 5
noop
noop
noop
noop
noop
addx -36
noop
addx 1
addx 7
noop
noop
noop
addx 2
addx 6
noop
noop
noop
noop
noop
addx 1
noop
noop
addx 7
addx 1
noop
addx -13
addx 13
addx 7
noop
addx 1
addx -33
noop
noop
noop
addx 2
noop
noop
noop
addx 8
noop
addx -1
addx 2
addx 1
noop
addx 17
addx -9
addx 1
addx 1
addx -3
addx 11
noop
noop
addx 1
noop
addx 1
noop
noop
addx -13
addx -19
addx 1
addx 3
addx 26
addx -30
addx 12
addx -1
addx 3
addx 1
noop
noop
noop
addx -9
addx 18
addx 1
addx 2
noop
noop
addx 9
noop
noop
noop
addx -1
addx 2
addx -37
addx 1
addx 3
noop
addx 15
addx -21
addx 22
addx -6
addx 1
noop
addx 2
addx 1
noop
addx -10
noop
noop
addx 20
addx 1
addx 2
addx 2
addx -6
addx -11
noop
noop
noop

154
2022/10/main.cpp Normal file
View File

@@ -0,0 +1,154 @@
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
enum Command {
NOOP = 1,
ADDX,
};
Command ParseCommand(const std::string &str) {
if(str.size() < 4)
return Command::NOOP;
std::string head = str.substr(0, 4);
if(head == "noop")
return Command::NOOP;
else if(head == "addx")
return Command::ADDX;
std::cerr << "Missing command type \"" << head << "\"." << std::endl;
exit(-1);
}
void StepCycles(long &cycle, const Command &command, const long &x);
void IncrementAndDraw(const long &x, long &cycle);
long Report(const long &cycle, const long &x);
void ApplyAction(const std::pair<Command, std::string> &command, long &x);
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
std::vector<std::pair<Command, std::string> > commands;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
auto cmd = ParseCommand(line);
if(cmd == Command::NOOP)
commands.push_back({cmd, ""});
else
commands.push_back({cmd, line.substr(5)});
}
long cycle = 1;
long x = 1;
for(const auto &command : commands)
{
// Step 1: Increase cycle count of command to see if we would have reported
StepCycles(cycle, command.first, x);
// Step 2: Report, if needed:
total += Report(cycle, x);
// Step 3: Perform command action:
ApplyAction(command, x);
}
while(cycle <= 220)
{
StepCycles(cycle, Command::NOOP, x);
total += Report(cycle, x);
}
std::cout << "Ended on cycle #" << cycle << ", value of x: " << x << std::endl;
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}
void StepCycles(long &cycle, const Command &command, const long &x)
{
switch(command)
{
case Command::NOOP:
IncrementAndDraw(x, cycle);
break;
case Command::ADDX:
for(auto i = 0; i < 2; ++i)
IncrementAndDraw(x, cycle);
break;
default:
std::cerr << "Missing ability to parse command type." << std::endl;
exit(-1);
break;
};
}
long Report(const long &cycle, const long &x)
{
static long last_reported_cycle = -20;
auto next_cycle = last_reported_cycle + 40;
if(cycle > next_cycle)
{
// std::cout << "Cycle #" << next_cycle << ": "
// << next_cycle << " * " << x << " = "
// << next_cycle * x << std::endl;
last_reported_cycle += 40;
return next_cycle * x;
}
return 0; // no change
}
void ApplyAction(const std::pair<Command, std::string> &command, long &x)
{
switch(command.first)
{
case Command::NOOP:
// std::cout << "NOOP" << std::endl;
// noop
break;
case Command::ADDX:
// std::cout << "ADDX " << command.second << ": x goes from " << x << " to ";
x += std::atoi(command.second.c_str());
// std::cout << x << std::endl;
break;
default:
std::cerr << "Missing ability to parse command type." << std::endl;
exit(-1);
break;
};
}
void IncrementAndDraw(const long &x, long &cycle)
{
static int drawing_index = 1; // 1 to 40
// NOTE(dev): using -0 and +2 instead of -1 and +1 to account for 0-based vs 1-based
if(drawing_index >= x - 0 && drawing_index <= x + 2) // within one or on target
std::cout << "#";
else
std::cout << ".";
++cycle;
if(++drawing_index > 40)
{
std::cout << std::endl;
drawing_index = 1;
}
}

2
2022/11/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

56
2022/11/data.txt Normal file
View File

@@ -0,0 +1,56 @@
Monkey 0:
Starting items: 93, 98
Operation: new = old * 17
Test: divisible by 19
If true: throw to monkey 5
If false: throw to monkey 3
Monkey 1:
Starting items: 95, 72, 98, 82, 86
Operation: new = old + 5
Test: divisible by 13
If true: throw to monkey 7
If false: throw to monkey 6
Monkey 2:
Starting items: 85, 62, 82, 86, 70, 65, 83, 76
Operation: new = old + 8
Test: divisible by 5
If true: throw to monkey 3
If false: throw to monkey 0
Monkey 3:
Starting items: 86, 70, 71, 56
Operation: new = old + 1
Test: divisible by 7
If true: throw to monkey 4
If false: throw to monkey 5
Monkey 4:
Starting items: 77, 71, 86, 52, 81, 67
Operation: new = old + 4
Test: divisible by 17
If true: throw to monkey 1
If false: throw to monkey 6
Monkey 5:
Starting items: 89, 87, 60, 78, 54, 77, 98
Operation: new = old * 7
Test: divisible by 2
If true: throw to monkey 1
If false: throw to monkey 4
Monkey 6:
Starting items: 69, 65, 63
Operation: new = old + 6
Test: divisible by 3
If true: throw to monkey 7
If false: throw to monkey 2
Monkey 7:
Starting items: 89
Operation: new = old * old
Test: divisible by 11
If true: throw to monkey 0
If false: throw to monkey 2

114
2022/11/main.cpp Normal file
View File

@@ -0,0 +1,114 @@
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
enum Operation {
ADD,
MULTIPLY,
};
class Monkey {
public:
Monkey(const std::vector<int> &starting_items, Operation operation_type, int operation_amount,
int division_by, int true_monkey, int false_monkey)
: items(starting_items), operation_type(operation_type), operation_amount(operation_amount),
division_by(division_by), true_monkey(true_monkey), false_monkey(false_monkey)
{
}
friend std::ostream& operator<<(std::ostream &out, const Monkey &monkey);
private:
std::vector<int> items;
Operation operation_type;
int operation_amount;
int division_by;
int true_monkey;
int false_monkey;
};
std::vector<int> ParseItems(const std::string &line);
std::pair<Operation, int> ParseOperation(const std::string &line);
int ParseDivisibleBy(const std::string &line);
int ParseTrue(const std::string &line);
int ParseFalse(const std::string &line);
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
std::vector<Monkey> monkeys;
int line_num = 0;
std::vector<std::string> buf;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
{
if(buf.size() == 5)
{
auto op = ParseOperation(buf[2]);
monkeys.push_back(Monkey(//std::atoi(buf[0].substr(7, buf[0].size() - 7).c_str()),
ParseItems(buf[1]),
op.first,
op.second,
ParseDivisibleBy(buf[3]),
ParseTrue(buf[4]),
ParseFalse(buf[5])));
buf.clear();
}
continue;
}
else if(line.starts_with(" "))
buf.push_back(line);
}
for(const auto &monkey : monkeys)
std::cout << monkey << std::endl;
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}
std::ostream& operator<<(std::ostream &out, const Monkey &monkey)
{
out << " Starting items: ";
for(auto item : monkey.items)
out << item << ", ";
return out;
}
std::vector<int> ParseItems(const std::string &line)
{
return {};
}
std::pair<Operation, int> ParseOperation(const std::string &line)
{
return { Operation::ADD, 0 };
}
int ParseDivisibleBy(const std::string &line)
{
return 1;
}
int ParseTrue(const std::string &line)
{
return 1;
}
int ParseFalse(const std::string &line)
{
return 1;
}

2500
2022/2/data.txt Normal file

File diff suppressed because it is too large Load Diff

127
2022/2/main.cpp Normal file
View File

@@ -0,0 +1,127 @@
#include <fstream>
#include <iostream>
#include <string>
enum RPS {
Rock = 1,
Paper,
Scissors,
};
enum Result {
Lose = 1,
Draw,
Win,
};
RPS ToRPS(char c)
{
if(c == 'A' || c == 'X')
return RPS::Rock;
else if(c == 'B' || c == 'Y')
return RPS::Paper;
else if(c == 'C' || c == 'Z')
return RPS::Scissors;
std::cerr << "BAD DATA '" << c << "'." << std::endl;
exit(-1);
}
int RPSScore(RPS rps)
{
switch(rps)
{
case RPS::Rock:
return 1;
case RPS::Paper:
return 2;
case RPS::Scissors:
return 3;
}
}
bool Won(RPS us, RPS them)
{
if(us == RPS::Rock && them == RPS::Scissors)
return true;
else if(us == RPS::Paper && them == RPS::Rock)
return true;
else if(us == RPS::Scissors && them == RPS::Paper)
return true;
return false;
}
RPS Which(RPS them, Result desired)
{
if(desired == Result::Draw)
return them; // same
switch(them)
{
case RPS::Rock:
if(desired == Result::Lose)
return RPS::Scissors;
return RPS::Paper;
case RPS::Paper:
if(desired == Result::Lose)
return RPS::Rock;
return RPS::Scissors;
case RPS::Scissors:
if(desired == Result::Lose)
return RPS::Paper;
return RPS::Rock;
}
}
int Points(RPS us, RPS them)
{
int rtn = 0;
// score our play:
rtn += RPSScore(us);
// tie:
if(us == them)
return rtn + 3;
// win:
if(Won(us, them))
return rtn + 6;
// loss:
return rtn;
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long new_total = 0;
for(std::string line; std::getline(ifs, line); )
{
char them = line[0];
char us = line[2];
Result r = Result::Lose;
if(us == 'Y')
r = Result::Draw;
else if(us == 'Z')
r = Result::Win;
RPS todo = Which(ToRPS(them), r);
total += Points(ToRPS(us), ToRPS(them));
new_total += Points(todo, ToRPS(them));
}
std::cout << " Total: " << total << std::endl;
std::cout << "New Total: " << new_total << std::endl;
return 0;
}

300
2022/3/data.txt Normal file
View File

@@ -0,0 +1,300 @@
vGFhvGvvSdfwqhqvmCPnlFPnCNPcCFcWcr
ZbWZDMgsTHsrNNLJcJnsJl
HbBWQgZVZZBzbgZphwjqpmmVfdGmjG
vvCJLGnthChvtrvCCnRbTRqRPRBtbTRfPRRl
djZSgHNNwjqcdWlbcbfc
pFgMSfpMfzMDZFSgSjGJQQnCvMCVLnnJQLGC
gVhQWQpcWZVwwHVvFvnnnnDFdL
lzbPlztjltztzSjfGcPdTHLTHFCnnHCLndFGGd
jsNbzbczclttSlfbqlljRQMJRMMpJwRZhspZgJRM
hLJvfGcNDttSGvJtvSSJcqbqFBBWbjQqDrqbjDDjjb
lTswlzZdssgFpdPwZpMQnCjngCCjWBQBWWQqng
PRZMpzPZTdVZTfJvFvLFRctJcf
JHbQtHVHHLLbTJmmZddgdgwhllMNhhhTgg
spqpNGDjDPMhCFChMj
DBSDDGnpSDsDWqWczcvSqWvsBtJJLLZrRVZLJRbBZNVrBHrV
GwGhfhPhpHccvwSwrTsmsCjDmqTfbDqjss
tQntQcNRJMFnnVQFFctJqCsRmsTjjbDqDlTqTbWT
NZdVBZZNFzMFNNNvGprZcLGPGrrpcP
SvCPLrrlCSvZLrCPPBNPRvNLQBbpmbdggQTTfpfQgpgTqbbb
HVjHwMVwWtdMGwtwMwdhDFgbJgJqTmFMfFfmmfTTpq
whtHVcjDtHWtsWdwVGVHthDPzRrNSsCRLrLRlZNzZSNzNR
rjrlCCBtbtntwPPt
FvfJHqBJQWWgWgWLwnMwMLbzvhwTTp
WqHgWqBFgGfQgHfVdQFfVfrDllSsRSDmVmRCZZmSSSSZ
gjnppCgGHNPrqqmFnnbr
tGltVlJRtLRlrqcJcqZDqBJc
VvhLlvWltWdVltRTLTfgwSjGNHhggQNQNjps
HDWjCNfQjmwgWhcwPPVbZGcpMb
sFltFBRRSRJBSSsBlSSnRLPZbVGMVPZpMpPZpcMrFZMc
BLTBsstlqBRRBSvJJBsHdgdDNHCQHvbdCjQNNW
lRGzWLZNFwJVbVVGcJ
HqqpjPvHQnJgVgTnbdTV
rVvjBQHQrQhCrzlzWrRlDZ
jZjTZRSjZnhGZhzGnG
HbnPHrCbBDMnhcrVLWWLLWWg
MBwbCNDDptwNMttjdSnsqSRSFFdjtj
bSfvcsNsDdccHHQm
ljrlplvBhDHDHHHHJl
jgpzhrzRrvhFRFrzFnWfZtTwSWZPbbqNbsTqsW
vvCTvcDzHcgtvWjvcDcvgBCgwTdPFPpwpwmTSwwmdPwZpfZh
rNLMNVqLGNrVsRNJNsPnGnnfnpSFGdfddndd
VPQsMbVsPbzzvgCzgv
wPsrqprHQQZsChZn
cjgFLwWDlDltfLmTCnmWCnZZChCQ
FccccSLGFwjVlfVLLtgdSPSpMpBMdMBRRdHdBp
mQQcpmCCprrfLQqZVGqLGv
PtsJdsMtTTTvFqLTnnqbGZ
HjldthsHWztJzstZhBcHDDgpNpCpmrpgSD
lCmhDljDJgWggcnh
LdQrbdTDQGfGLPdqqFrHwRJcWRHgHBWHBJ
sLqsGtDqdGQfSTsqtfqqVMzjCzlvllZljNpCsMMl
CfLCZCCqqHlhSSrrtpRjpL
mWQbnQZVTWwNdwmDSbpbrFptjDrjRj
PJWVnTWPVnnclqqBsCCZHP
tqvtbNCgqJSgZgZvSncrrcGjBGhcnVcR
DswGQQQdRcjBnRDn
sMdlFMQQpfZbvlNtZGgN
RMlPllHtrlrlcZLsZfLcfwdDGD
QppnQhTBgwQDJsGzLQ
gTjnmjvphDSNMbtMbtMRHNVr
RHHcChrVVChCWQmRnMZmnmbTbGmFnqTT
gpzpfpszDwvDDNdwjdstnSMMHGMqvZnFTTZqbq
DsDdpfppwHsgJdjzfdDjdssLPlRccPQQrJcchPQWWQRhlQcr
rsrjQjnRnQZZqMmMMVqs
WTSTdvJLvTGJTGCMGvzBBpVVqqFVzBzVmf
tTSJhGLJbJhLJRRbHPQbnHHMrl
GGgMgBJHWHhLWMhWhgfrhgWLzmsmlzTtzHmsmlszRtszRVlT
bvScppfcQfcQSFCQpnPqwwTdRTvmzVssvswtddsv
ZDpqnPbQbPPnQbFbfSPSqbQJhGrjgMZBhWLrLrBBBBJWhg
hQCCGCNhDmGFJsTt
fcggBBpvBSrtsRTpRmpD
wflWlBlfnvfWWgMNPPLhPnzhPmLQ
pcGGTvVpcQLLzSPPPpVBVQwngNqgsJqgJgqSngsJMqJg
RZDFGhtCDGmWfWsNdwJhnMgwswqJ
ZCGjRGjZllFGHvvcTPjPTQpB
FDVsWrFZnnnfNRJdgBBBMLsJLH
wcThcTphvCThwTlblpzwGlpLRgHJWLgHLBHdHWJLBLWR
mwcbPmClwlzlwvvbTmWbQSjZmZSrDnSNVZfVFnZf
tMlttlFRSrcSFcwQSRwSzrMMPPGGPGLWgNfTNTcLPNPGBPPG
pbZVCDTqnCjVDHnHVnhBPBBbhBhbhgLgmWLh
qZCJZJqqjjCVvvRQltlzTrJtMMMw
QvvdBDdMbdFFJrMMjjmjCfCntC
lHTPsNLPcfVZLnfj
GgsWpHPpTPWpNsGvgdnDbQRQFRbdQg
jPNwllsVZjhslSjwGShZMdJDmmdmWLtMDDPHMPFd
QbvpDrbBrtMbbHJmcH
vznvzBRpBprQBqQZjNswwZDnSlGjZl
PdNTzLQPLrVMzGcMtt
FsSvDrvmrwDggHGwgV
vlpZpZmfnmFTlTWJWdbrdh
mZmnggMTSJrrmnrbmTbngJMtwPvwzzRvPGhQdGZPGPLvGvRd
FFVBNHVlFlDfCsWwLwPzzhGPCvzhQv
qBHLsDcfqFfDDfsFLNcNNBFsrgpMpnJSbnmTnrtmbMSqnpnr
qjBNwBPNPspqddssbsTsMDhTDrThQb
gvzZSZzFbgHnrHmn
fcvfZcRSZFGfZcvFbGttcPfpVjWVwqBqdwNdwNNpqV
RrTmtTrqznrnRCSqJrWlWDbhWVnfVDVWdclV
QBBgHQGvHHQswLHQQLGLHdLhfhlZZFlsscVDZfWfDhVlZZ
dLBMPpGPjLHPHPBHjjgQjHQztSJRztmrNCSCmSpmprrrrz
HHWJgjjsJrPBWBjgWgDvbbvtbNDNVtttMPPp
SnLTlhhNSntRVVLFVbbb
ChqdcNTNqqJCrQrQrrBC
BvfLLngFLDrrlDFDDnGmGlmzqzdGqMMWWwWW
RVsPbsbVZbjctccCcsCSPmdNqMqMWddwqVzhhNHwHd
tcsjPZRctZTSbbtSbtsSjZznnJfJBrfJgLvJJDDBvpTrgp
LJJsNdtJQtbWRJQttjGhjVnjcnzcsczGqj
MDPPlvCwrTlZfMMvTlPTdVcVhVVjchSBrjccSnnq
lgZCvTTZfMgHLptdRgmR
gCDrJRNgJDZRCwMgqGbtVVjTjlFbbTtR
mccnfcnSQScdvdcQQQpWdnWSjPqTbFFlbPqbPVGNjTPjtN
NnzmpWmBBzzpzDgwhDghrZrw
wcbVDBQwVBFQLFQDQcqQcLcJfpHJjmljGgMHfcfgGgjf
PtnWMtSnlgJmWWmm
nThPtRnzntstvrtRPqDFLMLdDwBBFLQDBT
zshqnVqTwqHqZQgZDSZjpFjFFF
PsBRvttdcgFFBSmc
GlPsbLtrvrrrtJlCTnVTlwwfnhwVqH
CvVVnFwWZnZwJZMNlCMNMpbMrrQG
cpghqzqqtzbGMjTNclGN
PqLBsgqBsSfBffShVmvRVwWsFpwZVpsn
LzsLSScvscqNdGdgddQjCDbzhpCDbRbhDpDDwDwt
ZlMBBBnlMFVFHVMJflJjJBfhRnCbCDpRttRPDCbWpCRbpW
mlrFmJrmscNGmsjm
FqQjLRjfvTFvlPHHNPMBDDNDPR
chWptpcWTzBPMsMMMBHW
zcJghwJZpZcgnctccdzzpGQrbQbblFFlTCCFTbdCFCFq
QcwNpCcQzpwtCGPPPnrGrfHfvN
FgjhhhjMVFVjqRRqDBVBqvMZvdrHnPZWZvsnZHdWnv
ShBFhDVghhTBgBBFRRgRCmCPCcpPbwCmLTcCmbpb
ZzlzsBzZnWnsBhFRvfvvLfWqfvMv
GgQGjjddHHPwpHpTGjPdHMvtvwJqLtJRFlRFRqMwLc
dgbbdjpGGgTHGGgQgdpmpgblrBrhrhCBSSznChsVhBsmNB
PhSwPdnpsmSWWcjjDFNqnc
GJGCTLbTZTrlfflVLFchHDHHDFcVVN
RhlhrllQZhCsPvRBvMtSvw
GVgnrgTWGVGjLVjWSpvvNmPTmpQmzvhf
tBbBDsFtszzSSbPZbh
BqlqdcqSJtFMdMjWrnGCWRrWGG
sJVJsQhMhPPSQMwdHRmmsmmwRmsr
zLFjLDTBFNWWwrqrffldlRdFRq
BLjzjTpzLpzWGTbQpMJvVMQwQhhMQM
RqSztDRhJDLmRMLlfvsP
dMdMMHZCsnbdvmbP
VHcZVVcZTwTQpgHQcgFMFBpDDzBqqqDhqJSjSjJjSD
rdMnMGjdHhfnjqWWDJPpGWPtvW
PTBSQSSzZSBSCzQFFSlZTFSvcZpWWcJvtJppvZpLLcDVcv
sgQCsBmmlFCPFFzTgTBgdNnrNndnMrrrfbrNjf
bpZdggTjHbgLglpHjldvHpjdhTVzmhzzzFPzmhFsFQSFnhhN
rPCDBcCCMPGcWDNNWQzQQSNQnNzQ
fCCJtDtGGGfGBtGqBrrcfRBcvPwpLgdZZvHdljvqpvdwbpvl
qpmsNldnlHlCqQlHsHNHwJpJMtwvvvjMvfWjpDtt
TccVBScrzBzzTGPbVTPQhWjfMjwwRtJtjMtWDWWfDS
FQFbzBGczGBFLnFmmqsCLg
qpblblvpvJzStJDrhrnGrdhDfFqf
ggNQNwBgmTcgCBTBTQQjNfDCnZRRRrRGCnrFfdnhrC
mjVFHQTHNjTwcmpzJzHltltbSssS
WChWmdcmzndhFcZrrbvrVMVssj
NQLDlDplpSJGpLfRRMZVBBGjVsGbbjbBZsGv
QNDfNqlpLgSfNfNgNfpgpqwndwWwnCCnnTFMdHndzn
ZGRPTngTZMSGMGnhSgRjQHsPbqjmsWHQCQWbNN
BFLLfpzVDBfDdlfQcsbVcNmQsqqbcC
zFvdplLDLtzFmrrwMMtTrShZ
nTdmnVCGqTsSBTqv
HlMPwMlHfPSfBBmFBfSL
trHHwRHRwMHPMJQJHnDhbdRhdpCZmChNnd
lwHWjzplvHqWHGsMLsLwLfgdfLdg
tPJNPQmQmSGcTtFmctGmSCBgsBBRbLBRVdLVLCBBLgVf
FPtTPQNPrPPQctTcNPSQJJPDjlzplnGDDjWWplWHhGvpnr
jwvvDbvsRsrrjrfvfrrZsPpCpmPJJPqlqWmzRJRTqq
HdLttdSQHdLHMMtNdLMSTtHpCmPplWhCzmzmPWlJhlNplP
BTSLtLLQtnVZDnffbwfw
snvQdrtrQprWpgmGLp
FhzwlwHccBcljFBSDmHmLpgRmPDCffWL
zFhllqjczzwJqqSqlZMsvJgVNMTbssVNnQbb
dLZHrWjWPFZWZnPjZttjddFnMDVMGJMQqvMVGVRVpjVpGVvv
zhzTwTlfTwCsShSgNhfzsQQqvMQStQMDGJJGvGQVvq
TTwCBfsfBwhzwTBCzlmHZdLmBBbtLnLbFnnF
BhBRLFmlBlmhgShHmhSlZlFgvbQNwvcsvMCcsQCwNQvNMsBw
ttWddDjrfjDcssscDbvH
jfjfPWdzdfjdnWpjtrzqnhmJGJFhSJRHSmSmlqlHmq
QvJTgvsvghHRHHNbZvNZTRSzBBCLrDqzrfDDtJSqSLBC
cPPwdcFFPDwfFrBrFfFfrC
nppwdplpRvllsgDH
BGLLWLLwHVZwHnNhwsMsrqMqhh
STlTpDpmjzmjjjgccqdsbNbBhlNnNMhsqs
pjmgjfSDSzmSgFzRZQfRRZLBVLVtZZ
WHjddztMtVLNNFFTmbFPFPRw
bJnvpQfqccQJZfpcbvCphcFGDPFGRwDGDDGwGsmPFnPF
rvffQJZJqrpZCJZJQrQpvBvStlSWSzVSWBbzBLzjtjWWWj
SJFMSMGSDLTsFgHvHL
mNzRrRRzjzqqgPHvLTHjlvWg
ZLbRpRnRnCrbmnmrRRNnwbGfMwDwfDDdSVMdVJdd
nsqTbhcDssPsPWsnchPJMSTSMmJMwTSTCJJfJw
DHvFvvdHpvpGFHDMVVJVplCCVpggCl
RdQjtvHtDQNGsZqzcqPqbNcq
GFzRjczzQJnLjJvvTj
mSfHrNHDzHDrDSSSBvTZLTNqWJWBWLlv
PfgCmfPzDVrtHsddVMsRFcVFQM
sfBgfBfBsHBHFGhsqfjgQZtQQMdZgbZQptbM
rNLRSzRTrrvvLSTWGpjpNZdQPtGtMdNM
wvSWLwzTGTCcwwwJwvwcrcRcVfFBqhhVhDqhBllBfFqBCDCs
LbTpDTcMTSzzMLhScnDnSppNQwVNZFBVnFsrwQQZrQrQrN
tJtJCRlGWljGWCtjJZVPsJBsVwQmrQNN
fvHRftqjGfWGwtfGqvLTzDTzzzchSbMDTd
JJhWZlhqLDHtBDrqrB
bwwmfrSmbmFjVSFQwSdpDvGdpPnRvDtHpGtGPG
VgFfcSQfFgmLLrNThllTZc
QmfvrpnvrrJGnBSCFTBMSWFS
NVMggbVPzCTgDFDD
NRqHRZjVRZdRVdZwNPrMrchGhGpcGfvhQlHJ
nlBdCldndlZTttSSBBccPfGWLLHcTTcWPbbW
jpsFzFmzDzNzDGChGcGGmPQHQf
CNzqvvVJNFqvgRtlqRtdnwSZ
MJtDbNHDDpmVPJVzzjLm
RslhvlfRTWvWWRwfllSZngmggznjSPznLjmSnz
TlhffRwWQhChDqbBQLFHqNrb
HWnmSbzflWltlzLfWWDzjMBvCjjCTCgcMvzBBB
qRRRZJwhZFGdRNfghVjMVVgfcghC
QFFqwNNNwdNZZpqqZfnDSHmmlDLtWtHWlQmD
JrFdNTTLRBTJrFVrBNdVLFBdlHbzQQsQzbPJtpbtltWsHbQw
gZffDfMlCfjCSqMcpHPWHszstzHjQwpb
GMnvfGlfvSqvcMMDgDDcfnqSVFRdmTmVdNBTdmRmBFVnLLBT
ZvRHtDcZntLZssMssQBrMdnC
jglqlVdlbqgVWjJMbrrBCpmQBBfrpm
GqVVPPjPNjFVllNjJjFDvzTLZRvcLRLvTGdGDv
fDVzvVfzzZPMsMbb
LHtBwLBdhFgdHLLthRwFGGMsmrHMmmbZSmqbMGGG
bblRwbTRlllfVQnCQn
fVZzjRzpzpVCRPZhVWQvvLsWWWFQlmjWmG
JDHgJdtwbZqJqsWBBDLlQlvLms
cHHtdbqwrqbbtSbTgSTcVCMRZnRRVNhVPNMPpfMc
fCMPBBdpMpsqMssQccnV
TlwGWDjDZHLjZHHlLGmnlnNcRllsJcqtsJRV
ZHhZHThLLrGwjDDjLwGWWWSjPpbpzrvBFBFdBBbqvCbpFfpg
bvDfDPtCVfFFVdWWpmLRmzWzzdBW
jgZTghhjrGrsswrsghHrlgTGzSRmMLwpJMSMzWLLWRzpRRSc
lpjTpGHlpsNGTHllHrCFnDNPtVnvfQtQtQNP
BwlQcwZBwwwQNqJTrrsRGCDTNt
bMpVPSfRvCbCtTqsCs
dPSRfRpPPjjmLMgZBZBLZZwFQnZn
TsVfggTqVnsLVTdTpmDdRhwPRtPRDRwD
ljHBSWZvvFWvBFPppnQPwnpmzR
MSHSjbBclBSjccLJgqgnLVqTbsTT
zncfVgRzVJgnTfVqNHvZJZNJNMpHbdvH
PCBpsLjPPmMGdHNdHBHZ
jSLlrhLPDWLrPrDCLPCfnpzcVRFcRTnlVncntT
ccvSgjHtRjcjSvjvSrBjzSHHwnJPbgwPPZVVVZnPpZlpwnlT
ffqNqGGsGWqLTNqZwdndPnnJJpZVJW
sNmqhsCMQsMTmjrcmrHrRj
gWWWzNVJDwDzVWVDGbGNnhTnHLsmhmhfsQTNSmHd
vtMPZvrZvqtqBHljrqSnnmTfLfdnQsjhjmhL
MMPZPBqZCrBtvZcrBlDbGbbbzHJCbbRwgwDz
hGSRhsMswhcNNGwhwncMnCqCJNrHJPJJrJtCJdqHJm
BgVTzWBdTfCmfCJH
dlbVFvvWVZhSRQDMnlhc
WfpzBZmgJlQVGvWF
wHSbrHwmccnrmrHsClGqFGbQjQjjQJQQGv
SHPwwsRcrrNtrNSsphmZLzpfzhghZPdD
DFDPRpmgbPQtmgBBQDDNJTMMBZsqsZGqGZTGCGSqWG
fVvVVLcJVzlvzhqfSTCsZsMGMHqq
zJdrrdnzcLlwczwbQmQngRDQPbtDpQ
HDZZrpFqwRrQfBqhjjlVlQ
czTgvvWPNgPGcTlsQflCVshClC
PgNvtSJNvGVMMzNzgGvPGGLHFDdFdmZSZRdDdRrmpFwL
SVHNVFVPBHJqHhgFCgzLmCwppm
DvDdsGZljDlfdZnjnnZGMzLpRgLfMCLmzfPLhmgp
jZDZlrvrZTrTrTQrDsjslHNJqtWbWHbqbPBWNVQWBJ
NmGGBdWWJDJTTZHm
hFVhcqFjncpcppSjqfppqDvzDDDbbDZvDZZbHfJgvJ
jrPqnnHnqSPwPGWPdWst
BfhbwMwbbPbHPPPlrdJjrlMJLrJVTd
pnQnGnWDjnJdlJCh
qshsWvpttzNNQDtzRRPvwfcPHBBBHwbw
SHzGRQjhwwhGzjjwRjfBqpqbNCqNnnqqQqPlQC
TZtgLmZgVmgdFgmZtdrbNqnqlNlpblnlrnBd
DvgmvvZgmWJJjwHHhJSzps
JjlrlJjPJgDjJjJnDRDjNwGGqMvSddvPvwQddqSVvq
SLpphFLhFZhWLzvswwWqsqVVQWdv
FSHtTLZpfzRDDrJgRNjT
wjCMvrMlqqWHvWqddrHqgnBNhcffthhVLtpgLBnw
GbQFZzZZphnpgNZV
FhFzRTDRPzsRQGQGTFlllrJHjdsJlHMqjjHr
LqDcTbmJcqSJSTmnrTcmJrfffplfjZsGZfGGZfQLdplj
hWddgBvzWFZfPsQlGh
RBWBRCdHtgHttVVzHBVNNNDwSTDcSSSbScDDwbwbnmRS
FFPzwlZVVrzFFlFLVlllZdHCHPQMnJQQbhhChdhCbb
BRRqGBgRfqvgvBDDDTRgghNCMMTQNNbVJMNJJdbbdT
DfpgjGfsRWrFVzwLcs
PMTSdSmFjhFpNTqvppvRBrRBrDqB
HnZZznJbzGZGlZtZWHlJGcGcwMvQBsrwRDQvcDgrgDgrqRvq
HGlGfnJZfMMCfNhm
nRssqlqVRppVwdMMQwFgtRFz
smTvLLTvvNLtwMMQNg
CmPGBvZGWvBSGGDmTZjZlhpJcpHDJsbDnlrrprpl
djcQGNQqdGdGqMCgndwgCLDMgW
nvBvHpBppnvPPnJTBWLJVMwVfWJfCbfWgW
hsHHpBsvRTHpsPszTBTTsRTslGqGqlcqlScnqmhZmmZSZSjl
DddBHCmfWCBTDBHTHfMpzhzpJJMJsFrGrz
tPVPmbnttjPnZvSvSbnmZPZPNpNGMpJNzzNrGJpvhsshMpFs
mwnZcbmmStbVtVjbZVlcLTBlcLCRHRDWCWWW

81
2022/3/main.cpp Normal file
View File

@@ -0,0 +1,81 @@
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
int score(char c)
{
if(c >= 'a' && c <= 'z')
return (c - 'a') + 1;
return (c - 'A') + 1 + 26;
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
const size_t half = line.size() / 2;
std::string right = line.substr(half);
for(int i = 0; i < half; ++i)
{
if(right.contains(line[i]))
{
total += score(line[i]);
break;
}
}
// Part 2:
static std::vector<std::string> lines;
lines.push_back(line);
if(lines.size() == 3)
{
// get all letters it could be from first line
std::set<char> options;
for(const char c : lines[0])
options.insert(c);
// remove if not a duplicate
std::set<char> to_remove;
for(auto i = 1; i < 3; ++i) // remaining two lines
{
for(const char c : options)
if(!lines[i].contains(c))
to_remove.insert(c);
for(const char c : to_remove)
options.erase(c);
}
if(options.size() != 1)
{
std::cerr << "Error: More than one remaining option: ";
for(const char c : options)
std::cout << c << ",";
exit(-1);
}
total_pt2 += score(*(options.begin()));
lines.clear(); // reset
}
}
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

2
2022/4/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

1000
2022/4/data.txt Normal file

File diff suppressed because it is too large Load Diff

79
2022/4/main.cpp Normal file
View File

@@ -0,0 +1,79 @@
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
std::vector<std::string> SplitStr(std::string str, const std::string &delim)
{
std::vector<std::string> rtn;
for(auto split = str.find(delim); split != std::string::npos; split = str.find(delim))
{
rtn.push_back(str.substr(0, split));
str = str.substr(split + delim.size()); // chop off beginning
}
if(str.size())
rtn.push_back(str);
return rtn;
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
auto sections = SplitStr(line, ",");
if(sections.size() != 2)
{
std::cerr << "Incorrect amount of data for line: " << line << std::endl;
exit(-1);
}
auto elf_a = SplitStr(sections[0], "-");
auto elf_b = SplitStr(sections[1], "-");
if(elf_a.size() != 2 || elf_b.size() != 2)
{
std::cerr << "Incorrect amount of data for line: " << line << std::endl;
exit(-2);
}
int elf_a_min = std::atoi(elf_a[0].c_str());
int elf_a_max = std::atoi(elf_a[1].c_str());
int elf_b_min = std::atoi(elf_b[0].c_str());
int elf_b_max = std::atoi(elf_b[1].c_str());
if((elf_a_min <= elf_b_min && elf_a_max >= elf_b_max) ||
(elf_b_min <= elf_a_min && elf_b_max >= elf_a_max))
++total;
// sort
if(elf_a_min > elf_b_min)
{
std::swap(elf_a_min, elf_b_min);
std::swap(elf_a_max, elf_b_max);
}
if(elf_b_min <= elf_a_max)
++total_pt2;
}
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

1
2022/5/Makefile Symbolic link
View File

@@ -0,0 +1 @@
../4/Makefile

512
2022/5/data.txt Normal file
View File

@@ -0,0 +1,512 @@
[B] [L] [J]
[B] [Q] [R] [D] [T]
[G] [H] [H] [M] [N] [F]
[J] [N] [D] [F] [J] [H] [B]
[Q] [F] [W] [S] [V] [N] [F] [N]
[W] [N] [H] [M] [L] [B] [R] [T] [Q]
[L] [T] [C] [R] [R] [J] [W] [Z] [L]
[S] [J] [S] [T] [T] [M] [D] [B] [H]
1 2 3 4 5 6 7 8 9
move 5 from 4 to 5
move 2 from 5 to 8
move 2 from 9 to 1
move 2 from 9 to 1
move 1 from 5 to 3
move 10 from 5 to 8
move 1 from 4 to 7
move 1 from 1 to 2
move 5 from 3 to 7
move 1 from 2 to 8
move 21 from 8 to 5
move 13 from 5 to 7
move 2 from 9 to 4
move 1 from 7 to 4
move 5 from 1 to 4
move 1 from 5 to 7
move 2 from 2 to 7
move 1 from 3 to 2
move 1 from 1 to 6
move 7 from 5 to 9
move 16 from 7 to 4
move 7 from 9 to 3
move 1 from 7 to 5
move 1 from 3 to 8
move 3 from 2 to 7
move 1 from 8 to 9
move 3 from 3 to 6
move 21 from 4 to 9
move 1 from 5 to 7
move 4 from 4 to 9
move 8 from 6 to 3
move 6 from 7 to 1
move 12 from 9 to 8
move 6 from 7 to 2
move 3 from 6 to 5
move 1 from 6 to 9
move 4 from 8 to 6
move 3 from 8 to 5
move 4 from 1 to 8
move 4 from 6 to 1
move 2 from 1 to 3
move 1 from 5 to 8
move 2 from 2 to 8
move 5 from 8 to 3
move 4 from 2 to 7
move 5 from 8 to 1
move 2 from 1 to 7
move 1 from 8 to 2
move 2 from 1 to 7
move 11 from 9 to 2
move 1 from 8 to 5
move 2 from 9 to 4
move 3 from 9 to 5
move 2 from 5 to 1
move 6 from 5 to 8
move 2 from 4 to 2
move 1 from 5 to 6
move 7 from 1 to 8
move 2 from 2 to 7
move 13 from 8 to 1
move 16 from 3 to 1
move 3 from 2 to 1
move 12 from 7 to 6
move 15 from 1 to 8
move 2 from 3 to 8
move 16 from 1 to 2
move 24 from 2 to 8
move 1 from 1 to 5
move 1 from 5 to 8
move 3 from 6 to 7
move 26 from 8 to 3
move 20 from 3 to 9
move 1 from 2 to 9
move 16 from 9 to 3
move 14 from 3 to 1
move 13 from 1 to 6
move 3 from 3 to 4
move 3 from 9 to 4
move 1 from 7 to 8
move 5 from 8 to 2
move 8 from 8 to 5
move 18 from 6 to 1
move 4 from 8 to 5
move 6 from 4 to 1
move 2 from 2 to 5
move 5 from 3 to 8
move 5 from 8 to 7
move 2 from 5 to 8
move 5 from 5 to 4
move 3 from 2 to 8
move 22 from 1 to 2
move 1 from 1 to 2
move 5 from 8 to 2
move 2 from 5 to 2
move 1 from 1 to 6
move 5 from 5 to 2
move 1 from 9 to 8
move 5 from 4 to 1
move 6 from 6 to 9
move 3 from 1 to 9
move 1 from 1 to 7
move 8 from 9 to 6
move 6 from 7 to 1
move 5 from 6 to 5
move 27 from 2 to 1
move 4 from 5 to 7
move 9 from 1 to 5
move 1 from 9 to 1
move 3 from 6 to 2
move 9 from 2 to 1
move 2 from 7 to 2
move 1 from 8 to 7
move 10 from 5 to 9
move 1 from 9 to 7
move 25 from 1 to 8
move 6 from 7 to 4
move 11 from 1 to 7
move 3 from 8 to 1
move 3 from 2 to 6
move 3 from 8 to 9
move 11 from 8 to 6
move 1 from 2 to 6
move 12 from 6 to 4
move 13 from 4 to 5
move 1 from 6 to 1
move 3 from 7 to 5
move 5 from 8 to 7
move 1 from 7 to 1
move 5 from 1 to 6
move 3 from 6 to 4
move 3 from 8 to 6
move 2 from 5 to 2
move 12 from 5 to 9
move 5 from 6 to 2
move 2 from 5 to 9
move 6 from 4 to 9
move 11 from 7 to 3
move 1 from 2 to 5
move 1 from 7 to 8
move 1 from 5 to 7
move 1 from 7 to 1
move 1 from 8 to 1
move 2 from 4 to 7
move 2 from 6 to 8
move 5 from 3 to 6
move 2 from 7 to 2
move 2 from 2 to 9
move 1 from 2 to 9
move 1 from 1 to 6
move 35 from 9 to 7
move 2 from 8 to 7
move 3 from 3 to 8
move 5 from 2 to 4
move 3 from 3 to 7
move 2 from 4 to 7
move 4 from 6 to 5
move 4 from 5 to 9
move 3 from 4 to 5
move 1 from 8 to 3
move 4 from 9 to 8
move 1 from 9 to 6
move 38 from 7 to 2
move 1 from 3 to 5
move 1 from 1 to 7
move 4 from 7 to 3
move 3 from 6 to 1
move 22 from 2 to 7
move 1 from 5 to 8
move 7 from 8 to 4
move 8 from 2 to 8
move 3 from 5 to 1
move 4 from 3 to 9
move 1 from 8 to 3
move 1 from 3 to 7
move 2 from 2 to 3
move 5 from 8 to 9
move 3 from 9 to 1
move 2 from 1 to 7
move 6 from 2 to 3
move 6 from 3 to 1
move 2 from 3 to 6
move 1 from 6 to 1
move 14 from 7 to 2
move 4 from 1 to 6
move 8 from 1 to 3
move 4 from 3 to 6
move 3 from 9 to 5
move 1 from 8 to 6
move 1 from 8 to 4
move 9 from 7 to 1
move 8 from 2 to 4
move 4 from 2 to 9
move 2 from 2 to 1
move 3 from 5 to 8
move 1 from 8 to 6
move 1 from 7 to 8
move 1 from 6 to 5
move 3 from 9 to 5
move 2 from 9 to 5
move 4 from 3 to 9
move 3 from 6 to 3
move 3 from 6 to 9
move 9 from 4 to 1
move 1 from 9 to 8
move 3 from 3 to 6
move 2 from 7 to 4
move 4 from 8 to 5
move 7 from 5 to 6
move 19 from 1 to 9
move 5 from 9 to 3
move 2 from 1 to 6
move 1 from 4 to 6
move 4 from 3 to 2
move 21 from 9 to 7
move 1 from 1 to 2
move 1 from 9 to 1
move 1 from 1 to 8
move 16 from 7 to 6
move 24 from 6 to 5
move 7 from 4 to 5
move 1 from 8 to 3
move 2 from 2 to 8
move 31 from 5 to 8
move 1 from 4 to 6
move 2 from 6 to 9
move 1 from 7 to 4
move 3 from 7 to 9
move 1 from 4 to 8
move 2 from 3 to 5
move 1 from 2 to 3
move 1 from 3 to 7
move 1 from 7 to 9
move 24 from 8 to 6
move 1 from 8 to 1
move 30 from 6 to 1
move 2 from 5 to 2
move 1 from 6 to 9
move 6 from 9 to 7
move 1 from 6 to 4
move 1 from 4 to 6
move 23 from 1 to 3
move 21 from 3 to 4
move 4 from 2 to 6
move 3 from 6 to 1
move 1 from 5 to 1
move 4 from 1 to 9
move 3 from 9 to 6
move 8 from 1 to 6
move 4 from 8 to 5
move 2 from 7 to 5
move 7 from 4 to 3
move 3 from 4 to 9
move 9 from 3 to 9
move 1 from 7 to 6
move 6 from 5 to 8
move 14 from 6 to 2
move 4 from 8 to 4
move 7 from 4 to 5
move 1 from 7 to 9
move 6 from 4 to 3
move 13 from 2 to 6
move 5 from 3 to 7
move 1 from 3 to 8
move 1 from 8 to 2
move 4 from 8 to 3
move 6 from 6 to 4
move 2 from 2 to 8
move 5 from 4 to 7
move 3 from 7 to 5
move 1 from 7 to 9
move 2 from 3 to 9
move 3 from 7 to 3
move 1 from 7 to 9
move 1 from 7 to 9
move 3 from 4 to 1
move 6 from 6 to 1
move 2 from 7 to 5
move 1 from 3 to 5
move 11 from 9 to 4
move 9 from 4 to 5
move 3 from 3 to 4
move 1 from 3 to 9
move 2 from 8 to 1
move 9 from 1 to 8
move 22 from 5 to 8
move 2 from 1 to 3
move 3 from 4 to 6
move 14 from 8 to 9
move 1 from 3 to 9
move 19 from 9 to 3
move 3 from 9 to 4
move 2 from 7 to 2
move 1 from 4 to 6
move 1 from 3 to 8
move 8 from 3 to 1
move 2 from 9 to 6
move 1 from 2 to 5
move 3 from 4 to 9
move 1 from 2 to 3
move 20 from 8 to 3
move 4 from 9 to 5
move 1 from 4 to 2
move 26 from 3 to 5
move 1 from 8 to 3
move 8 from 1 to 4
move 1 from 3 to 7
move 1 from 2 to 1
move 1 from 1 to 6
move 1 from 6 to 7
move 4 from 5 to 3
move 3 from 4 to 2
move 5 from 5 to 3
move 2 from 2 to 6
move 3 from 3 to 5
move 2 from 4 to 8
move 5 from 3 to 9
move 5 from 9 to 8
move 19 from 5 to 9
move 1 from 5 to 2
move 2 from 7 to 1
move 1 from 1 to 7
move 1 from 7 to 4
move 13 from 9 to 3
move 8 from 6 to 2
move 10 from 3 to 5
move 14 from 5 to 4
move 7 from 8 to 4
move 1 from 6 to 2
move 6 from 3 to 8
move 4 from 9 to 7
move 2 from 9 to 8
move 1 from 7 to 1
move 3 from 2 to 7
move 1 from 5 to 3
move 7 from 8 to 6
move 5 from 6 to 2
move 8 from 4 to 5
move 3 from 5 to 8
move 3 from 8 to 6
move 5 from 7 to 9
move 5 from 3 to 6
move 1 from 9 to 4
move 17 from 4 to 7
move 1 from 8 to 1
move 12 from 7 to 8
move 3 from 1 to 4
move 2 from 4 to 6
move 8 from 6 to 1
move 4 from 6 to 3
move 1 from 7 to 8
move 5 from 5 to 8
move 4 from 7 to 1
move 3 from 2 to 6
move 2 from 5 to 1
move 6 from 1 to 6
move 4 from 3 to 5
move 4 from 5 to 3
move 1 from 4 to 8
move 3 from 3 to 2
move 17 from 8 to 4
move 6 from 6 to 3
move 14 from 4 to 9
move 1 from 3 to 8
move 1 from 7 to 4
move 3 from 8 to 3
move 5 from 2 to 5
move 6 from 1 to 7
move 2 from 6 to 4
move 4 from 5 to 7
move 1 from 1 to 5
move 1 from 6 to 3
move 10 from 7 to 4
move 1 from 5 to 4
move 1 from 2 to 3
move 15 from 4 to 5
move 3 from 3 to 1
move 6 from 2 to 6
move 1 from 2 to 3
move 2 from 4 to 7
move 2 from 7 to 8
move 1 from 4 to 2
move 2 from 1 to 7
move 1 from 7 to 2
move 12 from 9 to 1
move 4 from 9 to 5
move 4 from 6 to 2
move 1 from 7 to 3
move 6 from 2 to 4
move 1 from 8 to 5
move 2 from 4 to 2
move 11 from 1 to 7
move 3 from 1 to 4
move 17 from 5 to 6
move 15 from 6 to 4
move 1 from 8 to 9
move 10 from 4 to 1
move 1 from 3 to 9
move 2 from 6 to 5
move 1 from 2 to 6
move 4 from 5 to 6
move 4 from 1 to 2
move 6 from 6 to 7
move 2 from 2 to 6
move 9 from 4 to 9
move 6 from 1 to 2
move 3 from 4 to 1
move 10 from 9 to 8
move 4 from 2 to 1
move 1 from 1 to 2
move 5 from 8 to 6
move 1 from 2 to 7
move 1 from 9 to 4
move 2 from 6 to 9
move 13 from 7 to 2
move 5 from 7 to 5
move 2 from 5 to 2
move 1 from 4 to 5
move 4 from 8 to 4
move 17 from 2 to 6
move 3 from 4 to 6
move 2 from 9 to 1
move 7 from 6 to 8
move 1 from 5 to 2
move 1 from 4 to 1
move 2 from 9 to 4
move 1 from 3 to 9
move 4 from 3 to 7
move 2 from 8 to 5
move 3 from 7 to 5
move 10 from 5 to 8
move 2 from 2 to 4
move 6 from 1 to 2
move 4 from 6 to 3
move 8 from 2 to 6
move 1 from 7 to 4
move 5 from 4 to 5
move 7 from 6 to 7
move 5 from 3 to 5
move 5 from 5 to 2
move 4 from 8 to 1
move 6 from 1 to 6
move 3 from 3 to 2
move 22 from 6 to 2
move 1 from 9 to 7
move 8 from 8 to 6
move 1 from 7 to 6
move 2 from 5 to 7
move 4 from 8 to 5
move 7 from 6 to 7
move 2 from 6 to 4
move 14 from 2 to 1
move 7 from 1 to 3
move 12 from 7 to 3
move 1 from 4 to 3
move 2 from 5 to 8
move 2 from 8 to 1
move 1 from 4 to 3
move 6 from 2 to 9
move 6 from 9 to 2
move 2 from 2 to 7
move 6 from 7 to 5
move 13 from 3 to 5
move 5 from 2 to 6
move 5 from 6 to 1
move 2 from 3 to 6
move 1 from 6 to 5
move 1 from 6 to 1
move 3 from 1 to 9
move 6 from 2 to 7
move 1 from 2 to 3
move 24 from 5 to 2
move 7 from 3 to 7
move 13 from 7 to 9
move 4 from 1 to 9
move 4 from 1 to 6
move 1 from 5 to 6
move 16 from 9 to 5
move 1 from 6 to 4
move 1 from 5 to 2
move 5 from 1 to 3
move 11 from 2 to 1
move 4 from 9 to 6
move 1 from 4 to 7
move 2 from 3 to 4
move 6 from 6 to 9
move 1 from 1 to 3
move 2 from 9 to 4
move 1 from 7 to 9
move 4 from 2 to 9
move 8 from 9 to 2
move 3 from 3 to 2
move 1 from 9 to 4
move 5 from 1 to 7
move 1 from 4 to 8
move 2 from 1 to 9
move 1 from 8 to 7
move 6 from 5 to 3
move 1 from 5 to 1
move 5 from 2 to 3
move 4 from 1 to 5
move 4 from 7 to 1
move 8 from 5 to 8

119
2022/5/main.cpp Normal file
View File

@@ -0,0 +1,119 @@
#include <algorithm>
#include <fstream>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
void DebugOutput(std::vector<std::vector<char>> &stacks)
{
// DEBUG:
for(const auto &st : stacks)
{
std::cout << "Stack: " << std::endl;
for(const auto &ch : st)
std::cout << "[" << ch << "]" << std::endl;
std::cout << std::endl;
}
}
std::vector<std::string> SplitStr(std::string str, const std::string &delim)
{
std::vector<std::string> rtn;
for(auto split = str.find(delim); split != std::string::npos; split = str.find(delim))
{
rtn.push_back(str.substr(0, split));
str = str.substr(split + delim.size()); // chop off beginning
}
if(str.size())
rtn.push_back(str);
return rtn;
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
std::vector<std::vector<char>> stacks;
std::vector<std::vector<char>> stacks2;
// Step 1: Parse Starting Position
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
break;
stacks.resize((line.size() + 1) / 4);
for(auto idx = 0; (idx * 4) < line.size(); ++idx)
if(line[1 + idx * 4] != ' ')
stacks[idx].push_back(line[1 + idx * 4]);
}
// Step 2: Clean up data:
for(auto &st : stacks)
{
// clear out last line of each, seeing as how they're just index numbers:
st.pop_back();
// reverse list since we parsed top to bottom and inserted backwards...
std::reverse(st.begin(), st.end());
}
// DebugOutput(stacks);
stacks2 = stacks;
// Step 3: Parse Actions
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
auto actions = SplitStr(line, " ");
if(actions.size() != 6)
{
std::cerr << "Data corrupt: " << line << std::endl;
exit(-1);
}
long amt = std::atoi(actions[1].c_str());
long from = std::atoi(actions[3].c_str()) - 1;
long to = std::atoi(actions[5].c_str()) - 1;
// Part 1:
for(auto i = 0; i < amt; ++i)
{
stacks[to].push_back(stacks[from].back());
stacks[from].pop_back();
}
// Part 2:
std::stack<char> temp;
for(auto i = 0; i < amt; ++i)
{
temp.push(stacks2[from].back());
stacks2[from].pop_back();
}
for(auto i = 0; i < amt; ++i)
{
stacks2[to].push_back(temp.top());
temp.pop();
}
}
// DebugOutput(stacks);
for(const auto &st : stacks)
std::cout << st.back();
std::cout << std::endl;
for(const auto &st : stacks2)
std::cout << st.back();
std::cout << std::endl;
return 0;
}

6
2022/6/Makefile Normal file
View File

@@ -0,0 +1,6 @@
all: a.out b.out
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp
b.out: main2.cpp
clang++ -std=c++2b -g -O0 main2.cpp -o b.out

BIN
2022/6/b.out Executable file

Binary file not shown.

1
2022/6/data.txt Normal file
View File

@@ -0,0 +1 @@
hqhnqhqshhslswsffchfcfbblvlblqlggfwwqfwwqdddbbbhzhjjrqjqbjqjwqjwqwhwrrmcrrjqjjlllcvcrrnpptzpzmmswmmzrzjrrfcrfccpbpzzvrrdndllttwftwwgzzwhwggdvdnnlrnncscbcfcctchcdchdccztzgzjjtdtcdtcchrrgpgzgsgpsggvtvppdccfhcfclfcfdfnddlbbptbtdbtdtjdjgdjjzljlssgbgcgqcqzccfnftfjjsgstggsngsscvssjzjnjtntvnvssrqqhtqtvqtvvjbvvbnvvqvmvrmmdsdvdwwnbnvbnvvcgvcczcfzftfsfrfsfttldtdrrgrgmgbbdvvbqbhqbqlqsqbsbpbgbvgbgwwrswrwrwttvnnzdnzzwggrmrfmmvllzwlwzzlvlbvllgsllpnlnvncvcvqqrwwcmcczhchzczbccdwcwvwzwwvddlwlhljlqjqnncntnctczzmwmlmccpggljlssqswsmmpvmvwvrrcpcrprmprrtdrtdrrsjsmshmmdpdlppbnbvvmmflmmjvjhvhjvjsjbjwjvvblvbvlbbllwlslvljvlvdvdgvgcchnhpnhnvhhtfhhvssczztlzzgvvqqghqgqssdscsnsrsmrmmwgwmgmlmdmggbgzbgzgdzdzccghgfgddtntftddpdrdrmrjmmmzttqmttnwngggtgtqtqnqhnqqpnnntrntrnnshhjtjzzfqqblqqlblslflmlttcwtwzzrlrnrcrrrgtrrftfhthzhggwggvgvvfvddcnddfjddzqzrrvtrvrfrrgpgrgngsgddlmddzgzppdzzjzhjhjhqqbpbvvlrvrsvrvnrrsgsttndnbngnppmlppvgvfggvcvrvnnsnfnnfqfwwppnddrrfqqgbqqfmmlnlnngwgcgjgnjgjsgjgqjjnccdttpqttswwcgcmgmccrppmqmbbfwwvdwdfwfjwfjjblldsdrdvvgcvcwwllfpllcslsvssnvsnvvhnvnvwwcgwccslsbbnlbnbrrrtprptpdpdvdttgsgwswppcdchhqbqcbqbzbgbbstshthsttqgtqtpqqzhhwhghwwmbbdlbbtlltsllbvbnvvmqvqtvqvttlwtltmmrttwgtwwfdddwcchtchhbthbbclczzqbzzpvvwzwswggjddntnrnnwmnnbdbmbccqgqvvsnvvqbvbzvvzmvzzrfrlfrfhhdvddnmnnmhmqhhrhlrldljlbljjgqqvdvhhgmgvgddmmznndmmhssznsswvwdvdzdhhscssntnftfmmrggbmbmgmlltctbtbntnqqscqcscrcrhrlhhdchhzccvvbfvvpfffbwbsbjjmgmwgmgppjnpjphhlmhhpwwhwzhhhzbbzzcbchhpnnptpvphhsdsccffqbqllchlhlwlcljlppnccqsstzstswtwwljwjmmpttvqqspsjjclljqqlhqqtnnbrrsbrbjjllrmrjmjzmmclmclmmcvvbddhnnmhmbbwqqqhrqqtqmqbqdbdtdvvcscshccmffhqffdgdcgddljdjbdbjbdbrrtjjtnntpntpnpmnpmpgghffrnfrnnmdnmnhmmjcjffftrrttfwfvwvcwwrmwmpwmmnvntthmmgmbbcdclcppjhpjhjwwlppgsszqqwggmttfrfqflfsfmmmhchshmmjtjjgdjjnnsvsmsnwcgdfqljmnphlfdrhpggfqnhnszgpndhdqcgfhtdcgbsbtmhvnnrmqzqqcjdqndzbnrhwjvbvcldmnwltgpqbmstntnggtbqjzzqrfdsfttdfrcnsrpwrjrjqbgtjfmlwsrzdbdqvbtczgsjqhtgmctjfmdglfrsvqtgwpbqghzgzdfwzhbdhlmhdvhwjrdhhtjptvwpmjnmfcjdmdczmczvdqwvbgtvlwvwnvdlbqfshmlmvzzcmjbtpwpwgsqhfsgljzhbppcztfjdntzcvllqnzrqjwfjrlgvhmbpvbtqjrdzcsmcjzcdsmvcmhrbhgnscnfrfmscqsqpqplbrzhsrlsvvpmfdtdmtlrtvspmlljmfpshfmstjgnrrwmqlbnwbndcfdstrtqtnzpfqlcgrzmsnmhllljdgtmvftjttbwhqzcqwbwdbshgcqrptfjwbbfsjnvzztlbdchqrlbbrcnsswmhwphfwrbnvrncbrthprmltlwwlfpbqhdfqzwwcwjgqzdnvmhwpzpbtpwwvzcpfcsfqpwjljzzfwzmlfvhsccppzlzjlrvlpdtjpcptnvqjwtdbzrqwnfwmmjndflqqggczrfjlpdfjffctprnmhfdqvnzbfvhszzdmngnlmwzfdrbvlvjnmbllgrczssqcrhbmnpmqlrzgmqmhgsvcdlqnmlhlzvqzhnccbctslzlbcpdvqltqncpcrzwdchrqmwfwlcbcvfnnpjntfrznqdjsdtzqjjttddwvnfqmznhflblzvvtbwdzrrlqlmndzzzwnpbhhlvlbswfjtbnhlccscbnfgjtwbfdlwvzszwnwzhlbcdpvgqjcrpzsvvnfwqcqvrmhzhggvmzwggdpbfrdscjwhsdsbbjcnzldhzcvqtjrhsbfjlrlpvtcqhnnsvslfrdjvjhfhdcfzqchpvvhzbpqglqlrdttrdtndzhnzhtqndghtgmpsnhptprqzhbbdcrgmbvrvqmbptqgnmsccwmhrlpddvmhjntllwrzqwnsjchnblcgndjtmpswwgcstdftqcbhzgttrhnpvrhspjznhhvrlpdqbzzrvzjphcswhljdldvsrdhzltwgrcsvqwnhtqqjjrjgrplzmsnjhzrfbtqgdfgnbpvjrfzrrpdphgzrfbswdhzgbzswqtwwdtrvvswmjvwhqddfzjhgdqsfnwbmlcfwtmpldrdpwjwggbpmncvbghzjmpsqpvnmbhjfzzpsjdgmrtnndhzrphjzdbgrrnthtrfnspdngbdmwbnfjlsndqswfsvfqftqlgqjpfsfpmdbsjfrptvbpvflqgvlmmbchhghhrwmvdlrhlsdtvjjchwglcrwfsfnnbhjbtccbjsfwrbzrvgsbfnvzghhrqblqchjvdtrrbrwwwmfnczzmmrqdggsfrqbldbbfbbcthtsvpcnlbjjztwvhctbrjltqdwbzmrrfslbmjpnqwllbvjzgfsfqqtwbgwgclgdflshfhwggwdqlgbmdmdqglrtfwbddtsltmsvswhgjtqwtnrncpdzhnpfqcjnjzmtbjfzpjwgfbfggmsmfdhfbjctnhchpgfspthdbfpmvrmdbbspvwzqqwnmfwdnnblbcjszbccgflngnjjwsqshfbhjwgzrmvsgnrdbgwfhdvpmznpnvznfcqdclztcptjrrpbmpztwwbvlvtmngfhmfbfmrjbjzlrcvgllrlgthltstnwmffntqrwsrndlzqhztwpcwbdjjztgdzmgtthcvtvnjzzhvstfqhgddddgdsrbcqzqspjrncphhtbnslzphrtfqphffjrrlgwbrwqfzzqvzhnffcwvrncttgplshccglvchvlcbnlthhmzvcrfjvjqfsjjzzgqlpslfwngqnbgcwffpcqhlmlhvwssrpjbrcbftpzbbpptzrdqwpzpdjhtwbvwcqbfnwtflfgzgttglpcwdnzsmjffgfftdnpzlpszmzrrhvlzdfpgbzqlvvfslnndcmjvvpwzwcdzpcttfwbsdswmfqbbhbfbjvbvtspbbhmphzjsjcmmzpvvzhtvzlgwlqqvbnrgtszvghjfmchrwwhpmbsvfmgvqdtmvdtjppchbsgqrtgtnzczqmpgjdbmmflfpjbcdmhldwpgdtdvsbzhztjzfhcsbndfjntbldjnqwdffqspfnlplbtcdjtwdjhldtsdfrnmpfhzghnpcqlhhgblmqjvwhndqfbccvzzlbzbdprvcpwjjhrqnjptwssbjhgvpgtfzqwrzjvbdgwtnmptvdjrffcmbzmzcmrfbjv

56
2022/6/main.cpp Normal file
View File

@@ -0,0 +1,56 @@
#include <deque>
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
bool Unique(const std::deque<char> &buf)
{
std::set<char> s;
for(const char &ch : buf)
s.insert(ch);
return (s.size() == 4);
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
std::deque<char> buf;
int idx = 0;
for(const char &ch : line)
{
++idx;
buf.push_back(ch);
if(buf.size() >= 4)
{
while(buf.size() > 4)
buf.pop_front();
if(Unique(buf))
{
std::cout << "At index " << idx << ": ";
for(const char &ch : buf)
std::cout << ch;
std::cout << std::endl;
break;
}
}
}
}
return 0;
}

52
2022/6/main2.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
std::vector<char> buf;
int idx = 0;
for(const char &ch : line)
{
++idx;
// clear out from beginning up until this character is found:
auto i = std::find(buf.begin(), buf.end(), ch);
if(i != buf.end())
buf.erase(buf.begin(), i+1);
buf.push_back(ch);
if(buf.size() == 4)
{
std::cout << "Start-of-Packet at index " << idx << ": ";
for(const char &ch : buf)
std::cout << ch;
std::cout << std::endl;
}
else if(buf.size() == 14)
{
std::cout << "Start-of-Message at index " << idx << ": ";
for(const char &ch : buf)
std::cout << ch;
std::cout << std::endl;
}
}
}
return 0;
}

21
2022/7/File.cpp Normal file
View File

@@ -0,0 +1,21 @@
#include "File.h"
File::File(const std::string &set_filename, unsigned long set_size)
{
this->size = set_size;
this->filename = set_filename;
}
File::~File()
{
}
const std::string& File::Filename() const
{
return filename;
}
unsigned long File::Size() const
{
return size;
}

19
2022/7/File.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef ADVENT_DVEREB_FILE_H
#define ADVENT_DVEREB_FILE_H
#include <string>
class File {
public:
File(const std::string &set_filename, unsigned long set_size);
virtual ~File();
const std::string& Filename() const;
virtual unsigned long Size() const;
protected:
unsigned long size;
std::string filename;
};
#endif

58
2022/7/Folder.cpp Normal file
View File

@@ -0,0 +1,58 @@
#include "Folder.h"
#include <algorithm>
#include <iostream>
Folder::Folder(const std::string &filename)
: File(filename, 0)
{
}
unsigned long Folder::Size() const
{
unsigned long size = 0;
for(const auto *file : files)
size += file->Size();
return size;
}
void Folder::AddFile(const std::string &filename,
unsigned long size)
{
// make sure the file doesn't already exist:
if(std::find_if(files.begin(), files.end(),
[&](const File *file) {
return file->Filename() == filename;
}) != files.end())
{
std::cerr << "Folder \"" << this->Filename() << "\" already contains "
<< "the file \"" << filename << "\"." << std::endl;
exit(-1);
}
// increment this folder's size total:
this->size += size;
// add the file:
files.push_back(new File(filename, size));
}
void Folder::AddFolder(const std::string &name)
{
if(std::find_if(files.begin(), files.end(),
[&](const File *file) {
return file->Filename() == name;
}) != files.end())
{
std::cout << "NOTE: Folder \"" << this->Filename() << "\" already contains "
<< "the subfolder \"" << name << "\"." << std::endl;
// exit(-1);
}
files.push_back(new Folder(name));
}
const std::vector<File*>& Folder::Files() const
{
return files;
}

22
2022/7/Folder.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef ADVENT_DVEREB_FOLDER_H
#define ADVENT_DVEREB_FOLDER_H
#include "File.h"
#include <string>
#include <vector>
class Folder : public File {
public:
Folder(const std::string &filename);
unsigned long Size() const override;
void AddFile(const std::string &filename, unsigned long size);
void AddFolder(const std::string &name);
const std::vector<File*>& Files() const;
private:
std::vector<File*> files;
};
#endif

2
2022/7/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp File.h File.cpp Folder.h Folder.cpp SplitStr.h
clang++ -std=c++2b -g -O0 main.cpp File.cpp Folder.cpp

22
2022/7/SplitStr.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef ADVENT_DVEREB_SPLITSTR_H
#define ADVENT_DVEREB_SPLITSTR_H
#include <vector>
#include <string>
std::vector<std::string> SplitStr(std::string str, const std::string &delim)
{
std::vector<std::string> rtn;
for(auto split = str.find(delim); split != std::string::npos; split = str.find(delim))
{
rtn.push_back(str.substr(0, split));
str = str.substr(split + delim.size()); // chop off beginning
}
if(str.size())
rtn.push_back(str);
return rtn;
}
#endif

1013
2022/7/data.txt Normal file

File diff suppressed because it is too large Load Diff

170
2022/7/main.cpp Normal file
View File

@@ -0,0 +1,170 @@
#include "Folder.h"
#include "SplitStr.h"
#include <algorithm>
#include <fstream>
#include <iostream>
#include <stack>
#include <string>
#include <vector>
void DebugOutput(File *file)
{
static int indent = -1;
++indent;
for(auto i = 0; i < indent; ++i)
std::cout << " ";
Folder *folder = dynamic_cast<Folder*>(file);
if(folder)
{
std::cout << "Contents of folder: " << folder->Filename()
<< ", size: " << folder->Size()
<< std::endl;
for(File *file : folder->Files())
DebugOutput(file);
}
else
std::cout << "- " << file->Filename()
<< ", size: " << file->Size()
<< std::endl;
--indent;
}
unsigned long PartOne(File *file, unsigned long &grand_total)
{
unsigned long rtn = 0;
Folder *folder = dynamic_cast<Folder*>(file);
if(folder)
{
for(File *file : folder->Files())
rtn += PartOne(file, grand_total);
if(rtn <= 100000)
{
grand_total += rtn;
std::cout << "Folder \"" << folder->Filename() << "\" has a size of " << rtn
<< std::endl;
}
}
else
rtn += file->Size();
return rtn;
}
void PartTwo(File *file, unsigned long at_least, File *&smallest)
{
Folder *folder = dynamic_cast<Folder*>(file);
if(folder)
{
if(folder->Size() >= at_least && folder->Size() < smallest->Size())
{
std::cout << "New smallest size of " << folder->Size() << " by folder \""
<< folder->Filename() << "\"." << std::endl;
smallest = file;
}
for(File *file : folder->Files())
PartTwo(file, at_least, smallest);
}
return;
}
void Parse(Folder &root)
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
exit(-1);
}
std::stack<Folder*> dir_stack;
dir_stack.push(&root);
// Step 1: Parse:
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
if(line.starts_with("$ ls"))
continue;
else if(line.starts_with("$ cd"))
{
auto to = line.substr(5);
if(to == "/")
{
while(dir_stack.size() > 1)
dir_stack.pop();
}
else if(to == "..")
{
if(dir_stack.size() > 1)
dir_stack.pop();
}
else
{
auto existing = std::find_if(dir_stack.top()->Files().begin(),
dir_stack.top()->Files().end(),
[&to](const File *f){
return f->Filename() == to;
});
if(existing != dir_stack.top()->Files().end()) // found!
{
// Check to see if it's a folder, first:
Folder *folder = dynamic_cast<Folder*>(*existing);
if(folder)
dir_stack.push(folder);
else
{
std::cerr << (*existing)->Filename() << " is a file, not a folder."
<< std::endl;
exit(-3);
}
}
else
std::cerr << "could not navigate to \"" << to << "\" from \""
<< dir_stack.top()->Filename() << "\"." << std::endl;
}
}
else if(line.starts_with("dir "))
{
dir_stack.top()->AddFolder(line.substr(4));
}
else
{
auto values = SplitStr(line, " ");
dir_stack.top()->AddFile(values[1], std::atol(values[0].c_str()));
}
}
}
int main()
{
Folder root("/");
Parse(root);
// Step 1.5: Debug output:
DebugOutput(&root);
unsigned long grand_total = 0;
PartOne(&root, grand_total);
std::cout << "Grand Total (part 1): " << grand_total << std::endl;
const unsigned long max_space = 70000000;
const unsigned long space_needed = 30000000;
const unsigned long currently_used = root.Size();
const unsigned long currently_unused = max_space - currently_used;
const unsigned long amt_to_remove = space_needed - currently_unused;
File *file_to_remove = &root;
PartTwo(&root, amt_to_remove, file_to_remove);
std::cout << "Remove \"" << file_to_remove->Filename() << "\" to free up "
<< file_to_remove->Size() << " which is the smallest amount >= "
<< amt_to_remove << " (part 2)." << std::endl;
return 0;
}

2
2022/8/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

99
2022/8/data.txt Normal file
View File

@@ -0,0 +1,99 @@
020110220332333020110144320304042020444223003535441353331002333431100300241023221210123003331021020
002120010112022233203323334422340102033151553341235324543343233301202102130210343113312320222102020
000000000301021002423224442341031145215244543444223314545524515335404222310244314423023331200102012
011200302010212334422213334343335452314532352111122533515334412241512412033340322004232020212310011
110111200102310120411101020333232255345143342245212323552344535253214434143032323213200301101020121
122001020113011314043121413025543341512335111452355331355351515421515411500421204113413212021112302
011210211003201420103123304513544114145311452334355144111521441452154223512022101102111221311323311
011030200312240341224434214241313322323544154242345656634321531531424124544551344224331443202111303
031023120224010220144244342511241334331166432443322363352643453525244443222142533014331212133113031
331033331100013013431114214253543323143222523423236646456363626622312534521454454123324132323233200
313320023430241044213221132131122135436564345625426422255326234363243521151144414344130023210131130
002203011410101343345413454143416333665335233566235623536644652644522345535525153521230411343303211
022030323311323124542521154345356626352343324652424464566645425223224521453553252234321033403323130
331222243010032043452454232565665256426536435254566436633323343652534544214412242551144312310221231
231133233004211422411531255443363333555345434532475762623642433466363266634413551244254134333243030
020231113200002214145443133533534653326664654474363645366343345466265644554325342415122332200024311
311032340032414323451542554464466352256347635357637447736577667463426532442564245132242343241314212
210342413212232542421452232234546643373633347344743377376553465333423522425436534352355150302110320
012302042023135125251364365232626547463576733637455663764376436734352545425434331543241124042312202
304042410233125532432523224245663443763753734647533535565636563665334542556665554245524241400402122
100324144335411111343624365526556753335435457754653754663647544353454443256623466532421524442220212
004310002315421423634565264237567445665436743333467647547754434765353667542365233361541321530411122
340100133133254351662534562377644656735477678648447854646765556636735646456562322345353223545130204
223422234555541234336653556365464346366386775667444744567758637737757667635354324626442355153142402
301202352352311332364654446567354376644665887886878854847858588356564773766244445222614543212440041
121010254322255546522625235356663453785775455846758588786788567566653645763532436352663334521520342
223123122512444365553626454767563488464886467858877655766685458675437556363673526236645213411512224
003314511142456453664565476333555654845565878476575468776548666885476777366354622652365442341232330
100434351354142623236353735657745766665557455465675844665578767675874476556574642555262344222545124
310035122251134332246455666547787878577677667587668567788744875844888844364453536232254344234442004
332355524421462334544344655646458867688886798865795569865997666688465755335745555656646243433122421
212252432545222565265377376368574784887787696558698987968675547855656555445333366624445325141553342
113535121253534442546646364347455675758878676575695576785998796454646647555637657565266546254424513
023531155256556443573534665476784478579889966685965558767695667786588646763565366352565623135242132
332235311465633455637577656876574774599858977857599877979855878694546488485435736564352255345534352
423312331346353345545646578646466549968669789766955768696578957665488458568376747735452426221223133
042131555255526335474354376567744577697576655686887997959968659596857774864465577464334245541411144
314335533542324633457667677854784879668896688676989899996875778858675674784535777333543532331142411
342431321343652634443346854886679789759856968779866777899677797959996774647753365556465426225312415
443122331352464374355445874586585857875568898788666678776787986756859447544446666763365552244452322
434332122456323647344556476668759666569568769987679766689798887678765548587477474536465533643451422
012515214225433447464677777487776597697976998888987789798887796967785955887765466437333665342324523
151212435544622335634548655777875966867886867777679699887698988956977857868655457465635544364542154
425332155643342656676678888575989888788767888899689899798688796666757955465858667777362363434424542
531532414223243445466348848575895777968779899997887798776667989655588765447757447347342252524115215
155245334655555376575664568856876978978787888977789987998877778796686666588544843473375333466131323
442223263655353573545578848875879796997899897789887987979686977788898887848487563664644353624212355
532342436423523433743374566649565796978689677778887988977986779775985585775684847364464225436344143
144131162643455446377457566657777998676869667898877798979888978868889578745676553337663625625354412
212531125562654464546354657756555595879978788779777999979988869895856856488587466676673534564554215
515521136425625643733788668547967896969879989899779977888986996776697776777887634766746536654352314
533115456346557773554457648785576555967877979777897997977979879979889786544548474557775226255314122
432554142445363766476368787846679896977899887779797978979969889696765986666844737665565256236231155
125253442625345476646468778468579567787976888987879797899978977695756855477657433457362446432521533
451335344244435635354545558745856999567779868887799878899867977959975677866558447464563253543641554
412221312464362643575387865576575778679997969899879799897898997777656968646646747476434353234412443
132123436534443354553586484485777568678779897878779989966877968659558598445764456573762542646254544
024143156436353736354736885476858987768978898698789976987668878886568974574565737457544455543452243
413135313643263775675578866878568599957868689889887898688888897699957964455656556464353643525222353
151155234625524455454576866886566769799886776697778986968676996687578554546778475347663665445441542
225335432336665664467554464786765996688599897886876679899878795577796866847588643664352344525425543
231314414363454365656445447648785668665699968677877867679686575989979554888874435546345632362455211
215225154624264466667536475884866766856799777898688869799678789658958655666655664763723652345235254
035354151466424636347656474544888889966575676978876877797665689589954588444647355553546242434541533
001253252266442433343367457848868577696576876956987767987878766766685545864636355333223636351531525
432114153244234344474473336455665467595685659677769775776598955788485844764764774633253355345153344
440231335123622442356777766866685464699576999777998779679677676798556674878735743562224245652132511
321533313113424533355576556587855784598797699998756887876998858868457756543476743664332364153212141
003415211213442534357575744467674686668987887956977567898997789587764784753377657636326255155213240
224445525333436434526743474634674544887785577959758998579798555487687877644644777665225554533252422
114025431113445462556535777346657775747764689775588768859877487468477864653336547436625221413353402
444431445545324552322733365535555774656466544687955795855665775645668663457547655566226341423452434
410445115125126462226236353755455888548674587788447578688475766447586446763443644432535242233435244
124340412535436432636663557555763744747854587474866557668648548584743443577534342355356535325312231
200313132541126432532542747437536486654767558545587875558487658465577773437664544545354413212211212
101333454545223643623655465756576356785656755457885765456674785763465474656725224222541315314114031
131233142323341366245232435554365765545574774767785475776848668453355554474332533326544433554514201
321411402434455156645353526473756763444567846554465464446465455445745336435566265254512531525210112
030131034355454454644464565464475577344753366858566476585577545346763733342656446563454444451042420
123233024345514531322525463344645673755773347575544437475656346736346777342352464432215452454013411
014322323421235432556233655455544546633674634474456664346664375533773475562242423541545331424443423
103044012005453352356343445634325645434337637364655565435774676736733553262634342435541343244030000
320224321434222311444445623462256346445463567453434633465443337646352226626622452524224345304403330
212420324020443535541356556336654222753455556557453353546474577342535554563532343321131244211234443
122201202000423112251512562424625443344753367744337643545467743645523543344535431154212330403302410
302200224224202341324112146243633653523426575646533673677763345633345645554351214352331400423031333
123001320330302415435532414224224226352235334353577574436324344226425624263133551342153034141032032
213131040401103044255424155325562642646633364323565455323646566426224245451451423431324433130343033
231211142003310021532152553311226325626362465244625533422332633634454451545253314415220400420413203
312320130422410131322514243524545532465435666446335525623552365342455442353243151122403024303312021
133332233112042420435241253424143243654366264342464546256332442465235435334432132240241304411322221
333302213333240222002452421142454145262355663455246362444253326353144344554554324413300122011222021
202310030210410440001115535553444131333333663342464256255352255253344353414423520402213424030101331
020120023231001430421410113431542415212332151336254445313532121145524443121220343020012020230032230
210023323121322121303302233233245321224455333332343322323215223451525532222223304043001030230132022
002222021003231011234340303045243412535411232132142332533521354111141433134004443142111110122121100
022122131333022231003311233440122445251415343142141523345254553214425533033042143220401300010213100
122110132221332212341431023220242412121544355542132225542445544553234342030402442141111321103231211
122021200131211021314010312001241211235253115315252213451111223452204220130001212341202130012001221

200
2022/8/main.cpp Normal file
View File

@@ -0,0 +1,200 @@
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
long ScenicScore(int set_x, int set_y, std::vector<std::vector<int>> &trees)
{
const int tree_val = trees[set_y][set_x];
int score_up = 0;
int score_down = 0;
int score_left = 0;
int score_right = 0;
// up
for(int y = set_y - 1; y >= 0; --y)
{
++score_up;
if(trees[y][set_x] >= tree_val)
break;
}
// down
for(int y = set_y + 1; y < trees.size(); ++y)
{
++score_down;
if(trees[y][set_x] >= tree_val)
break;
}
// left
for(int x = set_x - 1; x >= 0; --x)
{
++score_left;
if(trees[set_y][x] >= tree_val)
break;
}
// right
for(int x = set_x + 1; x < trees[set_y].size(); ++x)
{
++score_right;
if(trees[set_y][x] >= tree_val)
break;
}
return score_up * score_down * score_left * score_right;
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
std::vector<std::vector<int>> trees;
// Parse:
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
trees.push_back({});
for(const char &ch : line)
trees.back().push_back(ch - '0');
}
std::set<std::pair<int, int>> visible_coordinates;
for(auto y = 0; y < trees.size(); ++y)
{
visible_coordinates.insert({0,y});
visible_coordinates.insert({trees[y].size()-1,y});
}
for(auto x = 1; x < trees[0].size() - 1; ++x)
{
visible_coordinates.insert({x,0});
visible_coordinates.insert({x,trees.size()-1});
}
// left to right, right to left IN EACH ROW:
std::vector<int> points;
for(auto y = 1; y < trees.size() - 1; ++y)
{
points.clear();
// initialize list with the first value
points.push_back(trees[y][0]);
// iterate through the rest:
for(auto x = 1; x < trees[y].size(); ++x)
{
// if it's higher than the most recent one:
const auto val = trees[y][x];
if(val > points.back())
{
points.push_back(val);
visible_coordinates.insert({x,y});
}
}
}
for(auto y = 1; y < trees.size() - 1; ++y)
{
points.clear();
// initialize list with the first value
points.push_back(trees[y][trees.size()-1]);
// iterate through the rest:
for(auto x = trees[y].size() - 2; x > 0; --x)
{
// if it's higher than the most recent one:
const auto val = trees[y][x];
if(val > points.back())
{
points.push_back(val);
visible_coordinates.insert({x,y});
}
}
}
for(auto x = 1; x < trees[0].size() - 1; ++x)
{
points.clear();
// initialize list with the first value
points.push_back(trees[0][x]);
// iterate through the rest:
for(auto y = 1; y < trees.size(); ++y)
{
// if it's higher than the most recent one:
const auto val = trees[y][x];
if(val > points.back())
{
points.push_back(val);
visible_coordinates.insert({x,y});
}
}
}
for(auto x = 1; x < trees[0].size() - 1; ++x)
{
points.clear();
// initialize list with the first value
points.push_back(trees[trees.size()-1][x]);
// iterate through the rest:
for(auto y = trees.size()-2; y > 0; --y)
{
// if it's higher than the most recent one:
const auto val = trees[y][x];
if(val > points.back())
{
points.push_back(val);
visible_coordinates.insert({x,y});
}
}
}
total += visible_coordinates.size();
for(auto y = 0; y < trees.size(); ++y)
{
for(auto x = 0; x < trees[y].size(); ++x)
{
if(visible_coordinates.contains({x,y}))
std::cout << "\033[1;31m"; // red
else
std::cout << "\033[0m"; // default white
std::cout << trees[y][x];
}
std::cout << std::endl;
}
std::cout << "\033[0m"; // default white
std::cout << " Total: " << total << std::endl;
long highest_scenic = 0;
for(auto y = 0; y < trees.size(); ++y)
{
for(auto x = 0; x < trees.size(); ++x)
{
auto score = ScenicScore(x, y, trees);
if(score > highest_scenic)
{
highest_scenic = score;
std::cout << "New highest: " << score << " at " << x << "," << y << std::endl;
}
}
}
total_pt2 = highest_scenic;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

2
2022/9/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

2000
2022/9/data.txt Normal file

File diff suppressed because it is too large Load Diff

8
2022/9/data_test.txt Normal file
View File

@@ -0,0 +1,8 @@
R 4
U 4
L 3
D 1
R 4
D 1
L 5
R 2

169
2022/9/main.cpp Normal file
View File

@@ -0,0 +1,169 @@
#include <cmath>
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <unistd.h>
#include <vector>
void ApplyMovement(std::pair<int, int> &head,
std::pair<int, int> &tail)
{
const int x_diff = head.first - tail.first;
const int y_diff = head.second - tail.second;
if(std::abs(x_diff) > 1) // 2 away
{
tail.first += (head.first - tail.first) / 2;
if(std::abs(y_diff) > 1) // 2 away due to diagonally following!!!
tail.second += (head.second - tail.second) / 2;
else
// snap to axis since you're already on it or you're one away
tail.second = head.second;
}
if(std::abs(y_diff) > 1) // 2 away
{
tail.second += (head.second - tail.second) / 2;
if(std::abs(x_diff) > 1) // 2 away due to diagonally following!!!
tail.first += (head.first - tail.first) / 2;
else
// snap to axis since you're already on it or you're one away
tail.first = head.first;
}
}
void DebugPrint(std::vector<std::pair<int, int> > &points,
std::set<std::pair<int, int> > &visited_positions,
std::set<std::pair<int, int> > &visited_positions_part2)
{
int x_min = points[0].first;
int y_min = points[0].second;
int x_max = points[0].first;
int y_max = points[0].second;
for(auto &pos : visited_positions)
{
x_min = std::min(x_min, pos.first);
x_max = std::max(x_max, pos.first);
y_min = std::min(y_min, pos.second);
y_max = std::max(y_max, pos.second);
}
for(auto &pos : visited_positions_part2)
{
x_min = std::min(x_min, pos.first);
x_max = std::max(x_max, pos.first);
y_min = std::min(y_min, pos.second);
y_max = std::max(y_max, pos.second);
}
for(auto i = 0; i < 50; ++i)
std::cout << std::endl;
std::cout << "X: " << x_min << " - " << x_max << std::endl;
std::cout << "Y: " << y_min << " - " << y_max << std::endl;
std::cout << std::endl;
for(auto y = y_min; y <= y_max; ++y)
{
for(auto x = x_min; x <= x_max; ++x)
{
if(points[0].first == x && points[0].second == y)
std::cout << "\033[1;30mH"; // head
else if(points[1].first == x && points[1].second == y)
std::cout << "\033[1;25m1"; // tail
else if(points[2].first == x && points[2].second == y)
std::cout << "\033[1;25m2"; // tail
else if(points[3].first == x && points[3].second == y)
std::cout << "\033[1;25m3"; // tail
else if(points[4].first == x && points[4].second == y)
std::cout << "\033[1;25m4"; // tail
else if(points[5].first == x && points[5].second == y)
std::cout << "\033[1;25m5"; // tail
else if(points[6].first == x && points[6].second == y)
std::cout << "\033[1;25m6"; // tail
else if(points[7].first == x && points[7].second == y)
std::cout << "\033[1;25m7"; // tail
else if(points[8].first == x && points[8].second == y)
std::cout << "\033[1;25m8"; // tail
else if(points[9].first == x && points[9].second == y)
std::cout << "\033[1;25m9"; // tail
else if(visited_positions.contains({x, y}))
std::cout << "\033[1;31mX"; // red
else if(visited_positions_part2.contains({x, y}))
std::cout << "\033[1;20mY"; // ??
else
std::cout << "\033[0m-"; // default white
}
std::cout << std::endl;
}
std::cout << "\033[0m"; // default white
}
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
std::set<std::pair<int, int> > visited_positions;
std::set<std::pair<int, int> > visited_positions_part2;
std::vector<std::pair<int, int> > points;
for(auto i = 0; i < 10; ++i)
points.push_back({0,0});
char dir;
int amt;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
dir = line[0];
amt = std::atoi(line.substr(2).c_str());
for(auto i = 0; i < amt; ++i)
{
// Move head:
switch(dir)
{
case 'U':
points[0].second--;
break;
case 'D':
points[0].second++;
break;
case 'L':
points[0].first--;
break;
case 'R':
points[0].first++;
break;
}
// Follow with tail:
for(auto i = 0; i < points.size() - 1; ++i)
ApplyMovement(points[i], points[i+1]);
visited_positions.insert(points[1]);
visited_positions_part2.insert(points.back());
DebugPrint(points, visited_positions, visited_positions_part2);
usleep(100000);
}
}
DebugPrint(points, visited_positions, visited_positions_part2);
total = visited_positions.size();
total_pt2 = visited_positions_part2.size();
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

2
2022/starter/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

29
2022/starter/main.cpp Normal file
View File

@@ -0,0 +1,29 @@
#include <fstream>
#include <iostream>
#include <set>
#include <string>
#include <vector>
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
}
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

2
2023/1/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp

1000
2023/1/data.txt Normal file

File diff suppressed because it is too large Load Diff

7
2023/1/data_test.txt Normal file
View File

@@ -0,0 +1,7 @@
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen

126
2023/1/main.cpp Normal file
View File

@@ -0,0 +1,126 @@
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
int main()
{
const std::string filename = "data.txt";
std::ifstream ifs(filename);
if(!ifs.is_open())
{
std::cerr << "Missing " << filename << "." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
std::map<std::string, std::string> values =
{
{ "0", "0" },
{ "1", "1" },
{ "2", "2" },
{ "3", "3" },
{ "4", "4" },
{ "5", "5" },
{ "6", "6" },
{ "7", "7" },
{ "8", "8" },
{ "9", "9" },
// { "zero", 0 },
{ "one", "1" },
{ "two", "2" },
{ "three", "3" },
{ "four", "4" },
{ "five", "5" },
{ "six", "6" },
{ "seven", "7" },
{ "eight", "8" },
{ "nine", "9" }
};
auto GetDigit = [&](const std::string &line, int i, bool ascending, std::string &result) {
std::vector<std::string> tests;
if(ascending)
{
tests.push_back(line.substr(i, 1)); // single digits
if(i < line.size() - 2)
tests.push_back(line.substr(i, 3)); // three-letter words
if(i < line.size() - 3)
tests.push_back(line.substr(i, 4)); // four-letter words
if(i < line.size() - 4)
tests.push_back(line.substr(i, 5)); // five-letter words
}
else
{
if(i < line.size() - 4)
tests.push_back(line.substr(i, 5)); // five-letter words
if(i < line.size() - 3)
tests.push_back(line.substr(i, 4)); // four-letter words
if(i < line.size() - 2)
tests.push_back(line.substr(i, 3)); // three-letter words
tests.push_back(line.substr(i, 1)); // single digits
}
for(auto test : tests)
{
if(values.contains(test))
{
result = values.at(test);
return true;
}
}
return false;
};
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
std::string first = "";
std::string last = "";
// first
for(auto i = 0; i < line.size(); ++i)
{
std::string result;
if(GetDigit(line, i, true, result))
{
first = result;
break;
}
}
if(first == "")
std::cerr << "Missing digit in line: " << line << std::endl;
// last
for(auto i = 0; i < line.size(); ++i)
{
std::string result;
if(GetDigit(line, line.size() - i - 1, false, result))
{
last = result;
break;
}
}
if(last == "")
std::cerr << "Missing digit in line: " << line << std::endl;
std::string val = first + last;
int val_int = std::atoi(val.c_str());
std::cout << val_int << std::endl;
total_pt2 += val_int;
}
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

2
2023/1_old/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -g -std=c++20 main.cpp

1000
2023/1_old/input.txt Normal file

File diff suppressed because it is too large Load Diff

7
2023/1_old/input2.txt Normal file
View File

@@ -0,0 +1,7 @@
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen

134
2023/1_old/main.cpp Normal file
View File

@@ -0,0 +1,134 @@
#include <cctype>
#include <fstream>
#include <iostream>
#include <vector>
#define INPUT_FILE "input2.txt"
int ParseNumLine1(const std::string &line);
int ParseNumLine2(const std::string &line);
int main()
{
std::ifstream ifs(INPUT_FILE);
if(!ifs.is_open())
{
std::cerr << "Couldn't open " INPUT_FILE "." << std::endl;
return -1;
}
long result1 = 0;
long result2 = 0;
for(std::string line = ""; std::getline(ifs, line); )
{
result1 += ParseNumLine1(line);
result2 += ParseNumLine2(line);
}
std::cout << "Part 1 Result: " << result1 << std::endl;
std::cout << "Part 2 Result: " << result2 << std::endl;
return 0;
}
int ParseNumLine1(const std::string &line)
{
char found[3] = { '\0', '\0', '\0' };
bool found_first = false;
for(auto &ch : line)
{
if(std::isdigit(ch))
{
if(!found_first)
{
found[0] = ch;
found_first = true;
}
// same as first, if only one
found[1] = ch;
}
}
return std::atoi(found);
}
int ParseNumLine2(const std::string &line)
{
char found[3] = { '\0', '\0', '\0' };
bool found_first = false;
for(auto &ch : line)
{
if(std::isdigit(ch))
{
if(!found_first)
{
found[0] = ch;
found_first = true;
}
// same as first, if only one
found[1] = ch;
}
else
{
const static std::vector<std::string> available = {
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
};
int num = 0;
for(auto i = 0; i < line.size(); ++i)
{
for(auto w = 0; w < available.size(); ++w)
{
const std::string &word = available[w];
if(line.size() - i < word.size())
continue; // not enough letters for this word
bool word_matches = true;
for(auto letter = 0; i + letter < line.size() && word_matches; ++letter)
{
if(line[i + letter] != word[letter])
{
word_matches = false;
break;
}
if(letter == word.size() - 1)
{
num = w + 1;
// std::cout << "Found: ";
// for(auto a = 0; a <= letter; ++a)
// std::cout << line[i + a];
// std::cout << " == " << available[w] << " @ " << letter << std::endl;
break; // true!
}
}
if(word_matches)
break;
}
if(num)
{
if(!found_first)
{
found[0] = num + '0';
found_first = true;
}
found[1] = num + '0';
num = 0;
}
}
}
}
std::cout << "Return: " << found << " == " << std::atoi(found) << std::endl;
return std::atoi(found);
}

4
2023/1_old/sample.txt Normal file
View File

@@ -0,0 +1,4 @@
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet

2
2024/2/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main_pt2.cpp
clang++ -std=c++2b -g -O0 main_pt2.cpp

1000
2024/2/data.txt Normal file

File diff suppressed because it is too large Load Diff

6
2024/2/data_test.txt Normal file
View File

@@ -0,0 +1,6 @@
7 6 4 2 1
1 2 7 8 9
9 7 6 2 1
1 3 2 4 5
8 6 4 4 1
1 3 6 7 9

83
2024/2/main.cpp Normal file
View File

@@ -0,0 +1,83 @@
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <vector>
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
std::istringstream input(line);
long *last = nullptr;
bool *increasing = nullptr;
bool safe = true;
for(std::string value; std::getline(input, value, ' '); )
{
long current;
// Get the value:
try {
current = std::atoi(value.c_str());
} catch (const std::exception &e) {
break;
}
// See if it's the first value:
if(!last)
{
last = new long(current);
continue;
}
// See if it's the second value:
if(!increasing)
{
increasing = new bool(current > *last);
}
auto diff = current - *last;
if(*increasing &&
(diff < 1 || diff > 3))
{
safe = false;
break;
}
if(!*increasing &&
(diff < -3 || diff > -1))
{
safe = false;
break;
}
if(last)
*last = current;
}
if(increasing && last // actually made it through at least 2 values
&& safe)
total++;
if(increasing)
delete increasing, increasing = nullptr;
if(last)
delete last, last = nullptr;
}
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total_pt2 << std::endl;
return 0;
}

146
2024/2/main_pt2.cpp Normal file
View File

@@ -0,0 +1,146 @@
#include <fstream>
#include <iostream>
#include <set>
#include <sstream>
#include <string>
#include <vector>
bool GroupSafe(const std::vector<long> &group);
int main()
{
std::ifstream ifs("data.txt");
if(!ifs.is_open())
{
std::cerr << "Missing data.txt." << std::endl;
return -1;
}
unsigned long total = 0;
unsigned long total_pt2 = 0;
std::vector<std::vector<long>> data;
for(std::string line; std::getline(ifs, line); )
{
if(line == "")
continue;
// add a row for this line:
data.push_back({});
std::istringstream input(line);
// for each value in the line:
for(std::string value; std::getline(input, value, ' '); )
{
try {
// add it to the row
data.back().push_back(std::atoi(value.c_str()));
} catch (const std::exception &e) {
break;
}
}
}
// DEBUG:
// for(auto row : data)
// {
// for(auto col : row)
// std::cout << col << " ";
// std::cout << std::endl;
// }
for(auto group : data)
{
switch(group.size())
{
case 0:
// Go to next line
continue;
break;
case 1:
// Can't be increasing or decreasing because it's the only one, so I guess safe?
++total;
++total_pt2;
continue;
break;
};
bool safe = true;
if(GroupSafe(group))
++total;
else
{
bool re_safe = false;
for(auto i = 0; i < group.size(); ++i)
{
std::vector<long> check;
if(i != 0)
check = { group.begin(), group.begin() + i };
if(i < group.size() - 1)
check.insert(check.end(), group.begin() + i + 1, group.end());
if(GroupSafe(check))
{
re_safe = true;
++total_pt2;
break;
}
}
if(!re_safe)
{
std::cout << "Bad: ";
for(auto val : group)
std::cout << val << " ";
std::cout << std::endl;
}
}
}
std::cout << " Total: " << total << std::endl;
std::cout << "PT2 Total: " << total + total_pt2 << std::endl;
return 0;
}
bool GroupSafe(const std::vector<long> &group)
{
bool increasing = false;
for(auto i = 0; i < group.size() - 1; ++i)
{
if(group[i] == group[i+1])
continue;
increasing = group[i] < group[i+1];
break;
}
bool safe = true;
int *last = nullptr;
for(auto i = 0; i < group.size(); ++i)
{
auto next = group[i];
if(!last)
{
last = new int(next);
continue;
}
if(increasing &&
(next - *last < 1 || next - *last > 3))
safe = false;
else if(!increasing &&
(next - *last < -3 || next - *last > -1))
safe = false;
if(!safe)
break;
*last = next;
}
if(last)
delete last, last = nullptr;
return safe;
}

2
2024/3/Makefile Normal file
View File

@@ -0,0 +1,2 @@
a.out: main.cpp
clang++ -std=c++2b -g -O0 main.cpp #-fsanitize=address -fno-omit-frame-pointer

6
2024/3/data.txt Normal file
View File

@@ -0,0 +1,6 @@
mul(168,87)}*:mul(911,800)(%,)where()#&&$mul(734,19)?when()why(){$:?mul(829,495)do()mul(724,312){;^mul(520,383) mul(137,485)select()-mul(700,211) <(who()who()/mul(295,600)]~<select()'$why()do()when()mul(310,255)^}where()who()(!+mul(16,916),)what()@:@#where()mul(918,822),when()~/)mul(177,722)<&]:who()where()>mul(439,650)?+$mul(349,399)mul(807,317)what()?@[%mul(674,778)!mul(104,928)~[!!mul(60,636){where()when()&@why()-+mul(742,28)select()why()'&why()@>select()mul(527,483)mul(797,855)how()mul(502,647)what() {(*'}%mul(688,600))!??,+$mul(538,127)&from(),>~&*mul(963,787)~mul(820,259)~}~how()>do()what()^<}[?{'mul(202,9)$select(795,484);from()<!mul(913,93)/{{what()#-select()how()]mul(520,288),^&what()mul(583,623)mul(657,601)>;^@what()mul(671,74)&@how(151,76)!?:{mul(933,567)/)&select()do()>+,~?>mul(627,488) *mul(437,91){!#}%?how()who()mul(741,704)select():where()mul(258,129),&why():)mul(770,13)@ from()?-!what()$mul(229,613)from() select()why()};select()mul(59,263)where()from(97,930)?where()mul(514,278)(-don't()&$[how()why(783,866)&who(589,80)#; mul(130,239)don't()mul(195,249),~>>who()mul(945,698) /}how()>mul(983,248)[~why()({from()-(how()?mul(206,469)&>~who()]mul(661,410)how()&mul(768,601)/!--select()>,%mul(455,805)(}]how();<who(735,631)why()mul(216,340))what(181,514)mul(736,427)^when()]$%where()'<;mul(754,836)*@!why()select()]mul(869,551)~mul(752,713) <(~&@#mul(124,162)why()/mul(512,273); /where()why()mul(471,915)/(where():?}mul(608,515){[@:'select()[][ mul(983,96)%where(),why(){~-+]mul(102,860):#?select()%who(105,947):who(416,728)mul(765,635)@(mul(898,549)$where(580,81){mul(497,154)>/from())mul(728,180)'(what()[mul(915,20)who()+&don't()select()^)}$!who()+>mul(481,439)- *mul(332,923)when()-why()!mul(625,335)?mul(156,134)why()*'$:mul(104,186)^?#>/mul(605,863),,?mul(161,457)!#~,#~>/mul(514how()where(),'$;'$+)mul(207,90)&>$how()mul(394,95),where()'mul(827,742)how()[from()(]:/why()$+mul(46,294)>who()who()^@[^mul(500,356){]{mul(989,398)(}: mul(300,17):how()who()%?#@why()!mul(362,556)>$mul(29,294)who()<;when()mul(108,898),#<<~-*(where()@mul(86,710),'-$&what()(mul(573,832)),?{mul(953,794)why()^what()-*,/?)mul(511,634):how()/how()'what()what()mul(709,593)]mul(721,842)(!&why()where()&mul(259,304/$[*why()+#mul(932,748)? {mul(979,591)mul(576,282)(-when():^,select()>@mul(146,41){[<#(#'*}mul(615,174)&>when()what()&(mul(914,488)[~why(267,875)mul(167,385)+<%~}@![why()mul(221,316):,;[:@(!who()mul(340,617)&*how()%mul(151,744) >},-)'?mul(414,238)mul(100,868)%%what()where()mul(467,880):mul(266,276)!@!#'who()'mul(500,629)[#^select()*+how()(mul(538,599):* [;'mul(919,315)mul(760,200) <$/$}{why()'(mul(794,683)from()**'$,}}mul(915,608)>$$mul(114,893)what()select()do():^from()??from()from()^mul(316,793)>'/when()+mul(199,368)[~mul(539,838) ^(*??%mul(162,286){mul(647,357)who()$(>what()?,why()>from()mul(239,449){select()who()mul(408,790)mul(567,879)
when(),who()[what()mul(874,22)mul*'mul(908,653)>~)@mul(773,355)#mul(716,195) ?@who()mul(128,574)^select(),{:mul(799,387)who()-)+]select()'mul[mul(153,811)from(854,516)select()'(',#mul(760,387from()mul(434,344)@?what(),&!'mul(108,675) 'who()%>+why()mul>]%select()[mul(793,13)mul(333,332)~why()/what()mul(774,658)**mul(375,739)[)*what()what(),>::>mul(702,335)%}{-@'~who();mul(992,903)}where()$(~@)'%mul(488,891)where()*);why()what():{&why()mul(29,881)&]where()where()~*mul(886,964)}&):where()who(){?mul(60,664)why()from()< +select()[when(789,49)$mul(40,510)<how()who()mul(755,503)mul(851,686)?#;}{{from()~'do()>from()~ who()>?from(431,14)%[mul(313,439)mul(999,227)[how()']what()(%,don't()who()><{#~'where()?mul(796,988)what()$/why()#select()/#what();mul(401{~mul(949,141)when()why())/^$$}^(mul(472,738){]:+mul(372,612)mul(647,895)>&$***mul(619,883)(;^mul(864,456-}#/?mul(68,612)~,}>from()!>-when()mul(997,365)mul(524,378)where()where()/!mul(301,937) ++?^what()mul(656,303)}{}mul(953,842);select()select()~[)<mul(617,87)where()what(517,442)~{mul(412,205)-?^?from()],+mul#?%#mul(389,357)how()!$<mul(809,511)who()>do() !;!mul(344,321)from()mul(819,403)+how()where()where()<($mul(908(,>%*why()what()^mul(533,374)-,select()mul(905,803)mul(140,691)what()([mul(874,79)]?how()what()?->mul(344,908)$#&#;from()!mul(256,631){where()#@,]~*:why()mul(225,679)where()?[mul(141,585)+)@~#how()mul(933,177)((+select()mul(312,241)+mul(247,632)how()^[,&from():where()%mul(663,72)![@@when()mul(274,536)>who()@mul(269,240)mul(732,115)!%@'%mul(479,836)-why()mul(502,828)#mul(548,385))mul(312,586)/&{//+{^mul(275,705)where(377,884)$ *!who()mul(382,713)+<@(<>)[select()'don't()mul(182,291)select()]:*select()where(872,531)what()&)mul(361,941)why()/+mul(832,469),-$)mul(753,874)^when(){,@mul(865,352),+#what()mul(749,612)!?#]from(),#mul(734,31)when()^mul(992,318)mul(396,187where()mul(134,182)&<&%$[>,mul(527,215)mul(400,794)'~what()mul(427,148)where()from()<<mul(867,258)<>-mul(495,578)where()}-don't()select()%+^{]what()where()mul(730,966)%$where()'mul(507,416)from()~)how(488,343) %<%>$mul(486,368)what()why()[mul}^^{who()what()[select()'why()who()mul(214,853)from()how(301,437)^):)]how()mul(657,161))(^@select()'mul(313,702)(mul(486,323)*&;&why(){'&how()-mul(911,603)-what()%mul(519,498))select():from()mul(652,991)!!/,mul(308,418)- &#+(who())~)mul(749,786);what()(mul(731,76)<!mul(572,33)/%:;select()from()mul(509,810)~mul(861,431)>do(){&what()$+-^how()mul(214,122)mul(540,414)from()mul(640,157)select()< #:;]^mul~mul(705,467)(?[}when()>where()?mul(45,584)~when()^;mul(519,782)}#when()+[mul(670,319?>]mul(451,604):mul(646,328)when()^mul(326,180)why();who();'$mul(642,425)from();?+when()]mul(907,636)what()%;do()what()?{who()mul(974,27)>{how()(^}mul(357,294)${~[@mul(983,221)who(){(!~from()^mul(128,197)*mul(942,48)>:+]{/from()#mul(237,772)<+select()@mul(361,84);why()]!)who()}+mul(740,305)&,[>]how()mul(660,613):)from()do() select()?when()%select() (mul(835,437)why();)</? how()mul(417,353)-( !select(480,286)mul(935,409)who()/*^+$mul(48,5)>how()mul(819<%/{how(675,621)where()@(>from()mul(722,49)
+)do()%;!who()who(772,423)]$<-mul(328,361))mul(149,957))do(){#!where()>#what()(select()/mul(756,781) *-select()?why(713,643)mul(514,277)$]how()/^mul(7,203)%when()how()who()mul(389,589~]who()*>$^@mul(129,92)~;mul(759,369)how()*!&from()/when()%mul(650,562),*who()*'%when()mul(236,299) }?how()how():don't(),who()how()'why()who()what()@mul(322,510):-@:$@^mul(634,343)-what()#what()from(38,805),<+mul*where(835,107)where()&where(816,43)(%{mul(617,254)where()!^![ who()?;<mul(166,155),$*:<mul(827>/~*;why()mul(788,442))-what())!?(mul(662,916)mul(401,521)mul(234,405)+~,{>from() :{select()mul(635,416)+[~[,mul(562,550)mul(152,551)#]mul(164,957)~<what()#where()>from() mul(761$who()?--<where()+mul(795,259)[~{?<select()&:mul(229,87)mul(864,182)how()?mul(974,34),mul(627-mul(177,523);,^mul(45,82)[-!}mul(370,437)(#:];:(mul(818,270)'}^]when()how(934,258)don't()'{+*why()}mul(530,297)]^/$from()<who()*$mul(842,310)from()^/)%select())+mul(482why()select()&from(415,942)!]how()why()mul(279,984)~when()>}~'/who()when();mul(796,168)what()mul(199,983)>:]when()?why() mul(410,263) when()how()?mul(413,448)]mul(825,830)# mul$mul(261,686)@~{>{what(276,567)mul(341,638)who(){?*$[why(831,759)^ from()mul(741,711)'who()select(){mul(61,52)[what(){%don't():who()@mul(219!)?];where();' *mul(371,514)>[:mul(53,428!mul(538,853)]$#~do()@mul(200%{$$[$#$)mul(57,357)/mul(399,855)~<(*@~what()(@mul(814select():what()]~[#mul(507,982)**mul(68,893)}#mul(631,348)from()mul(205,133)mul(497,687from() !mul(728,117)[;)'@/}@{mul(678,169)who()@$@@~%how()mul(959,969)%@^&{~! ]%mul(324,123)'from()who()}^%mul(763,855)from()^when()#{ /from()#]mul(316,502)what())^<^%%mul(813,959)&why()~~-?-mul(798,375)$>{#'why()&:,why()mul(83,95)(don't()mul(798,687)when(506,624)from()(,how()^: ]>mul(149,563)why()~mul(41,612)-:?when()^/)mul(974,373)>when()?how()*mul(36,761)what(){&@)mul(390,671)when()mul(696,964,@when()@$/?~>~mul(548,987)select()what()% who();$mul(80,587)&^{+,don't()?what()*why(),( mul(124-^>how()/>'mul(155,901)?<;when()!!mul(90,13))/'^from()&[,)mul(805,998):@select()/~from()+(^/mul(823,626)%where()select()how()%&>mul(257,517))#->mul(304,899))mul(255?mul(302,286)>?@<mul(777,721)^&what() !from()/*where()mul(817,696)why()#+&who()why(351,81)}where()$mul(237,864)<&(do()^?from():*{<who()select())mul(975,616),{+where()/@@who()mul(549,977)@<)when(),mul(508+<$mul(716,515)^,-]who()#select()<+mul(118,226how()mul(543,380)(how()?select()from()@}mul(28,144);;'>mul(899,21)@mul(619,488)$->&^@from()(*-mul(266,282)/]from()@who(109,244)()mul(98,720)why()what()>;% mul(681,256)#~)]from()@&mul(517,40)@@what())mul(725,452)mul(852,71)?$mul(612,673*select()what())#mul(120,4),where()who())mul(808,259)who()'^~mul(325,215)!>select()~mul(853,581)%why()mul(652,100)%<select()##what()~mul(237,441)when()!how(753,120)^mul(890,518)from():,who(196,65)+#$ mul(664,43)}%^how()/from()[[when()mul(39,906)mul(324,714)#[#from()mul(569,489)'<who()*@mul(167,880)*select(){>^@don't()/,when()~what(),+&mul(975,420){+*when()]^how()*why()who()mul(448,331)!/when()~mul(235,190)^$}+*++{#mul(96,137):?%where()mul(511,78)};^{&:when()!don't()&when()''&#:{mul(205,318)*!where()?when()~/&from(733,701)?mul*#&#where()where()]{select()mul(474,265)from(755,678)why()!;#]'>-]mul(132,817);&)]^*what()[mul(831,118)select()<mul(181,530)%)mul,])!<>+how()how()mul(292,875)%&select()[@*mul(868,274)&@select(),{mul(427,903)/@]mul(620,307-+what()select()-where()mul(206,860)-mul(937,784):where()!+mul(347,517)#!/usr/bin/perl(select()~from()mul(730-,what()!where(360,351)what()*how(600,916)mul(929,974)
~]#<!when()[~*<mul(132-+why()#%*~:@mul(416,703){@#';>mul(190,848)?{from() }where()<mul(527,529)-mul(209,184)?[what()when()mul(77,529)why()how()<#who(360,918)-mul(417,741)where()what(269,273)from()(mul(322,695)select()@^][don't()]mul(739,357)']when(789,549)/:&when()>mul(532,685)#+~^&]^where(947,658){mul(835,556)mul(785,197)@mul(20,129)>(%*$?,%^]mul(309,855)(!select(){[?](mul(408,217)+;who()why()-&$ ,$mul(824,38)&mul(848,553)@where()who(774,973)-[;mul(590,491)what()'/mul(625,672)!}~~%>-{]-mul(113,831)}+//>(what()mul(822,256):<*$!select()mul(743,335)how()^* (<mul(341,513)do() {,(how()*,^&mul(777,587){>^what()'{[,select(249,901)mul(795,853)@$;mul(486,10)>>?~mulwhere()<~}mul(375,790)/}when()*!mul~-select(){select()select()<]don't()''-'mul(934,731)select()';*select()&why()mul(280,932>mul(530,961)how(),-{how()&what()>(mul(285,204)who()+select()>~>?/<)mul(791,587)from();~mul(142,801),from()~>when()mul(636,737)mul(122,583)select()mul(29,534)[<}>~?;++,mul(853,461)where()&/where()>do()what()where()mul(224,748)when()(from()$%>mul(537,689)@how()from(97,626)%!mul(854,118)when(998,592)-+>how()'when()/mul(548,649)who()who()#) &@!,do()}[^[@mul(154,777)mul(96,225)when()mul(951,144)what()mul(358,785)select()+from()what()-$mul(507,770);select()where()where()mul(696,121)who()when()]&$}how()what(){mul(63,669)+*where()/why()mul}&@where()!?'@;mul(81,559)*]how(372,376)mul(602,773)+mul(511,514)) (,}mul!#%$where()from()%~?>+mul(451,596);from()mul(719,514)^who(533,943)}how()@mul(382,562)!#[,@*)>mul(234,778)&-mul(280,479){, [do()how()!&{mul(971,30)'@why()) ?:+>don't()where()%from()/*&&!mul(551,129)where()!when()@@>[$mul(266,378)&mul(354,236)where()who()mul(198,648)when()~<[what()what()mul(215,213)mul(687,432){,mul(595,927)+<why()*@how()*{%mul(764,459)>who(829,436)^+mul(424,283)@why(),mul(169,939)/[*from()> %!(mul(537,425)%^mul(352,791)*#when()when()-&;what()mul(904,80) select() how()how()mul(34,66)@%<mul(276,65)where()when()how()})mul(52,448)who();select()mul(692,130)what()${%&^%mul(444,170)[)(,<mul(297,209)%&]select(170,397)$mul(577,234),select()^:~,[*>do()mul(921,346)/#what()mul(49,901)mul(734,885)/)(:mul(553,997)(who()mul(62,853)from(535,930);where()#what()mul(457,969)&(+(*}why()mul(317,972)where()when()$do()why() why():~%:^mul(447,529){mul(612,477)how()$when()mul(66,532)>$$*mul(945+*<how(289,725) who() what()how()how()}mul(304,883)select()^':{/':'-mul(715,525)!mul(270,804)from()::['when()why()mul(93,166),-when()!mul(736,616)+;mul(531,606)<how()&[+&mul(967-^'}+-}from()mul(178,389)who()<*mul(116,273)#);#select()mul(628,521)@}where()<where()(;how(376,88)<mul(99,450)}<how()$mul(612(mul(214,455)?:mul(841,59)~~mul(162,250)^]#&>*^)who()mul(291,880)/mul(903,311)*;how()mul(58,539)]-@+&%),what()mul(501,878)*[[mul(626,427)]}how()?when()[mul(280,653)/when()]-<mul(765,466)~-<(select()}{){do()from()*where()!;mul(701,836)'~mul(529,579);!:'+@/'mul(54,282)^<'mul(792,927)&mul(470,236)who() @ ])+??mul(693,230#+~?:-^mul(814,574)from()<when()@#mul(430,705)where(),when()@*$!what()$how()mul(95,323)who()when()mul(38,704)@{where()why(),from()where()[{<mul(455,604)}where()from()~mul(719,681)mul(131why()^where(389,683)**mul(331,541)-}{mul(320,970)
:}#mul(737,307) *?)~,]mul(740,642))><mul(666,137)why()where()where()from()why()$ mul(709when(),select()*]when()(mul(510,937)&+>where()why()mul(235,299){;select()mul(543,852)>mul(456,133)(>mul(671,153)'?*who()(mul(12,640)<{##+mul(432,266)*>)'[~>$~?mul(816,840)what()-mul(698,399)how()mul(45,603))~*what()mul(737,715){when()why()~from()mul(995,968)where()mul(262,96)^?who(){; )from()who(615,278)mulhow()mul(838,616)}from())mul(865,576))~-;how()mul(192,403)))[-$]^select(),mul(184,369)#why()*^;)(do()#,'mul(423,897);)]what()/[$]mul(867,533)select(138,395)*-how()mul+#<why()}[~{mul(925,163)<mul(798,343):mul(137,381)~/>;mul(515,882)]:(mul(364,946)&!&,how()select()- mul(111,167):~$from()^]don't()&mul(829,425)!'/how()where()]/<what()mul(521,742)mul(316,792)mul(311,104)from()<%mul(869,189)^&why()[&:mul(683,138)how()mul(533,311)from()%what()@mul(785;select()~?{}++where()mul(102,590)}&what()}(^[<:mul(997,376)'@/$;mul(25,111)~+$]^;+?mul(786,845)@why()&mul(737,79)''from(340,968) how()where()^?mul(803$select()*why()!select()*/%-mul(450,746)who()-(from()where()when(525,894)mul(110,878)-%select()$)@;mul(445)]-~~*/)&mul(205,632)$[^}select(599,536)how()how()who()]mul(952,986)who()/#*:]who()+/mul(346,355)^where() don't()@who()?+&;mul(617,393)&how()>mul(195,257)*mul(953,79);who()when()$,from()<>why()mul(529,405)from()&mul(492,793)&#*[;+;-mul(331,898)?/{+}mul(424,343)$~[mul(523,74)why();mul(772,703):;mul(17,157)! }why()/]!^mul(979,338when()$?mul(898,616)}why(359,279)+from()what())}$from()!mul(612,784)(where()mul(640,368){#!mul(69,807)]how()( #mul(739,987)'*~&%who()!}@mul(834,525)when())::$mul(122,894)%+^(who()@when()%mul>when()from()?mul(464,80)$^! !/@?@,mul-what()!!@:[mul(283,21)([how()[mul(11,617)]}where()/mul(976,268)mul(843,731)<how()why()[mul(601,412)%how()!]@*why(136,791) -mul(371,365)@~$*'~[/ mul(15,594)how(),/{#-}>'mul(676,131)where()}{(]'where()mul(459,88);(where():mul(64,747);[&$})+select()&;mul(750#[{;*&mul(458,334)?where()select()%)mul what()?when()mul(808,879)what()*}-$+from()where()@mul(152,857)'#%where() /<:+?mul(304,149)from()!<when(865,985)mul(238,815))~!+<)@from()mul(401,975)%&mul(625>*!mul(802,11)!*select(),; )-;how()mul(199,993)/!when()^;[)mul(577,723)!?^who()+what()<mul(489,809)~what(625,812)<?;*#)how()do()!(]who()what()where()*from()+mul(705,108)(who()why(815,180)[]^[mul(821,379)&^(&<,%mul(197,678)%-what()mul(944,295)select()how()!mul(357,711))$-what()'&)'mul(114,910)}<*@-from(688,563)[mul(279,269)from()}$mul(707,287)<;*+what()*>when()mul(447,881)+'(+&@&do()mul(192]what()%/mul(463,832)mul?^*>why()where()from()what(){*mul(456,920) $where(911,93)select()+who()select()}don't()}!how()what()~+what()mul(404,558)>,>{(?{'&,mul(936,304);mul(232,989~;>]who()mul(582,897)*!mul(11,23),~>!{<who()$>mul(542,522)^;,from()(?mul(177,928)how(985,316)}who()@](-#why()mul>~why(851,863)[)!@>mul(101,448)select()+?%&select()~((mul(11,450)how()^)mul(344,639)}+;mul(343,648)^why()!where()&{/'#mul(9,810)where()-%mul(877,263)&select();where(240,275)[mul(289,282)how()&<{who()} ['do(){mul(818,421)/}$]mul(617,829)~['why()?&~)mul(741,559)mul(133,701)$]:@&mul(594,307)[',how()^{how()mul(388,657!({'mul(492,896)#@/why()why()mul(127,225)}>where()-/,^mul(219,314))mul(682,893)what()why(){(,from()(?mul(219,360)what()' ](mul(80,569)
select(82,585)mul(693,510)%$what()from()mul(740,749){~'<]mul(281,263)when()(!?>/% +mul(116,41)-*-when(506,165)?^}mul(651,943){~,/what(){#{!mul(629,41)/mul(74,998)?mul(525,86)&how()do()+/%mul(15,103)#select(671,57)from()who()]mul(309,559)%>mul(311,459)'when()@#mul(980,750)when()+%how()how()~:mul(484,554) )+{ - :]mul(113,626)[^<%,mul(187,326)*:!]*!mul(374,45)from(),mul(41,137),^)-,#when()?who()mul(93,289)select(853,56)]^where()mul(43,349)*where()mul(406,653)from()from()*&*mul(486,350);)*~how()mul(817,387)>>when()who():mul(417,224)^!&{from()}@mul(342,365)why()^who()+~!}when()do()why()when(939,686)^)((mul(160,438)what()>mul(23,766)+]*mul(618,433[/~where()[;why()what(){mul(292,318)*$why(664,963)how(68,975)why()who(276,89)where()!why(777,555){mul(875,358)@'[#who();)mul(198,992)?:(?~where()what()how()-'mul(956,332)mul(889,561)from()((what()mul(753,443)#>? , -mul(267,527):when()+mul(225,923)>>?^mul(726,980)~when()'mul(760,283)!;why(),;when()mul(358,713)//select()]%^{why()*'mul(406,429,(: {how()!^;mul(363,272)--where()*:select()when()?when()mul(242,130);why()>:!&why()$mul(386,685)@!}>when()why()>how()how(872,684)mul(418,627)why()[{:[-%mul(946,701)(}mul(10,874)&mul(109,151)],mul(676,79:;]}),mul(206,822)mul(228,261)-how()?]+mul(295,706)/]@( how()-mul(558,819)@::!>where()*when()?}mul(709,558)*)~;?}> how()from()mul(489,495)[*where():}(*%mul(189,692)how()/where()why()(mul(895,190))]<select();'who()when(309,317)mul(204,524)from(),&# mul(563,48)what()mul(207,241)&mul(450,18)when()what()select()^]{$why(565,783): mul(422,431){,}?+how()what()where()mul(782,229)[%}:~mul(994,946)){,$*,mul(84,333)#?@^]mul(324,259)<mul(723,626)*)/select()mul(22,373)from()mul(158,952) #mul(862,250)'$#;{mul(816,365)&$who(930,819) mul(440,442)^@@mul(35,883))>{+mul(904,446)~(?-*:select():]?mul(21,770){&?/what()mul(810,761)( <{#^why()select()mul(542,583)mul(517,719)*who()]mul(229,391)^:,;where()who()[&mul(181,416)>when()( %+{mul(376,885)+}/}*what()[%when()mul(412,213)who() mul(151,478)do()+when()mul(683,117)@how()[@>(*%mul(666,434)%+mul(83,30)^}:mul(983,213)@-what()mul(36,788)';%-#+]#mul(575,6)#when()'&@who()<$ who()mul(764,292)<,where()where()mul(230,519)<<^('mul(384,769)%,what()@who()when()where()when()mul(104,361)&select()what()-!mul(523,283)do()mul(920,551)mul(589,394)$(select()?#>&*'mul(672,365)+:]@$)mul(373,982)mul(810,292)-mul(990,386)?mul(372,766)where(),]^mul(651,898)from()from(){?;select()mul(293,197)why()( [;&^~@mul(505,310)what()what()select():]-what(873,670)mul(885,505);-#{';-how(967,119)select() mul(956,774)mul(51,516)mul(756,597)^~select()how()%&from()mul(463,747)&why()who()())mul(193,948)from()when()what()why()from():select()%select();mul(143,694)(mul(448,194)@<(-where(536,660)?select()mul(280,832)select()#^}mul(296,908)where()@{> #*do(); ;how()mul(417,4)mul(939,57)&'~?-'(#do())[where()+<<where()mul(223,643):%/mul(367,601)}*}[mul(451,653)why()<when()from();(#<;mul(960,745)>%:?(}mul(975,356):,select(275,833),#?(when()&]

1
2024/3/data_test.txt Normal file
View File

@@ -0,0 +1 @@
xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5))

Some files were not shown because too many files have changed in this diff Show More