day 10 init
This commit is contained in:
10
2021/day10/EXAMPLE.txt
Normal file
10
2021/day10/EXAMPLE.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
[({(<(())[]>[[{[]{<()<>>
|
||||||
|
[(()[<>])]({[<{<<[]>>(
|
||||||
|
{([(<{}[<>[]}>{[]{[(<()>
|
||||||
|
(((({<>}<{<{<>}{[]{[]{}
|
||||||
|
[[<[([]))<([[{}[[()]]]
|
||||||
|
[{[{({}]{}}([{[{{{}}([]
|
||||||
|
{<[[]]>}<{[{[{[]{()[[[]
|
||||||
|
[<(<(<(<{}))><([]([]()
|
||||||
|
<{([([[(<>()){}]>(<<{{
|
||||||
|
<{([{{}}[<[[[<>{}]]]>[]]
|
102
2021/day10/INPUT.txt
Normal file
102
2021/day10/INPUT.txt
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
[(([{<{(<{{[({{}{}}{[]()})<{{}()}>]}}(([{{{}[]}[[]()]}[<{}[]]{()()}]](({{}{}}{{}()}))){[{({}())[[
|
||||||
|
<(({[<([{({[{{<>()}}[{<>()}({}{})]]<{<()<>>{[]()}}(((){}>[[][]])>}([{<[]{}>(<>[])}]))<[[[[[][]
|
||||||
|
(<<(<{{{{<<<[(()<>){()<>}][[()()]]>{<{[]{}}<<>()>>}>{(<{<>}([]{})><(<>())<(){}>>)<(([]{})(()()))<<()[]>{{}[]}
|
||||||
|
[[[[<[{[(<{{{({}<>)((){})}((()())[()()])}}><[([((){})]<[()[]]{{}<>}>)[[{[]<>}][([]{})[{}()]]]]>)<{(<
|
||||||
|
[<(<[[((<{((<<<>[]>><<<>{}>>){<[{}<>][<>[]]><<<>()>[(){}]>})[<{[{}<>][(){}]}<[[]<>][{}[]])>{([<>[]][
|
||||||
|
(([[[[<([[{([{<>()}{()<>}][((){})]){[{[]<>}({}<>)][(<><>)[()[]]]}}<{{({}{}){[]{}}}<{<><>}({}{})>}>
|
||||||
|
{{{[<(<([<{({{[]()}[{}()]}{<()<>>(()<>)})}><<[{<()()>(()[])}<<<>[]]>][<{()}{<><>}>({{}[]})]>>](
|
||||||
|
(((<<({<{{<[{[{}[]][()<>]}({{}{}}[{}[]])]>}<<((<{}[]>{<>{}})[{{}[]}])>{<({<>}<<>[]>){[{}{}][()[
|
||||||
|
<[{{[{[[(<{({{<>[]}<{}{}>}<([]())<[]()>>)}({{[[]<>]]<<<><>>[<>]>}<{([]){(){}}}<{[]<>}{[]<>}
|
||||||
|
[(<([{[{<{{[<<()()>{<>}>(({}<>)<()()>)]({{{}{}}[{}()]}[[()<>](<><>)]))}(<<{{()<>}([]())}[<{}
|
||||||
|
(((((<<{<({{<[{}()]({}<>)>(<{}[]>([]()))}<{<()<>>([]<>)]>}[<{<()<>><[]<>>}[{[][]}([]{})]>{[[()
|
||||||
|
(<(([<[[(<{(({(){}}<[]<>>)[(()[])(()[])])({((){})}{<{}{}>(<>[])})}((({<>()}<<>{}>)(<{}<>>{[][]})))>[<[{<{}(
|
||||||
|
<(<{([(({<<(<{()<>}[(){}]><{[]{}}<[][]>>)((([]{}){<>{}}){({}<>){<>{}}})>>(<{<({}<>)<{}<>>>({[]()}{<>{}})}>[[
|
||||||
|
<{{(<<<[(([[[[{}{}]]<[[]][()()]>][(({}[]){[]})<{(){}}{{}{}}>]][({[(){}]([]())}([()<>][{}()]))({([]<>)}[<<
|
||||||
|
(([{{<([[[{{[<<>[]>{()()}][{<>()}{{}}]}([<[]><[]{}>]<<[]<>>>)}][{({[()()]<{}{}>})((<[]<>><
|
||||||
|
{{<{<[{<[{<[({{}()}([]{})){(<>[])([][])}][[{()[]}][<[]{}>]]>({(<{}{}}<[]{}>)[[()<>][{}{}]]}[<<[]()>[{}{}]
|
||||||
|
((<([([(({[([({}{})]({[]<>}<<>()>))({<()()>[<><>]}({<>{}}<{}[]>))]{{[{{}[]}][[()()](()())]}[
|
||||||
|
([<(<[{[<<(<<{<>[]}[[]{}]>([{}][<><>])>[{<<>()><<>()>}])>>]}[(({<{(<()<>>{{}{}})[{[][]}]}<{
|
||||||
|
([(<{{[[[[{{(<{}<>>([]())){{[]<>}{<>()}}}[{[{}<>]<(){}>}]}[<<[(){}]([]<>)><[[][]][<>[]]>>({(
|
||||||
|
(<{[{{<{<<{{<(<>{}){()[]}><(<><>){[]<>}>}{<[<><>]{[]<>}>[[<><>]{[]}]}}>[([<[{}[]]>(<[]()>([]<>))]<[<[]{
|
||||||
|
<{([[<<{[([<<{[]{}}<<><>>><<<>{}>[[]()]>>({<[]<>>({}{})}({()()}(<>[])))][{(<(){}>[<><>])<<{}<>><[][]>>}[[
|
||||||
|
{(<[[{<{[[[{[([][])(()())]}[<[[]<>]{{}()}>{<{}[]>[(){}]}]]]{[<({[][]}(<><>))[([][])<<>[]>]>({{{}[]}[<>{
|
||||||
|
[({{{(({[<(([<(){}>[[]{}]]){{{{}()}}[<[]()>({})]}){<[<{}{}>{[]()}](({}[]>{<>[]})>[([()<>][[
|
||||||
|
{{<{{{<([<<[{[[][]]({}())}[<<>[]><<>[]>]><{(<><>)({}{})}{(()<>)([][])}>>{<[<{}{}>{()()}]{<{}{}><[]>
|
||||||
|
([<<[((({{{<([{}[]](()()))<(()()){{}{}}>>{[{<>[]}({}())>}}}<{[<<{}<>>(<>{})>(({}<>)[()[]])](<{()<>}
|
||||||
|
{(<<<[[<[({{[{{}{}}][[[]{}](<><>)]}<{([]{})<[][]>}[{{}{}}<()()>]>}<[{{()[]}{()[]}}[[[][]]{(){}}]](<({
|
||||||
|
<{{((<{[<({{([<><>]([]<>))}(<<()<>><(){}>>{([]<>)([][])})}{[{({}())[()()]}[<<>()>{[][]}]](
|
||||||
|
<<<[({({<({[<<<>{}>(<>{})>]((<<>()>[()])(({}{}){()()}))})>{{<(([()<>]<<>[]>)({()}))>}}})}<{({<<(<<{}>(
|
||||||
|
<(<{<[((<(<[([()<>][[]()])]<((<>)<{}{}>]({()()}[[]{}])>><<{{<><>}{{}<>}}([[][]]<<>>)><(<{}{}>({}[]))
|
||||||
|
[[([{[{[{({([<()>]{(<>())(()())})[[{<>()}{()<>}][[<><>][[][]]]]}{(({{}{}})[{{}()}[{}<>]]){[<()()>{()[]}]
|
||||||
|
[<<[{<({([<(<({}())[[]{}]><[[]{}]{<>()}>)>(<(<()()>)(<()<>>[{}[]])>)]<<[{<{}[]>([]{})}<((){})<
|
||||||
|
{[{{<{[{({{<[<<>{}><[][]>]<<(){}>[[]<>]>>([[<>[]]<()[]>](({}{})(()<>)))}}{<<{<(){}><()[]>}[(<>[])(
|
||||||
|
[<<[[([[{{[({<<><>><<>[]>})({<{}()>({}[])}((()<>)[<>()]))](<([()()])<<<>[]><()()>>>)}<{<{(()<>)[()[]]}<({}())
|
||||||
|
[{([{<([<(<<(([][])<<>[]>)<{<><>}(<><>)>>(<(<>[])([]{})>{<()<>><{}<>>})>((<[<>[]][[][]]><{<><>}(<>[])>)))[
|
||||||
|
<{{([{[([[{<[(()())[{}{}]]><[<[]>[(){}]](([]<>)(()()))>}{([{[]()}[{}[]]]<[<>[]][<>{}]>)}]][<[<<(<>{})[{}{}]>>
|
||||||
|
{{[<<{{({({<<{<>()}<{}[]>>>{<[<>()](()<>)>{(()<>)<{}[]>}}}<((<<>[]>{()[]))<{[]()}{<>[]}>)<[[{}][{}[
|
||||||
|
[<<[<<{[[<({[[{}[]]([][])]<({}[])>}<{{<>{}}<[]()>}{([]<>){()<>}}>)<{(<()<>>(()<>))(<<>><()<>>)}>>]<{<<
|
||||||
|
<{({(<<(<{({<({}<>)>({{}}{<>()})}{<(()<>){<>{}}>{{[][]}({}[])}})}>)>>([<(({(({<><>}({}[])){{()<>}[[]]})<((<><
|
||||||
|
(<{[[([[<{[<{<[]()>([]())}((()<>>{{}{}})>]}>]]{<<<[(([[]<>]<{}()>)({<>{}}<()[]>)){<{{}()}<[]<>>>[
|
||||||
|
[[{[<[[<<{<([{()[]}{{}{}}]<<[]{}>>)<[[{}<>]{{}[]}]{[{}()]{(){}}}>>({([()()]<[]<>>)<{{}()}(
|
||||||
|
((([{({[{<{({{[]<>}[{}()>}[({}[])[[]()]])[[{<>[]}{{}[]}]<[(){}]{()()}>]}{<{([]<>)}>([{<>{}}]{
|
||||||
|
[(<(<({{{((<[<<>[]>{()<>}][[[][]]<<>[]>]>[[<[]{}>[{}{}]]{([]()){<>())}]))([(<<[]{}>>)][[{(()<>)([][])}]{<(<>
|
||||||
|
{<[[<<{({[(<(({}{})(<>{}))<{<>[]}<<>()>>><(<()>({}()))[{[]{}}(<>[])}>)]}){(<{(({{}[]})<(<><>)([]())>){[([][
|
||||||
|
[[{[<{[((<[<<<<><>>[<><>]>[<<>>{<><>}]>][{{<()>{{}[]}}{({})[{}()]}}[<[[]{}]{()()}>({[]()}(<>{}))]}>{{<([
|
||||||
|
{<<({<[<(([[[[[]()]][<{}<>><()()>]](<<{}[]>[<>()]>[{<>{}}[()]])])({(({{}[]}<<>()})(<<>()>)){[{()<>}{(){}}]
|
||||||
|
<[[<<[{([(({{{<>[]}([]{})}<[[]()]<()()>>}[<({}[])[[]<>]>[<{}()>[()()]]])[{(<[][]>{{}<>}){{<>()
|
||||||
|
([[<(<({({(<([<>[]][[][]])[<()[]>[[]()]]>{((()())([]{})){<{}()>{<>{}}}})}[<[<[()<>]{[]{}}>({[][]}(
|
||||||
|
[<{<([{<[{<[<([][])}([[][]]<<><>>)]><(<(()[])<()<>>>({<>{}}[<><>]))>}<(<(({}()){{}[]})[<<>[]>]>){
|
||||||
|
{{[<{<{([<<[{[()()]{[][]}}[[[]{}]{{}[]}]]{<<{}()>[[][]]>{{()[]}(()())}}>{[{[(){}][[]()]}<<()>
|
||||||
|
<{[<{[{{(<<(<<{}>>{{()[]}({}{})})<{[<>{}][<>{}]}((<>{}))>>([[(<><>){()<>}][(()[]){[]<>}]])>)}<<{{([<<>
|
||||||
|
{<({<<{((<{<(<{}>[()])[[(){}]]><<[<>[]]>(([]())([][]))>}<[{<{}()>[[]{}]}[[<><>]([]{})]]>)<[[<{[]}[()[]
|
||||||
|
[{<{[[[([[((<[[]{}][<>{}]>[((){})([][])]]({[[]<>][{}()]}[(<><>){[]<>}])){[<[{}]><[()()]>]<<([]<>)(<>())>{<<>[
|
||||||
|
[{[{<([[[(<{<<[]{}>([]{})>[[<>{}]]}>[<[[{}]<<>{}>]{<{}<>>{<>{}}}>([<{}[]><(){}>]<(()())(()<>)>)])<<<[(()<>)(
|
||||||
|
[(([<{(<({<<<(()()){(){}}>[{<>}(<>{})]>[{([]()>(<>())}<(())[()<>]>]>(([<{}{}>]{[[]{}]({}())})(([<>{}]<()<
|
||||||
|
{[{([([[[{<{[<{}()>{{}{}}]<{<>[]}([]<>)>}[(<<>{}>({}{}))<<{}()>{{}[]}>]>}{(<[[()()]}>{[[()()]<{}[]>][[()[]]]
|
||||||
|
[<([[{[<<[{[{({}[]){{}{}}}]}]([({{()()}}<[[]()][{}[]]>)([[()()>])]{<{<()[]>[<>[]]}<[{}{}]{<>()}>>
|
||||||
|
<<(<[<((((((<{(){}}[<><>]>)[<<()[]><{}[]>><<()[]>{{}[]}>])[(<<()}>([{}<>]))({<{}><[][]>}{([]())[{}<>]})])){<
|
||||||
|
{[([{[[(<{<{{<{}{}>(())}}>}(({{{[]()}<{}[]>}{([]{}>{<>[]}}}<{<[]()><()[]>}<[<>{}][[]<>]>>)((<[{}[]]<[]<>>
|
||||||
|
<{{{(([[([{{{<(){}>{{}()}}{({})<()[]>}}[{(()[])({}<>)}[{[]{}}{()<>}]]}]<(<([{}[]](<>{}))[<()[]
|
||||||
|
<({({[<<([{{({<><>}[{}[]])}{(<<>>([]<>))<{(){}}{<>()}]}}])({{{[{(){}}[(){}]]<[()<>][{}{}]>}}}{
|
||||||
|
(({[(({({((<({[]<>}{[]<>}){[[][]][(){}]}><<<{}[]>(<><>)>(({}<>)({}<>))>)<{{[[]<>][<>()]}}<[(()
|
||||||
|
<([{{[({([([<{()()}<{}>>{((){}){{}[]}}]<<[[][]]({}<>)>((()())[[][]})>){[<[<>()]<{}<>>>(<<>{}>[[]{}])]{[[
|
||||||
|
{[[[[<{([<[({[[]()]<{}{}>})((<<>{}>[[]<>])<(()())([]())>)]({{[[]<>][{}[]]>[[[]<>]([]{})]}({{(
|
||||||
|
[<{<[[<[[({([{{}<>}{<>}][{{}[]}{(){}}])[{<<>()>)([<>()](<>[]))]})]][({[[(([]<>)[{}()])[({})(<>
|
||||||
|
([<{{{<([{[[([<>[]]<{}{}>)[({})[<>{}]]]]{<<({}[]){[]()}>[<{}()>]>[([{}[]][()<>]){[()()]<<>()>}]}}<{({{()()}[
|
||||||
|
{(({[({<<[{[(([]{})<{}{}>)({[]<>}[<><>])]}({({()[]})(({}<>)[{}]}}([{[]{}}(()())]))]>(<[[[{[]{
|
||||||
|
[{[((<{[{<[([{<>[]}<[]{}>]({()<>}[[]{}]))<[[<>{}]<[][]>]<{(){}}{[]{}}>>]<({(()()){[][]}}{{[]{}}{()<>}}){
|
||||||
|
{{<{({{<<({{(([]())<<><>>)((<>())[{}{}])}{((<>{})[()<>])[(()<>){{}{}}]]})<({[[<>{}]<{}<>>]([<><>
|
||||||
|
{<[<[{[(({((<[<><>]([][])>{{<>{}}<{}()>})(<{{}{}}([])><{()<>}(<>{})>))(<{{()<>}{<><>}}[{{}{}}([]<>)]>)}[
|
||||||
|
[<[[[(({(([({{<>[]}<()<>>})([[{}()]([]<>)]({<>[]}[{}()]))])<{(<[[]<>]{[]<>}>){{{<>[]}}(([]{}))}}<[<{<><>}{
|
||||||
|
[<{{(<[(<<([<<{}[]>[<>()]>({<>[]}{<>})]<[{[][]}[()]]>)({{[()<>]<<>{}>}<(<>[])({}[])>})>((<{{()}}{<()<
|
||||||
|
[[(([[<{<<({<(()<>)[{}[]]>[<()[]>[()<>]]}(((()())[{}{}])))>[([({{}[]}([]<>)){({}<>)([][])}]
|
||||||
|
<{<<<<[([([[(<[]<>>){{<>{}}[()[]]}]]{[<<()[]><{}[]>>[<()<>>([]())]][{<<>[]>[{}()]}]})][<[<[
|
||||||
|
({{<[<[(([(([<()()>{()[]}][(()())[{}]])(((()[]){{}[]})({[]}{[][]})))]<[{[[[]()>]<[<><>]>}[(
|
||||||
|
<[<[[[{(([<(({{}{}}<()[]>))>{[<({}<>}([][])>]<[(()()){()()}]<<{}[]>({}())>>}]<<[([<>]([]<>))[{<
|
||||||
|
{[[<[(<(<{({[[[]}{<>{}}]}({{{}()}<{}[]>}<<()[]>{[]()}>))}[[{<{{}<>}([][])>[{()()}]}(([{}<>])({[][]}<<>[
|
||||||
|
(<({[{[<<<({[[()[]]]})>>{[{{{[()()][[]{}]}{{<>{}}(<>[])}}<{<{}{}>(<>())}<{[][]}[{}[]]>]}<<[<<>()>
|
||||||
|
[[(<(<{<(<{<<{{}<>}<<>{}>>{{()<>}(<>())}>}>){[[{<<<>{}>[{}<>]><{[]}((){})>}[[<<>[]>{<>()}][{{}{}
|
||||||
|
{[((((({<({({(()())}([{}<>]<()[]>))([<[]>[[]()]]<[[][]](<><>)>)}[<[{{}<>}[[]<>]]>{<<()[]>{{}()}>[{<>}{()[]
|
||||||
|
<[{[(<<[{[<<<<[]()>[<><>]>[<{}<>>]>>]}[([[<({}())[{}()]>{({}{})(<>)}]]([<{[][]}((){})>[{{}()}
|
||||||
|
[[{[[({([<<{[{<><>}<[]{}>][[<><>](()[])]}>[(({{}{}}([][])))((<{}{}>[{}{}])({[]}{{}}))]>]{(
|
||||||
|
{<[(({{<[(<[{({}{}){(){}}}<(<>{})({})>]<(<<>{}>)<{{}()}<<>[]>>>>{[<<[]{}>{[]()}>{[[][]][()[]]
|
||||||
|
({[<[{[<[{[(([{}[]]<{}[])){{{}[]}<{}()>}){[{()[]}(<>{})][{<><>}]}]{{({{}<>}([]{}))}{((<><>)([][
|
||||||
|
[[(<[{({({({<{{}[]}<()<>>>[{(){}}{<>[])]}<<<[]()>>{<()[]>({}())}>)(<[{(){}}([]<>)]{[()()]<{}>}>
|
||||||
|
<{[{[(({{<{(([<>[]]{[]{}})({{}[]}[<>()]))[[{()<>}<{}{}>]<[()<>]<[]()>>]}<(<(()<>)[()[]]><[<>()}{[]{}
|
||||||
|
(([(<[{[{[({<[[]{}]{{}{}}>}([<[]()>(()())]))<(<(()[])[{}[]]><[()<>][{}<>]>)<(<[]{}>]{({}())[<>
|
||||||
|
([{<[<[{{((<<{{}{}}[[]{}]><[{}{}]<{}{}>>><({<>{}}([][]))((<>[]){{}<>})>)[{[([][])[[]{}]]<[{}][<>()]>}])([[<[
|
||||||
|
[{({((<({(({({{}<>})({()()}(()()))}(<<[]{}>><(<>())({}<>)>))<[[(<><>)[[][]]]<{()<>}[[]{}]>]<((
|
||||||
|
{({{({({[{([[{[][]}([]())]<([]())<{}{}>>][[([])[{}<>]]{{<>[]}<<>{}>}])[<<{<><>}{{}<>}>>{<{
|
||||||
|
{{(<<(([<{<((<<>{}>{<><>})[([]()){[][]}]){{{[][]}[()]}[({}[])]}>}[<[<{()<>}<<>()>>]<(<(){}><()[]>){[()[]](<>
|
||||||
|
{((<(<[[[<(<<[()()]<[]<>>>)({(())[{}[]]}))<{<{{}<>}>[{[]}[()]]}<<(()<>)[[]()]>(<(){}>[<>[]]
|
||||||
|
<<{<<{({({({({{}()})({{}<>}([]()))}(({()[]}[()<>])[<()[]><[][]>)))(<<[[][]](<><>)>(((){})([
|
||||||
|
{<<{(<{{{{((([()[]][[]{}])[{()<>}{<>[]}]){{{<><>}}(([])[[]()])})[((<{}()>[[]<>])({[][]}{()(
|
||||||
|
[((<{{(<({[<<[<>{}]{(){}}>([{}<>](<>()))>][[([[]()][[][]])<{[]<>}{[]}>]<((()<>))>]}((<[([][
|
||||||
|
(<<([(({(([[([[]<>]{<>{}})(<{}[]>[{}<>])]<([[][]][[]{}])>][<<{<>{}}<<>[]>>[<<>{}>{()()}]><(<[]())({}())
|
||||||
|
(({[{([({<<{{{{}{}}(<>())}[([]<>)(<><>)]}<{{()}}<<{}<>><(){}>>>>>}>([<((<{{}<>}[[][]]>{{<>[]}[()
|
||||||
|
([{(<([<[<([({{}<>}<{}[]>)][{[{}()][[][]]}[(()())(<><>)]>)><([<[()<>]<(){}>>{[<><>]<{}<>>}]{
|
||||||
|
[<<(<[({((((<(()<>)[[]{}]>[{<>[]}{()<>}])(<<()[]>(<><>)>{(()[]){[]<>}}))({[{()<>]{()<>}]{{()()}(<>{}
|
||||||
|
([<<{({({(<{{<()<>>(<>{})}[<(){}>([]())]}[({{}<>}([]))]>([<({}{})[<>()]><(<>[]][(){}]>]<[<<>[]>({}<>)][{<>}
|
||||||
|
[<[{[[{[[{[({([][])([][])})[([{}[]][<>[]))<[[][]]<()<>>>]][<([()[]]{[]<>})>[{({}<>)[{}()]}]]}][(
|
||||||
|
{<<<<[[<{{[{<[[]{}][{}{}]>}(<<{}<>>(<>{})>({<>()}<()<>>))]<<<(<>())<()<>>>><[<(){}>[<><>]>>>}}[(({(<<><>>({
|
||||||
|
<[<(<([((<[<(<{}[]>(()<>)){({}[])([]<>)}><[{[]<>}{<>()}]>][<<{<>[]}{(){}}><[()<>]{[]}>][<({}<>)>]]>)[[[((
|
55
2021/day10/Makefile
Normal file
55
2021/day10/Makefile
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# AOC daily Makefile - GNU make only.
|
||||||
|
#
|
||||||
|
# Copyright (C) 2021 Bruno Raoult ("br")
|
||||||
|
# Licensed under the GNU General Public License v3.0 or later.
|
||||||
|
# Some rights reserved. See COPYING.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with this
|
||||||
|
# program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
|
||||||
|
#
|
||||||
|
|
||||||
|
INPUT := INPUT.txt
|
||||||
|
SHELL := /bin/bash
|
||||||
|
|
||||||
|
CC := gcc
|
||||||
|
|
||||||
|
LIB := aoc_$(shell uname -m)
|
||||||
|
INCDIR := ../include
|
||||||
|
LIBDIR := ../lib
|
||||||
|
LDFLAGS := -L$(LIBDIR)
|
||||||
|
LDLIB := -l$(LIB)
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH = $(LIBDIR)
|
||||||
|
|
||||||
|
CFLAGS += -std=gnu99
|
||||||
|
#CFLAGS += -O2
|
||||||
|
CFLAGS += -g
|
||||||
|
CFLAGS += -Wall
|
||||||
|
CFLAGS += -Wextra
|
||||||
|
CFLAGS += -march=native
|
||||||
|
CFLAGS += -Wmissing-declarations
|
||||||
|
CFLAGS += -Wno-unused-result
|
||||||
|
|
||||||
|
TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n"
|
||||||
|
export PATH := .:$(PATH)
|
||||||
|
|
||||||
|
.PHONY: clean all compile ex1 ex2
|
||||||
|
|
||||||
|
all: ex1 ex2
|
||||||
|
|
||||||
|
compile: aoc-c
|
||||||
|
|
||||||
|
ex1: aoc-c
|
||||||
|
@$(TIME) aoc-c -p 1 < $(INPUT)
|
||||||
|
|
||||||
|
ex2: aoc-c
|
||||||
|
@$(TIME) aoc-c -p 2 < $(INPUT)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@rm -f aoc-c core*
|
||||||
|
|
||||||
|
.c:
|
||||||
|
@echo compiling $<
|
||||||
|
@$(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@
|
56
2021/day10/README.txt
Normal file
56
2021/day10/README.txt
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
-- Day 10: Syntax Scoring ---
|
||||||
|
|
||||||
|
You ask the submarine to determine the best route out of the deep-sea cave, but it only replies:
|
||||||
|
|
||||||
|
Syntax error in navigation subsystem on line: all of them
|
||||||
|
|
||||||
|
All of them?! The damage is worse than you thought. You bring up a copy of the navigation subsystem (your puzzle input).
|
||||||
|
|
||||||
|
The navigation subsystem syntax is made of several lines containing chunks. There are one or more chunks on each line, and chunks contain zero or more other chunks. Adjacent chunks are not separated by any delimiter; if one chunk stops, the next chunk (if any) can immediately start. Every chunk must open and close with one of four legal pairs of matching characters:
|
||||||
|
|
||||||
|
If a chunk opens with (, it must close with ).
|
||||||
|
If a chunk opens with [, it must close with ].
|
||||||
|
If a chunk opens with {, it must close with }.
|
||||||
|
If a chunk opens with <, it must close with >.
|
||||||
|
|
||||||
|
So, () is a legal chunk that contains no other chunks, as is []. More complex but valid chunks include ([]), {()()()}, <([{}])>, [<>({}){}[([])<>]], and even (((((((((()))))))))).
|
||||||
|
|
||||||
|
Some lines are incomplete, but others are corrupted. Find and discard the corrupted lines first.
|
||||||
|
|
||||||
|
A corrupted line is one where a chunk closes with the wrong character - that is, where the characters it opens and closes with do not form one of the four legal pairs listed above.
|
||||||
|
|
||||||
|
Examples of corrupted chunks include (], {()()()>, (((()))}, and <([]){()}[{}]). Such a chunk can appear anywhere within a line, and its presence causes the whole line to be considered corrupted.
|
||||||
|
|
||||||
|
For example, consider the following navigation subsystem:
|
||||||
|
|
||||||
|
[({(<(())[]>[[{[]{<()<>>
|
||||||
|
[(()[<>])]({[<{<<[]>>(
|
||||||
|
{([(<{}[<>[]}>{[]{[(<()>
|
||||||
|
(((({<>}<{<{<>}{[]{[]{}
|
||||||
|
[[<[([]))<([[{}[[()]]]
|
||||||
|
[{[{({}]{}}([{[{{{}}([]
|
||||||
|
{<[[]]>}<{[{[{[]{()[[[]
|
||||||
|
[<(<(<(<{}))><([]([]()
|
||||||
|
<{([([[(<>()){}]>(<<{{
|
||||||
|
<{([{{}}[<[[[<>{}]]]>[]]
|
||||||
|
|
||||||
|
Some of the lines aren't corrupted, just incomplete; you can ignore these lines for now. The remaining five lines are corrupted:
|
||||||
|
|
||||||
|
{([(<{}[<>[]}>{[]{[(<()> - Expected ], but found } instead.
|
||||||
|
[[<[([]))<([[{}[[()]]] - Expected ], but found ) instead.
|
||||||
|
[{[{({}]{}}([{[{{{}}([] - Expected ), but found ] instead.
|
||||||
|
[<(<(<(<{}))><([]([]() - Expected >, but found ) instead.
|
||||||
|
<{([([[(<>()){}]>(<<{{ - Expected ], but found > instead.
|
||||||
|
|
||||||
|
Stop at the first incorrect closing character on each corrupted line.
|
||||||
|
|
||||||
|
Did you know that syntax checkers actually have contests to see who can get the high score for syntax errors in a file? It's true! To calculate the syntax error score for a line, take the first illegal character on the line and look it up in the following table:
|
||||||
|
|
||||||
|
): 3 points.
|
||||||
|
]: 57 points.
|
||||||
|
}: 1197 points.
|
||||||
|
>: 25137 points.
|
||||||
|
|
||||||
|
In the above example, an illegal ) was found twice (2*3 = 6 points), an illegal ] was found once (57 points), an illegal } was found once (1197 points), and an illegal > was found once (25137 points). So, the total syntax error score for this file is 6+57+1197+25137 = 26397 points!
|
||||||
|
|
||||||
|
Find the first illegal character in each corrupted line of the navigation subsystem. What is the total syntax error score for those errors?
|
Reference in New Issue
Block a user