diff --git a/2023/day-10/demo-input.txt b/2023/day-10/demo-input.txt new file mode 100644 index 0000000..2417530 --- /dev/null +++ b/2023/day-10/demo-input.txt @@ -0,0 +1,5 @@ +-L|F7 +7S-7| +L|7|| +-L-J| +L|-JF \ No newline at end of file diff --git a/2023/day-10/input.txt b/2023/day-10/input.txt new file mode 100644 index 0000000..88c152b --- /dev/null +++ b/2023/day-10/input.txt @@ -0,0 +1,140 @@ +.|-J--7F7F-F|-F777F7J-J7F--7..-LJ7F|.F7L-77--F7|7.F-7-77.F.L---J.F---FLJF-F|77-|-----|-FL-J-|7-7FF.7--F7F7.F--F7.FF-F--J-.L-L77--77|---L7--7 +--7-L7.FJ7--JF---7F||.LL|J-7.FJ7.-JJ--JJ.||JFJLF.FJ-|7J7L7-L7JJ|77-J||JFLJJ.LL--7JFJJJ||FL.LJ|-7FFL.FJ|F-F-|J||L-L-LJL-7LJFLJJL--F77.LF.|F|F +LJ7L|.L|..LF|JF-7L-7-7|L||7L|L7-7|7FF-JL|F|-J77L7FJ.L|--J|7LJ.|F7-F7||77J7.F7|LLL.|-|---7JF7-|-7-7|FJF7..LLJLLJ..L7LL-FL7FF-LFJ.FF.-|7LJ.-L| +FJF7-7.|FL-7L||-|JFJ-|JJ||7J|F7F|JFL|.J7L--7LFJ||||L.L-|.-L.LF-JJJLFJL7..F|.|7...F7--.|F|.FJ7JFLJL|JFFL-7|FLLJL|-|-F.FF-7-LF.LJ-JL7||FJFJJLJ +--J|.7.FJF7|7--7F7|-7J7.||L-LJ|7.||.7-||.|J|LFL7FLJ7F7JF-L|-F|F7FFFF7LF-F-7FLL-7.7L-J-FF--7F7F7JF--7FF7LL|-F--7JFJF7-FJ7LL77-|...FFLJJ7|JFJJ +L|.LF-F7LLJJL|.JL||FLL|F|F|7|JL-77L..--J-F-|.LJ||--LJL||-||F-|.|-FFJ|F7-L7L7-7||F7.LJ|LL7FJ||||F7-L-7.-7||F-7LJ7L-|JLJ-77F|L|L-FJJ77|F|-JLJJ +||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LJ||FJ|F---J||FJ||L7JFJ|F7|||LJ|||L7L---7L7L7FJ|F--J|||||F--J7LJ-LF77.77J.|J +L7FJF7-7FL-JJJ.F-7--L-7|L||||LJL7|F7F--J||FJ|||FJ||L7L-7|L--7F---7LJL-J|F77FJLJFJL7L7L7||LJL7F7||L7L7F--JFJFJL7|L-7FJ||LJL-7F7F-7-||7-LL-L|7 +.L|-7.FLJ.-|JJ-7FF7.|FJL7||||LF-J|||L7F7LJ|FJ|||FJL7|F-JF-7-LJF7FL7F---J||FJF-7|F-JFJFJ|L--7|||||J|FJL--7L-JF7LJF-JL7LJF7F7||LJFJ-||J.7-7.|7 +|.|.F.77||.-7J.|F-J-LL-7LJ||L7L-7||L7LJL7FJL7|||L-7LJL7LL7L7F-JL--JL7F-7|LJFJJLJL7FJFJFJF7FJLJ||L-JL7F7LL7F7|L--JF--JF7||||LJF7L--J|-7L-JLJJ +|-|-JF|-FJ.LJ777F77|.F7L-7|L7L-7||L7|F--J||FJ|||-FJF--JF-JFJL------7||FJL-7L7F7F-JL7L7|FJ|L7F-J|F--7|||F7LJ|L7F-7|F7FJLJLJ|F-J|F--7|.|J|.L7J +LJJ7FLLF-F.L|LF7||F-7|L7FJL7L-7||L7||L--7L7L7||L7|FJF7.L-7|F7F-----JLJL-7-L7|||L--7|FJ|L7|FJL-7LJF7||||||F7|FJL7||||L----7LJF7LJF7LJFL-|7LL. +.|FFFJJ|JFLF-7|||||FJ|FJL-7|F7|LJFJ||F7LL7L-JLJFJ|L-JL-7FJ|||L-----7F---JF7|LJ|F7FJ|L7|-|||F--JF-J||LJ|||||||F7||||L-----JF-JL77||J.FJ||F-LF +LFJJJLFLF7|L7LJLJLJL7||F-7||||L-7L-J|||F7L-7F--JFJF--7FJL7|||LF----J|F7LFJLJF-J||L7L-JL-JLJL7FFJF7|L-7LJ||LJ||||||L-----7FJF-7L7|L--7FFL-7-| +||||L777|L7LL-----7FJ||L7|||||F7L7F-J||||F-J||F7|FJF7LJ7FJ||L7L----7LJL7L--7|F7|L7L---7F7F-7|FJFJLJF7L-7||F7LJLJLJF-7F--J|FJ.L7LJF--JJJL.--- +FL|77JF-L7|F------J|FJL-J||||LJ|L||F7||||L-7L7|||L7||F7FJFJL7|F7F--JF--JF-7|LJ||FJJF-7LJLJF|LJFJF7FJL7FJ|||L------J||L---JL7F7L--JJFL-LL|.J. +J.|J7-L-FJ||F-----7||F---J||L7FJFJ||||||L--JFJ|||FJ|||LJFJF7||||L--7L--7L7||F-J|L-7|FJ|F7F-JF-J7|||F7|L7||L--------7|F7F7F7LJL--7L--J..L77|. +|7|.-77.L7|LJF-7F-JLJL-7F-J|FJL7|FJ||||L---7|FJLJ|FJ|L-7L7||||||.F7|F--JFJLJL--JF-J||F7||L7FJ.F7||LJ||FJLJF7F7F7F-7|||LJ|||F----J7.F7--7.L77 +FF-.L|FF7||F7L7|L---7F-JL7FJL-7||L7|LJ|F7F7||L--7LJFJF7L7||||||L7|||L7F7L-7F----JF7|||||L7|L-7|||L7FJLJF7FJ||||LJLLJ|L-7LJ|L-----77||--|.FJ| +F|JF7F-J|||||FJL----JL7F7|L---J|L7|L-7|||||||7F7|F-JJ||.||||||L7||||FJ||F7||F7F7J|||||||FJ|F-J||L7|L--7|LJJLJLJF---7L7FJF7L7F7F--J77||-FLJ-7 +-JFL-L-7||LJ|L-------7|||L-7F-7L7||F7|||||LJ|FJLJ|F7FJ|FJ||||L7|||||L7|||||||LJL7|||||||L7|L7FJL7|L7F7||F----77|F--JJLJ|||LLJLJF7F-7FL-7-|F7 +.F7.LF-JLJF7L--7F7F--J|||F7||FJFJ||||||||L-7|L7F-J||L7||FJ|||FJ|||||FJ||||||L7F-J|||LJ||7||FJL7L|L7||||LJF7F-JFJL7F-7|F-JL-7F7FJLJFJJ-LJ.LLJ +.LJJ7L----JL--7|||L--7LJ|||LJL7L-JLJ||LJ|F7||FJL7FJ|FJLJ|FJ||L7|||||L7||||||FJL-7||L-7LJFJ|L7FJFJFJ||||F-JLJ.FJF7||FJFJF--7LJLJF-7|.|..77..| +F-JJFF7F------JLJL77FJF7|||LF7L----7LJF7|||||L7FJ|FJL-7.LJFLJFJ|LJ||FJ||||||L--7|||F7|F-JFJJ|||L7|L||||L----7|FJ|LJL-JFJF7L7F-7L7LJ7-77L7--| +F.-7FJLJF7F7F----7|FJFJ|LJL-JL-----JF-J|||LJL7|L7|L7F7L--7F--JFJF-J||FJ|||||F7FJLJ||LJL7FJF-J|F-JL7|||L7F---J|L7L-----JF|L7|L7|FJ7F|JLLFJL77 +|FLLL-7FJLJLJF---JLJFJFJF----7F7F7F7|F-J|L-7FJ|7||FJ||F--JL-7FJ-L-7||L7LJLJ|||L7F-JL-7JLJ.L7FJ|F7FJ||L7|L7-F7|FJF7F-7F-7|FJL-JLJ-F-.F7.LJ||J +J--||L||J7.LFJF----7L7L7L7F--J|LJLJLJL7FJF7|L7L7LJL7|LJF---7LJF-7FJ||FJF7.FJ|L7||F-7FJF7F7FJ|-||||L||7LJ|L-JLJL-J||FJ|FJ||F7F7F7|LJ-F-J..|.. +||FJFFJ|-F--JFJF7FFJFJ-L-JL-7FJF------JL-JLJFJFJF--JL--JF-7L7|L7|L7||L-JL7L7L7||||FJL-JLJ|L7L7||||FJL7F-7F-------J|L-JL7||||||||F7|.LF7.-|7. +L7J-L|FJ-L---JFJL-JFJF--7F7FJL7L-----7F7LF-7L7|J|F-7F7F-JLL-JF7|L7LJ|F-7FJFJFJLJLJL7F--7FJ.L7|||||L-7|L7LJF-------JF7F7LJLJLJLJ|||F7-|-7..FF +L7--FLJJ.FF7F7L-7F7|.L-7|||L-7|F----7LJL-JFJ7|L7LJFJ||L---7F-JLJFJF7||FJL7|FJF-----JL7|LJF--J||||L7FJ|LL--JF-7F-7F-J||L--7F-7F-J||||.|FJFJFJ +-L-LL|.FLFJLJL--J|||F--JLJ|F7LJL---7|F7F-7L-7|FJF-JFJL--7FJL---7|FJLJ|L7FJLJJ|F--7F-7L7JFJF-7||||FJL-JF7F--J7|L7|L-7|L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|L-7|L-JLJLJ||FL-7L7L7LJL777-JF-.|| +||FLFJL7FJL-J|LJF7|L-JLJF7|L7F---------JLJ|FJL--7F7|||L7FFJ|LJF7LLJFL--7|L7L7FJFJL7FJF----JL7F-7FJ||LJLJLJF7LJLF7F--7|L--7L-J.L-7FJ.J..|.FJ| +FL7-L-7|L---7|F-JLJF-7F-JLJFJ|F-----------J|F---J||LJL7L7L7L--JL-7F----JL7L7LJFJF7LJFJF7F7F7|L7|L7|L--7F--JL-7FJLJF-J|F-7L7JF7F7LJ77|FL-FLF- +LJ.7LFJ|F7F-JLJF--7|LLJF7F-JFJL------------JL--7FJL--7|FJL|F--7F7||F---7FJ-|F7L-JL-7L-JLJLJ|L-JL-J|F7FJ|F----JL7F-JF7LJLL7L-JLJL7F7-LJJ-LJ|J +.FJ.LL7LJLJF-7FJF-JL7LFJLJF-JF7F-----7F--------J|F---JLJJFJL-7||||LJF--JL-7||L7F7F-JF---7F7L-----7LJLJFJL---7F7||F-JL---7|F7F---J|||LJ--|.-- +F7J|-LL7F-7|FJ|-L---JFJF--JF-J||F---7|L-------7L|L----7F7|F7FJ||LJF7L--7F-J||FJ||L-7L--7LJL------JF7F7|F----J|LJLJF7F---J||LJF7F-J|J77.FF-J| +|J.|L|-LJJ||L7|F-----JFJF--JF7LJL7F-JL--------JFJF----J||LJLJ7LJF-JL---J|F-J|L7|L--JF-7L7F7F--7F7FJLJLJL-----JF7F7|LJF7FFJL--JLJF-J|7-7.J7|7 +FF7FF7F---J|JLJL--7F7FJ7L---JL7F7|L-----7F--7F7L7|F---7||F7F7F7LL-7F---7|L7FJ.|L7JF7L7||||||F7LJ||F7JF--------JLJLJF7|L7L-----7FJJL|7J..L7J7 +7-||||L--7FJF-----J|LJF------7||||F----7LJF7||L-JLJF--J|LJLJLJ|F--J|F--JL7|||FL7L7|L-JL7LJLJ|L--J||L7L-----7F--7F7F|LJFJF7F7F7LJJ|JLL7J.FJ.7 +LJF-JL---J|.L-----7|F-JF7F--7LJ|LJL---7L--JLJ|F---7L--7|F7F7F-J|F-7|L-7F7|LJF-7L-JL-7F7L-7F-JF7F-JL7||F7F--J|F-J||FJF7|FJLJLJL---7--JLF|JL7. +|7L---7F7FJF-----7LJL--JLJF7L-7|-F----JF7F7F7||F-7|F7FJ||LJLJ|FJL7LJF-J||L-7L7|F7|F7LJL-7||F-J||F--JL-J|L---JL--JLJFJLJL7F7F7F-7FJJ.|-F|7FFL +-7F---J||L7L7F7F7L7F7F-7F-JL--J|FJF7F-7|LJLJLJLJFJLJLJFJL----7L7FJLFL-7||F7L7||||FJ|-F--JLJ|F-J|L-----7L------7F7F7L----J|LJLJ.LJJ.F7.-J7.FJ +|LL-7F7|L-JLLJLJL7|||L7|L-7F7F7|L7|LJFJ|F-7F----JF7F7FJF-7F7FJFLJJLF-FJ|LJ|FJ||||L7L7L----7||F-JF-7F7FJF----7F||LJ|F---7FJ-F-----7J|L-J|L7L7 +||LL||||.LF-7F---JLJL-JL-7||LJLJFLJF7L-JL7|L-----J||LJFJFJ|LJ--JJ-FJ7|FJJLLJFJLJL7L7L7F--7||LJF7L7LJ||FJ-F-7L7|L-7||F-7LJF7|F---7|-FJJF7F-7| +.LJL||LJF|L7LJF7F7F-7F7F7|LJ-F7F7F7||F-7FJL---7F--J|F-JLL7|J|JJ|J7F.LLJ|7-||L-7F7L7L7||F-JLJF7||7|F7LJ|F7|FJFJ|F-JLJL7|F7|LJ|JF7LJ|F7.JL|F7- +|7-FLJJ|7F7L--JLJ||FJ||||L7FFJLJLJLJLJ-|L----7|L---JL--7|LJ.LJ.|7-J-||JF-7|F--J|L7|FJLJ|F7F-JLJL7LJL--J|LJL-JJLJF----J||||F-JFJL-7-||7JLF|JL +L7JFJF|F-J|F7F7F7LJL7|LJL7L-JF--------7L-7F--JL7F7F-7F-JF--777L-JL|LJ-7L.LFJF--JFJLJF-7|||L----7||F7F--JF-------JF----J||||F7|F--J7||J-FFLJ. +LJ-|FF7L-7||LJ|||F--JL7F7L7F7|F-----7FJF-JL--7-LJLJ|LJF7L7FJ77.|JL77.L7.FLL-JF--JF-7L7|LJL--7F7|L-JLJF--JF-------JJF7F7|LJLJ|||.F7F|L-7|LL-7 +-|F-7||F7||L-7||LJF---J|L7||LJL----7||FL-7F--JF--7|F-7|L7|L7F7F-7.J7LJL-J7|JFJF-7|FJFJL---7FJ||L-7F7FJF--JF7F7F7F7FJ||||F-7FJ||FJL7|F-JJJ|F| +|LL7||LJ|||7FJLJF7|F-7FL7|LJF------J||F77|L---JF7L-JFJ|FJ|FJ|LJFJ7L7J-L7-FL7L-JJLJL-JF7F77||FJL--J|LJ.L---JLJLJ|||L7|||||LLJF|||F-J||J|.FJFL +F.||LJF7||L7L--7|LJL7|F-JL--JF--7F-7LJ|L7|F7F7FJ|F-7L7|L-JL-JF-JJ-F----|7|JL.|7FF----JLJL-JLJF7F7FJF--7F7F7F---J|L-JLJLJL----JLJL-7|L-7F7-J. +F-FJF-J||L7L7F7LJFF7||L--7F-7L7FJ|FJF7|FJLJLJLJ-LJJL7LJF7F7F7L-7-7FJ7|FJ-LJFJL-JL7F7F-7F7F7F7||||||L-7LJLJ|L---7|F----7F7F7F7F-7F7LJF-J|L7.7 +|.L-JF-JL7L7|||F7FJLJ|F7FJ|LL-JL-JL-JLJL-------7F--7L7FJLJ||L--J-7|-F7JJL|---7J7FLJLJ|LJLJLJ||||||F--JF7F7L----J|L---7||||LJ|L7||L7FJF-JFJ.| +FF-F7L--7L7|LJ|||L--7|||L-JF7F--7F---------7F--J|F-JFJ|F7-LJF|.||.|F|JL7.F.|F7.LFF--7F------J|||LJL---JLJL---7F-JF7F-JLJ|L7FJFJLJJ|L-JF-J|FF +LF-J|FF7L7|L-7||||F-JLJL--7|||F7|L---7F---7LJF--JL-7L7LJ|-|||.L-F7|FJFFJFF-77L77FJF-JL-7F7F-7|||F-----7F7F7F7LJF-JLJF--7|FJL7L-7F7|F-7L----7 +LL-7|FJL7|L--JLJL-JF7F---7|||LJ||F7F7LJF--JF-JF7F--J.L--J7JLL||F||JJFFF7-L7||F|-L7|7F77LJ||FJ|LJL----7LJLJLJL-7L----JF-JLJ|FJF-J|LJL7|F--7FJ +F--J|L-7LJF--7F---7|||F--JLJL7FJ||LJL--JF--JF-J|L---7FF7F77|FF--J|..F7||7FJL7F7F7|L7||F7JLJL-JFF7F--7L-------7L-7F---J-F7F7L-JF7L7F7||L7JLJJ +L--7L--JF7|FFJL7F-J|LJL-----7|L7LJF7F---JF--JF7L----JFJ|||7F7L--7L-7||||FJF-J|||LJFJ|LJL7|F7F--J||F7L-----7F7L-7|L7F---JLJ|F7FJ|FJ|||L7L--7J +LF-JF7F7|||FJF7|L7FJF-------JL-JF7|LJF---JF7.|L-7F7F-JFJ||FJL7F7L-7||LJ|L7|JJ||L-7L7L--7L-JLJF-7LJ|L7F-7F7LJL-7||FJL-7F---J|LJFJL7||L7|F--J7 +FJF7|LJ||||L7|LJ|||-L7F7F7F7F7F-JLJF7L----JL-JF7LJLJF-J-||L-7|||F7||L7FJFJL7FJL7||FJF--JF-7F7L7L7FJ|LJLLJ|F--7LJLJF7FJL7F7J|F-JL|LJL-JLJ-|J| +L7||L7L||LJ|LJFF-J|F-J|LJ||||||F---JL------7F-J|F---JF-7|||||||||||L-J|FJF-J|F-JFJL7L--7|J||L-JL|L7F-7F--JL7FJF7F7|LJF7||L-J|F--7JF-7-L-7JL| +LLJL-JJLJJ-F---JF-JL7FJF-J|||LJL-7F--77F7F7|L-7|L-7F7L7|||F7|||LJ|L-7FJ|FJF7||-FJF7L--7||FJL77F7L-JL7|L----JL7|||||F-JLJ|F-7||F-JF|FJ..FL-J| +F|.LL7.LL--L7F7FJF7.LJLL--JLJ7F--J|F-JFJLJ||F7|L--J||FJLJ|||||L-7L7J|L-JL7|LJL7L7||F--JLJL7FJFJL-7F7|L--7F-7FJ|LJLJL----JL7LJ||JF-JL-7-7.LF7 +FJ.|---JFJF|LJ||FJ|F--7F-7F7F7L---JL--JF--JLJLJF7F-JLJF7FJ||||F-JFJF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JJ7-7L--J|.|F--JFF-J|-L7.LL--JFLLJ|L-.F-|F--J||FJ.LJ-J.FLLJ-||LL7||LJ|||FJFJF-JFJ|L7FJ|F7L|F7J.FJ...|7F-|7|-7.--7.-.LF +LLF--JLJ--FJJ7.|JF77J|L-|.||LF--7|7F|F-JJJ|-|J|FLFJ-LJJFJ7F7L--L--7|||J.F|-FJ-7LL7|L-FJ|L7FJ||L7L7L-7L7L7|L7LJL7L-J-777.F.LFFLF-|7||.F-.|.F. +..LJ--7JF|.LL-FJ7J|LF-JF7-FF-L-7LL7FF-||JJL7-.L|FJLF.F|-FFFF-|JF||LJ||FJ-|-|J7|J|-LJLL-J|||-LJFJFJLFJFJ.||FJF7FJ7.F.LL-7F7.FJ-|J.7F77L.|JFJ7 +LL---J|LFJ-.|-|F7--JLJF|.|FJ.|FL-7F7.F---7||...L|L77-777|FJ|7-F--7|FLJ7.F|LJ.|.-JJ..||7LLLJ7.FJFJFFJFJ|.LJL7|LJJF-J77.LFJL--7F|-LJFJF.FL7.LJ +LJLJ7.-77..L77JL---L7FFJ|-||7|JJF|JJ7.|7LFF-.F--JF|JF7.FLJ-J|7|FLJJ77.L-|--F-LL--77F|-L7J.LJFL7L7FJFJL7.LL.LJFL-J7-L7F|L|JJ|LLFFJF-.L7JLF--| +F-7JFFJLJF|JLL..|JF7LJJ-F7FL-J--FJ|FF-J|FLJJ.-L7-L7-7.-JFLF|-F|JL|JF--|JLJL|7JJF|JLF-7LF7FFFJFL-JL-JJ..|.|F|.7F-FF77F7LF7|.|...F7|F--J77L--J +|.L-7J-L7-JLLL--L-FL--LJ.LLJLJ-L|-7JJLL--J-L-J.JJ.L-J-J.LJ|JJJJ7.J-FJLL-L-.J---FJ..|.|.L|7.|.LLJ.|JJ.FF--L-L7JL-F7-FJ|-7J|7L7-|LJ.LJ-LJ7--J- \ No newline at end of file diff --git a/2023/day-10/part1.lua b/2023/day-10/part1.lua new file mode 100644 index 0000000..7acdeec --- /dev/null +++ b/2023/day-10/part1.lua @@ -0,0 +1,112 @@ +require("lib") + +local input = GetInput() + +--[[ +| is a vertical pipe connecting north and south. +- is a horizontal pipe connecting east and west. +L is a 90-degree bend connecting north and east. +J is a 90-degree bend connecting north and west. +7 is a 90-degree bend connecting south and west. +F is a 90-degree bend connecting south and east. +. is ground; there is no pipe in this tile. +S is the starting position of the animal; there is a pipe on this tile, but your sketch doesn't show what shape the pipe has. +]]-- + +-- Find starting position +-- Find the two starting pipes accordingly from starting position +-- Loop twice from starting position until both loops are at the same coordinate +-- Count the steps + +local pipeSymbols = { + ["north"] = {"|", "L", "J"}, + ["east"] = {"-", "L", "F"}, + ["south"] = {"|", "7", "F"}, + ["west"] = {"-", "J", "7"} +} + +local function findStartPipes(x, y) + local maxRight = math.min(x+1, #input[y]) + local maxLeft = math.max(x-1, 1) + + local north = input[math.max(y-1, 1)]:sub(x, x) + local south = input[math.min(y+1, #input)]:sub(x, x) + local east = input[y]:sub(maxRight, maxRight) + local west = input[y]:sub(maxLeft, maxLeft) + + local t = {} + if north and table.contains(pipeSymbols.south, north) then + t[#t+1] = {currentPos = {x = x, y = y-1}, lastPos = {x = x, y = y}} + end + if east and table.contains(pipeSymbols.west, east) then + t[#t+1] = {currentPos = {x = x+1, y = y}, lastPos = {x = x, y = y}} + end + if south and table.contains(pipeSymbols.north, south) then + t[#t+1] = {currentPos = {x = x, y = y+1}, lastPos = {x = x, y = y}} + end + if west and table.contains(pipeSymbols.east, west) then + t[#t+1] = {currentPos = {x = x-1, y = y}, lastPos = {x = x, y = y}} + end + return t +end + +local function checkDirection(path, symbol, dir, x, y) + local oppositeDir = {["north"] = "south", ["south"] = "north", ["east"] = "west", ["west"] = "east"} + local currentSymbol = input[path.currentPos.y]:sub(path.currentPos.x, path.currentPos.x) + local newX, newY = path.currentPos.x + x, path.currentPos.y + y + if (x ~= 0 and path.lastPos.x ~= newX) or (y ~= 0 and path.lastPos.y ~= newY) then + if table.contains(pipeSymbols[dir], currentSymbol) then + if symbol and table.contains(pipeSymbols[oppositeDir[dir]], symbol) then + return {currentPos = {x = newX, y = newY}, lastPos = {x = path.currentPos.x, y = path.currentPos.y}} + end + end + end + return nil +end + +local function runPipes(path) + local x, y = path.currentPos.x, path.currentPos.y + + local maxRight = math.min(x+1, #input[y]) + local maxLeft = math.max(x-1, 1) + + local north = input[math.max(y-1, 1)]:sub(x, x) + local south = input[math.min(y+1, #input)]:sub(x, x) + local east = input[y]:sub(maxRight, maxRight) + local west = input[y]:sub(maxLeft, maxLeft) + + return checkDirection(path, north, "north", 0, -1) or + checkDirection(path, east, "east", 1, 0) or + checkDirection(path, south, "south", 0, 1) or + checkDirection(path, west, "west", -1, 0) +end + +local function pipesTouching(pathsTable) + if pathsTable[1].currentPos.x == pathsTable[2].currentPos.x and + pathsTable[1].currentPos.y == pathsTable[2].currentPos.y then + return true + end + return false +end + +local function pipes() + local sum = 1 -- Start at 1 because finding start pipes doesn't include a +1 + local paths + + for row, str in ipairs(input) do + local start = str:find("S") + if start then + paths = findStartPipes(start, row) + end + end + + while not pipesTouching(paths) do + sum = sum + 1 + for i = 1, #paths do + paths[i] = runPipes(paths[i]) + end + end + return sum +end + +print("How many steps along the loop does it take to get from the starting position to the point farthest from the starting position?\nAnswer: " .. pipes()) diff --git a/2023/day-10/part2.lua b/2023/day-10/part2.lua new file mode 100644 index 0000000..e69de29 diff --git a/2023/day-12/demo-input.txt b/2023/day-12/demo-input.txt new file mode 100644 index 0000000..c5bec3a --- /dev/null +++ b/2023/day-12/demo-input.txt @@ -0,0 +1,6 @@ +???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1 \ No newline at end of file diff --git a/2023/day-12/input.txt b/2023/day-12/input.txt new file mode 100644 index 0000000..183c0ed --- /dev/null +++ b/2023/day-12/input.txt @@ -0,0 +1,1000 @@ +??#.?#?#??? 1,3,1 +?????.??.???. 1,1,1 +??????.??..? 2,1,2 +.??#???.??? 3,1,1 +??##?#?????.. 5,1 +?#?#?????. 1,1,2 +#??????????. 1,1,7 +??.??#.??#?? 1,3,2,1 +.?#....??? 2,1 +#?.?#..?#???? 1,2,1,1 +?#?.?#???? 2,4 +??.?.#?????? 2,1,1,2 +#??#????.?##??#????. 1,4,1,3,1,3 +?##?????????? 2,2,2 +??#??.#??#???? 5,4,2 +????????.? 1,3,1 +?####..?.?##??#?? 5,6 +#?.???#???.???. 1,1,4,1,1 +?#?..????#?##??? 1,4,5 +?#??.##???? 1,4 +.??#?.???. 1,2,2 +..#?#?.???.??#? 3,2,2 +.??#?????.?##??## 3,1,3,3 +#???#?????#?#?? 2,2,1,1,1 +##??.??#??.#?.?? 3,4,1,1 +???????.#?? 2,2 +??.?#?????? 1,3,1 +?????#???.?#?????#? 8,3,1,2 +#?.#??#?#??#?.???#?? 1,6,3,1,2 +..???.???#????.? 1,1,3,1,1 +??#?#???#??????#?##? 7,4,5 +??.???#???#.## 1,4,2,2 +???##..?.? 3,1,1 +?.##????#?.?# 1,4,1,1 +?#???????? 1,1,3 +??.??#?????#???? 3,5 +?#???????#?.? 4,1,1 +?#???????..?.?. 8,1 +.???????????.#?#?? 8,4 +??#?????#????? 5,7 +.??.??#????.???. 2,1,2,3 +..#????.##..?? 5,2 +?###.?.????..#???# 4,1,1,1,5 +??#?#?#??????? 3,2,1,2 +????#.?#?? 1,3 +.#?..#.?????. 2,1,4 +.?#?#?.?#?? 4,2 +???##??.??#???????. 7,7,1 +???###???#???.#. 5,4,1 +???????#??#???#? 1,11 +?.???.?#?#?#??#? 1,1,1,1,4 +#.???.##?????? 1,1,5 +?.??#??#?# 6,1 +?..??????#???.?##? 3,5,2 +?.?#.?#?#? 2,3 +..?.?????. 1,1,3 +?#??????##?##.?#???? 3,8,4 +?.#?????#.?#...?.# 1,1,4,1,1,1 +?????#?..#???? 1,1,2 +.??#.##???.? 2,2,1 +.#?##???..???? 7,1,1 +?????????. 4,1 +.?#?#.????? 1,1,2 +?.?#.?#??.??.. 1,1,3,1 +.???.#?#???#.?? 3,1,5,2 +??#??.??????. 3,1,2 +?#?##??.??. 4,2 +.?.???##???.? 1,7 +??????####????? 1,6,1 +??#.?#????#????. 2,8 +?#?#?#?.#?.???#????? 6,1,9 +#??##.##???????????. 5,6,4 +????.????.?? 1,1,1,1 +.?#?.?.???? 2,4 +?.#??###???? 7,1 +#????#??.?#?????? 1,4,1,1,1 +?#?????.??? 4,2,1 +#.??????????# 1,2,6 +?#???.??????.??#? 4,1,1,3 +?????..#?#? 2,3 +..???#.?#????? 4,2,2 +?.???.??#?#?## 1,1,1,6 +.?###?#.?#??.??#??? 5,2,2 +##??????????#??????? 2,6,6,2 +.????#?#??#?#.???# 7,1,1,4 +.?#??..#?.???????? 3,2,5,1 +??????#???#??? 1,8 +????#?????..?#?. 7,1 +??#?.?..#?.?# 2,1,1,1 +#?#??????? 1,1,1 +?.?#?#?.?. 1,1,1 +.???#????#??. 6,2 +?????.?#???# 1,3,1 +????#?.??#??. 1,1,4 +?#??##???? 6,1 +?.#?##???#? 4,2 +?????#???????. 5,5 +????.#????..?? 1,1,5,1 +..???????#? 1,2,2 +.#?.?#?.?..#.?? 1,2,1,1,2 +.##???.?.?????? 3,1,1,5 +??.?#?#??????.????? 7,1 +.??.??#???.. 1,5 +?#??????.##.?????? 3,1,2,2,1 +?????????#???.? 1,1,3 +?????.?????????#??#? 4,6,5 +.#?.#?.?##?# 2,2,5 +.?????????#?#?#??? 1,1,6 +.?#.??????#.???? 2,6,2 +????.????.?#??#??# 1,1,2,6,1 +.##?###.???#?. 6,3 +??#????#????? 8,1 +?.?#????#?#?????? 1,6,2,3 +.???#?.???.??# 5,1,1,1 +??????.#?????.#.? 1,1,3,2,1 +?????.?..??? 4,1,1 +?#???##???.#. 3,2,1 +?.???????.??##.#???. 1,1,4,3,1,1 +????.#?.????#???## 1,1,1,6 +?#.?..#??##.?####?? 1,1,5,6 +.??????###?.???? 10,2 +???#..??.??? 1,2,1,3 +??????#.###??.??.? 2,1,2,4,1,1 +.?.??##??? 1,6 +???#?#.???.#.? 4,1,1,1 +??.?#??????#.?#??#. 6,1,5 +????.#???? 1,2,1 +?.?##??.????????. 3,2,3 +??#?#??##???#? 10,2 +?#??.??.?###?????.? 1,1,2,6,1,1 +????#??#?.# 5,1 +??.??#???#????#?#.? 1,1,1,10,1 +??????..??#?#?#? 2,3,4,1 +????#?.????# 1,4,1,1 +?????##..???#???. 3,3 +?#??#??#??.?????#?. 9,5 +?#?#..##?.#??? 3,3,1,1 +??##???##?.??#.? 3,5,3,1 +#???.#??..?#??.#?? 4,3,2,1,2 +#??#???##?.?# 1,3,3,2 +..##.??.???##?..?? 2,6,1 +?????#??.???.#? 3,3,1,1,2 +?.??...#?????#. 1,7 +???#??#?#???# 9,1 +????.????#???#??? 1,1,11 +.???????.#.????????? 4,1,1,1,3,1 +?#?#????????#. 1,4,4 +?#?????###??#.??# 2,7,1,1,1 +??.??.#?????#?##?? 1,1,10,1 +?????.?????? 3,1,2 +???.?#??###???? 1,3,7 +.??##?##??#????.? 12,1 +?.??##???#...? 4,1,1 +.??.????.???#? 1,2,3 +?????#??#?.?.?? 1,5,1,1 +.?...????????# 1,2,5 +.??.?????. 1,2,1 +.#...?#??.#???##? 1,2,2,3 +??????????.#? 2,5,2 +.????.??#. 1,3 +#?##???#?.? 4,1,1 +????#?#??.# 2,4,1 +??.?#?#???# 3,2 +.#??#??.?#?#??#????? 1,3,10 +?#?.#????####?#??#.? 2,3,10 +???#????#? 4,3 +?#??.?#??# 4,4 +??????#?#?.?.???#??? 7,1,2 +??..#????.??.???.?. 1,5,1,3,1 +##?.#.#????? 2,1,5 +?#####??.??..??? 7,1,1 +.######??.#??? 7,4 +.#?..#.?#??? 2,1,2,1 +.#???????? 2,2 +?????.##???#??.?.. 4,7 +???#.?#??###???? 1,1,1,5 +..?#????.????#?? 1,2,4 +??#?#?????? 6,1 +#?????#????#?#?#..# 1,5,1,3,1,1 +.?#?#?????? 7,1 +..?#??#?.????# 5,1 +...??#?..?#?##? 3,5 +?#??.??????#? 2,7 +??????.???..????.... 2,2 +?##?#?.??##?#?????? 5,6,1 +??????.??? 4,2 +????#..#????#??###?# 3,1,11,1 +??##????????# 6,1,1,1 +#??##??????#? 1,10 +???.#????.???#????? 1,3,6 +????#????? 4,4 +.????##??????#. 9,1 +?.??#?.???#?#.. 1,2,5 +#..????#?#?????? 1,8,1,1 +?##???.?##??.? 6,5 +.???????#??##?.? 1,7 +????.????#?.?? 2,4,1 +#???#??#???#? 1,2,7 +?..#?#..??.??#??##?? 1,3,2,7 +?.##??##????##????#. 13,2 +????????.??? 1,3,1 +???.???##??#?.? 2,7,1 +.???.#.#.??#. 1,1,1,2 +##.?###.#??.?? 2,3,1,1 +?????.???.???#?##??. 1,8 +.???#?#??????##???? 1,1,1,4,5 +???#.??????.# 2,4,1 +??#?#???#???#.?#?#? 10,2,4 +?#?##??..??????##? 4,1,1,1,2 +.?.?????.?????? 1,1 +???.???.???? 3,2,4 +??.????#?##?? 1,5,2,1 +#?#?????#?.? 1,5,1,1 +.???..???.#? 2,1,2 +#?#?????#?? 3,6 +?#??#?????#?##.??#? 1,2,1,5,1,1 +????.??.?#?.?? 2,3 +??.###.?????? 2,3,5 +?.??????#...???? 1,4,1,1,2 +.??#???##?.?????? 3,3,4 +??##????.?.#?# 7,1,1,1 +#?????????.??????? 1,5,1,5,1 +?#???#???????#????? 5,2,1,5 +#?##?????#..# 5,1,1,1 +#?#?#??#?##?.?????. 12,1,3 +.???#??#?. 1,2 +????????..???#.??.?? 2,3 +????.????????##.??. 3,1,8,1 +#?.#.????????# 1,1,4,1 +###?#?????#?#?? 3,3,1,1,1 +???????#?#? 1,4 +??#????#.. 2,1 +..????#???????.?? 2,3 +.???#??##??##?? 8,2 +???#??#??#??###? 7,4 +????????##???? 2,8,1 +?.#??#??.#???#?## 1,6,1,2,2 +.?#?..?.?##? 2,3 +?.#?#??#?# 1,6 +##?.??#??#??#?# 3,6,1,1 +??????#??.? 2,5 +?##?.?????.???#??? 3,1,5 +??..??#?#????? 1,9 +?#.??????.?????. 1,5,5 +??#?#???#??.. 1,6 +?.??##?#???? 1,2,4 +.???.????? 1,2 +?#?????#?.?? 5,1,1 +.????#????? 2,2,1 +#?#???###?????????. 11,3 +???##??#.##????# 1,2,1,7 +#?????..#??#????? 1,4,4,2 +.?.?..?????#?## 1,1,6 +???.?#?#???.??.?? 2,1,4,1,1 +???##???..#??.#??? 5,1,1,1,1,1 +#???.????????? 1,1,3,1 +??.??.?.?? 1,1,2 +?.?#?????????.? 2,3 +??.??.?#?##???? 2,7 +.??????????#??#?. 10,2 +?#..?.#??? 1,1,1 +..?#?????##????#?#? 3,10 +?#?.??.?.#?#??? 3,5 +?????.??#?#??? 4,6 +?#?????##?#.?? 10,1 +??#???##????#?#? 1,8,1,1 +.???????#..??#? 1,1,2,3 +#????.###?..?.??# 2,1,4,1,3 +???.#.????.???#???? 1,1,1,4,1,5 +#?.?#?#??.???##?.#? 1,4,1,3,1 +??.???#??#?#?# 1,11 +?????#?#?#.???. 7,1,1 +??.??#???#???????#?. 8,4 +.????.?????## 3,1,2 +??????.???#.?. 5,1,1,1 +.###????.???#??.??#. 5,5,1 +????#??.?????#????## 1,3,11 +#??????????. 3,3 +????#????#??# 1,7,1 +?#???????#?.##??? 3,1,1,2,2 +??#??..#??? 2,1,1 +???##..??##????#???? 1,2,9 +??#??#..?#????? 4,1,2 +??##?.???#?##??##?? 3,1,4,4 +.#?#??????.? 1,2,4 +?#?##?#????.???.?# 11,1,1 +??????????? 2,1 +??.??????.??#?#????? 1,2,1,5,1,1 +.##?#??#.???? 7,3 +??????#?????##??#. 1,2,4,2,2 +.?.??.??.?.? 1,1,2,1 +?????????? 1,3 +???.???.?? 1,2 +??.??#??????.??# 1,9,1,1 +.???.?.?#??.?.? 1,1,2,1,1 +##.????#?#??? 2,7,1 +.????????? 1,1,1 +???#???.#.??? 1,3,1,1 +????#?#?#??#?.?# 3,1,4,2,1 +????#????#?#?.#. 2,8,1 +????#????????##???.? 2,2,9,1 +??..????????#??....? 4,3 +..?.?####.?.#?#. 1,4,3 +??.????.??? 4,1 +?????.??#.? 3,2,1 +??#????????#.? 5,4 +???#?#????.??#??? 9,2 +????..?????# 1,1,4,1 +?????#..??????#?? 3,6 +??.????#???.#?????. 1,6,3,1 +??.#.???#?#?#???? 1,1,8,2 +#..??#?#?#? 1,6 +.?.#?#????#?.#.#?? 1,1,6,1,1,1 +#???????.??#??.?## 5,1,5,2 +???.#??.####?#?#?. 1,1,9 +????..????#????#??? 2,10 +.??.??.??#? 1,1,1 +#.?#??#??.#? 1,2,1,1 +??.??.??????#???#?. 2,9 +.?.?.#??...??.?.?... 3,1 +???#????###?.???.??? 1,9,1,1 +???#??????#???.???#? 1,10,1,1,2 +.?.?????#?????.???? 1,6,1,2,1 +??#??????#.?.??. 4,1,1,2 +?????#???..??#?? 6,4 +?.####?..??.? 5,2 +??.???#?..#?#????# 1,1,1,6,1 +??.??##????????? 8,1 +.??#?#?????????????? 1,1,1,1,1,9 +??#?##??#?#?# 5,1,1,1 +.?#???#.????#???. 6,1,2,1 +?.?..?????##??? 1,1,1,4 +??#???#??. 2,3 +?#??????????#?? 1,2,1,3,1 +.????????#??#??.?. 3,7,1 +??.#??.???# 1,3,4 +?#.##???##??#??.?? 1,3,3,1,2 +?#?.?.#??. 1,2 +?#???##?#???#??? 1,13 +???????#?#?????#??. 1,10 +.????#.?..???# 4,4 +.???##.###.?#.?? 1,2,3,2,2 +?.?##????? 1,3,1 +#?#?##???###..??#??? 6,5,5 +?#?#???#??#??.# 10,1 +#??????#??##? 1,1,1,5 +####???###.?.????# 6,3,1,2 +.#??.?#??? 3,3,1 +??#???#.????..?#??? 7,1,1,1,1 +?..?????????..#.???? 4,1 +??##???.##? 4,1,2 +?.?????#???##?.?#??? 1,1,1,8,1,1 +?.?#?????##?##??#? 2,8 +?#?.?#??.? 1,1,1 +??.????..#.?????.? 1,1,1,1,5,1 +?##??#??????. 5,1,1 +.?.????##? 1,2 +???##?#.#??????? 5,8 +#?????..?#??#????# 4,1,1,1,2 +#??.??#?.#?. 1,1,2,1 +?.?#?#?#???????.??.? 5,3 +???#??#????#?? 2,7 +????#?????#???.???# 1,9,1,1 +#?.??.???..?#.?? 2,1,2,1,2 +.###?.???.?? 4,2,1 +???#?.#.?##.???#? 1,2,1,2,5 +#?????????#?#????? 1,1,1,8,2 +???????#?#??.?????? 1,10,1 +??#.???#??#. 3,4,2 +?#??##.?#.#?## 6,1,4 +????###?#??? 1,3,2,1 +..??????#? 2,2 +.??#??##???? 1,2,4 +.?????##?#???.? 2,4,4 +?##?#??#?.??# 4,1,1,1 +.#?#???##??#?.#?##?? 8,1,5 +??#.#.#??#?#.?##?# 1,1,1,1,1,5 +.#??#?.??##??#???? 1,1,9,1 +#??.???#?? 2,2 +???????.#.?# 1,1,1,2 +???????.?#???# 1,4,2,2 +????#??#??#?.# 1,4,1,1 +?#.???#??#????.? 1,9 +???##?????#?#??#. 5,6 +??#???##???#?#???. 2,12 +?#?.??.???? 3,1,3 +?#??.?.??????.. 1,1,1,1,2 +#??#?.????.. 1,1,4 +?#?#?.???????????. 2,1,1,1,1,2 +?.?????????##???#? 1,5,2,2 +###??.?.???.#?? 4,1,2 +???#?????#???#.# 1,1,9,1 +??.#??..?..??? 1,2,1 +.?#?.?.?????...?? 2,2 +????..???#?#??? 1,7 +?????#???.????? 1,5,1,1 +?????????????? 2,5 +???#??.??. 4,1,1 +#??????.#???????# 2,1,6,1 +?.#???.?.? 1,1,1 +.?????#????.? 3,5 +???.?????#.??#????? 6,3 +??#?###????.?.#??.# 7,2,1,1,1 +#???##?.??.???????? 6,1,1,1,1,1 +??.?.???#?.?.??#. 5,2 +#..?#???#?#???? 1,2,7 +.???#?#?#????? 9,1 +???.???#?#?#.??#? 2,2,5,3 +????????????? 1,1,1,2 +#?????.??????### 4,2,5 +.#????#????#?? 3,1,1,2 +???????#.#????????? 2,1,1,2,4,1 +?##.??#??. 2,3 +?????????#???.?#??? 2,1,1,5,5 +????????.#?#?#.. 7,5 +?.?.??#?????.? 1,6 +?#.?#?#?.???? 1,3,1,2 +..#??....??#?????? 2,9 +.?.?#?#?????? 6,1 +??#?#.???? 3,1 +?#??#?????? 5,1 +#.????#???.#.??.?? 1,3,1,1,1,1 +.?###????.???? 3,1,1,2 +?#???#?.##?#???? 1,2,6,1 +#??#??????#..??#? 1,1,5,2 +..?#?.???? 2,3 +#????..?.?..????. 5,1,4 +.?.???????#.#????? 1,1,1,1,6 +.??.??.????? 1,2,1,1 +#???.??????# 3,1,1,1 +.#???#?#?# 1,4,1 +???##?#?#?###????? 11,1 +?.?#?#???#??.#. 8,1 +???#?????..#?#??? 8,5 +??...??#?#?##?????#? 1,15 +..?????#???#?? 7,2 +??????????#?#? 1,5,2,1 +????#?#?.??..#??.? 5,2 +.??##??#?.#? 4,1,1 +??????????#?? 1,10 +?#??#????????. 5,3,1 +??.???????.???##??. 1,1,1,2,6 +???###.#?? 1,3,1 +.?..#..??#.???? 1,1,1,1,3 +#????????#?.?#?##.. 2,1,2,4 +??.?.????????. 1,7 +??#?#?????#?#? 5,3 +??#???#?#??.?????.? 9,3 +#??.?????#??????# 2,2,2,4 +.#??.????? 1,1,1 +..##???.?? 2,1,1 +???.??.?????? 2,2,3,1 +?????##..??.?? 1,4,1 +?..?#??.?#?#???????? 4,8,2 +????????.?# 4,2 +#.????#?#? 1,5 +??#????#????###???? 2,1,9 +??##?????.?????. 4,1 +?#?##?#..????.???.? 6,1 +?#?.#????#???.#? 3,1,3,1,1 +#?#??????? 3,5 +#????#?#?? 2,4 +.?#??#?????##???? 5,7 +????.??#??..??? 4,1 +.##..?..??#??##??. 2,9 +..???#??.## 5,2 +??.??##?????????.?#? 12,3 +.?.?#?..???##? 2,5 +?#??.?#.?. 3,1 +?????#?#???.???.? 1,7,1,1 +???.#...#? 1,1,2 +??????#???#??. 1,3,3 +??#?.??#?##?.? 2,4 +?.#???????#? 1,1,4,2 +???#??????. 4,1 +???#????..#.?? 4,1 +#?...???..?#? 2,1,1,2 +??##???#??#?????# 2,7,3 +???.??????...? 2,2 +?#???????#?. 5,1 +?.?#?#.?.# 4,1 +????##?#???????.?.?# 9,1,1,1,1 +?#????#??#.?? 2,1,1,2 +????#??.??????#??.. 2,7 +###?.?#??? 4,1,1 +?.?##?#..?.???#.? 4,4 +.?#?##???#???.# 1,3,5,1 +.?#.#?##????. 2,8 +????###?#?? 1,1,5 +????..?#???#???. 3,9 +#?####?#..? 1,6,1 +???.???.?#????.? 3,3 +????.????#?..?? 1,3 +.#???.#.??#???? 4,1,2,1 +?.?#???????????. 1,1,8,1 +.??.????#?????? 1,1,3,2 +?.???.##??####? 1,8 +??##?????#??????#? 5,9,1 +##????????.??? 5,2,1 +#????.??#??#?.???#?# 4,6,4,1 +##?##.??.#??#?#??# 5,1,4,1,1 +????#??##?? 1,1,5 +?..#?#??#.???? 1,6,1 +?#???.??.?####???.?. 4,1,8,1 +.???#????#????#? 6,6 +.#??#???#?.? 1,6 +??#???..#? 1,1 +.????###?.? 1,6 +??.?#????.?? 1,2,2,1 +.??????##?#. 1,1,4 +.??#??.???????.??? 3,6 +?.???.???###? 1,1,1,4 +?#????.#???.? 2,1,1,1 +??#?????#??. 1,1,1,1 +????????...?.?##?. 6,1,3 +?.?.???#.?. 1,1 +.??#.?#?#?.??##? 1,1,4,3 +#???.#.????? 1,1,1,4 +??.#?#????? 3,2 +?.??#????? 1,7 +?????#?###?#??. 1,5,3 +????#?##?#????.??.# 8,5,1,1 +?.??#?.??#.? 3,2 +.###????#?????? 3,7,1 +???###??##?????#?? 8,3 +#.?#??#??#?.?##?#?#? 1,1,2,2,8 +#????????????#? 3,1,3,1 +..?????##.?#???#? 2,4,1,2 +??..??????.# 1,1,2,1 +#???#?#?.#?????## 1,5,1,6 +?????##??#??? 1,5,2,1 +?#?#??#????????.? 3,4,3,1 +??.?##?#??#??? 1,5,1,1 +?.????####.? 1,5 +.#..????#?##??.?#..? 1,2,6,2,1 +.#???..#?.?#?????. 4,1,6 +?##?#??#?#?#????.? 6,1,3,1,1 +.?##???####?????#??# 11,1,1,2 +.#.??.##????? 1,2,1,1 +.#??.?.###?.? 3,4 +?.????..?#..#??? 1,2,2,1,2 +????#?????#.????.?.# 6,1,1,1,1,1 +??????..??#??#???? 1,3,4,1,1 +?.???????. 1,1,1 +???..??.?##??#??.?. 3,1,7,1 +???.??..?? 1,1,1 +?#.??##?.. 2,4 +#...??.????? 1,1,1,1 +??.??#?##??.?? 1,6 +?#?..???#####?.? 2,7 +???#??#??.?#?..?###? 7,2,5 +#?#???????.???? 7,1,1,1 +.#???#??#??? 1,2,2,1 +??#???#?????.?#?? 1,1,5,2 +?????.?.?#??#?? 3,1,5 +.#?.???????? 1,3 +?????#??##?#??.#? 1,4,6,1 +??????#?#??#?.??#??? 6,4,4 +.??.??#??.??#??? 1,2,4 +??????.?#?.????. 1,1,1,1,3 +?#??????#. 5,1 +?#???#?#.#??#.?#?? 7,2,1,1 +##??????#????#? 3,5,1 +#.#???#??#??.? 1,1,7,1 +???..??#?????.? 1,3,3 +??#????.???#???.?# 4,5,1,1 +?#??.?#.?? 4,1,1 +.????#???#? 5,3 +.??????#?#??# 1,1,2,4 +?.???#??????...? 1,1,1,4,1 +.?#..?.???? 1,1 +.#?#?????????????? 3,2,1,1,2 +?????#????#?#??.?.?? 10,1 +.?.??????? 1,3 +##?????#..?#??.?? 8,3 +?.?#??#????????#? 1,4,4,3 +?#??.???.?#????#? 3,1,3,1 +##???#?#####?????.? 4,9,1,1 +???.??#??#?.?. 1,2,2,1 +?#?#?.????#???? 4,2,3 +????????#????.? 5,4 +.?#??#????#??#. 6,1,1 +????#???#??.??#? 4,2,2 +..???????# 4,1 +??????#??#??.???? 11,1 +?##.??#.??????? 2,1,2 +.?.??????..?.?????. 5,1 +.??#??.#??????#????? 1,1,1,1,1,8 +?#?.???.#?? 3,2,3 +??.?##????? 3,2 +?..#?###??.??? 7,2 +?.?#?.#??? 1,1,3 +??#..???#??.?. 1,5 +??#??#??.##?#??##.? 7,8 +..?.??.?##. 1,3 +???#?##???#??. 1,11 +?.???.??##??#. 1,1,5 +??#?#??#??????? 1,1,7,1 +???#?.???..#.???. 1,2,3,1,2 +.##?.?#???????.?? 2,8,1 +??.?????#?. 2,2 +#????#??.??#??#?#..# 1,5,3,3,1 +???#?.?.?????????## 1,2,1,3,1,2 +#??????#??.? 3,2,1,1 +#??#..??#????.? 1,1,4,1 +??.?##?#?#..??# 1,2,1,1,2 +?????.??#?#?#??##.? 2,11 +.?????..?. 1,1,1 +?.#???.???#????#? 1,1,1,2,4 +????.?.?#. 1,2 +????#?##????#? 9,1 +?...?????...??#????? 2,3 +?#??..##.? 3,2 +?####????????.???? 4,4,2 +?????????????? 4,3,1,1 +????###?#..??.#? 2,4,1,1,1 +??????##?#?? 3,2,3 +?.#???.##????? 2,1,2,1 +??#?????#???? 2,1,3,1 +??.?#???##??#. 1,1,7 +??????????#?????? 3,2,3 +?????#??.#??? 5,1 +#.???????##?.??#?. 1,8,2 +??##????.#?# 4,2,1,1 +#?.??????.????##? 1,4,3,2 +?#..??..#.?? 1,1,1,1 +?????..?#???????#? 3,10 +#?##???????#????. 5,1,2,1,1 +?#??#??????#?? 2,4,3 +????..????????.#???# 3,1,3,1,2,1 +.???#??.??? 1,3,2 +?.#?..#???.?#?? 1,1,1,1,3 +.?????????#?.###?.. 9,3 +???????#?? 2,1,2 +##.?????.?... 2,1,1,1 +.????.????? 4,3 +??.?#?.?.#? 1,2,1 +.??.?????..?.?# 4,1 +.##.???###??????#?? 2,4,3,3 +#.?##???.#?#???????. 1,3,1,3,3 +??#???????##. 3,5 +?.??.?#??.?? 2,1,2 +??#??###?#?.#?. 8,1 +????#???#?.##.?? 9,2 +#?#????????.. 4,1,1,1 +?..?.?.#????# 1,2 +?.???#?????.#?? 4,1,3 +??.?????.??.???.?.? 2,2 +?????.?.#. 3,1,1 +???.????.?##??##???? 2,3,5 +#??#??.#.?#? 5,1,1 +..?#??#???..#? 8,2 +?.??.??.?.#??.## 2,2,1,1,2 +??????#?#.???#..#? 1,1,3,1,1,1 +?#???????#?? 1,5 +??#?#??#??#?#?????? 12,1,1 +????????#???. 1,1 +.?.???#??#? 1,5 +???#??#?.???? 7,1,1 +??.#??#?????##?? 1,1,3,1,2 +??????????? 1,3,3 +?#?.???#?????? 2,1,3,1 +?????#????#??????? 5,1,1,1,1,1 +?#?#????.???#..?. 4,1,4,1 +????#?#???##??#?.#?? 1,4,6,1 +?#?#?#?##???????. 12,1 +??.????##???.? 1,1,4,1 +#??##.#?.#??##?. 1,3,1,5 +.##.???..#??#?? 2,3,4 +???.??????##?? 1,8 +????##???#??..???? 7,4 +???????.#?. 3,1,2 +???#?.##?? 5,2 +?.??#?.?????? 1,4,1,1 +?.#??.?.?#?#?. 2,4 +.?..#????# 1,1,1 +.#??#???????##??.? 5,1,1,3,1 +??????#??? 2,4 +??#??????.??##????? 3,4,1,5 +.??.?#????#..? 2,3 +..?.?????##?#????#?? 1,14 +???????##??#? 5,2 +????.?#??????????? 2,1,7,1,1 +#????##???? 1,6 +?#?.??.??.? 1,2,2 +????????#. 1,5 +.#?#???.#?????.? 6,6 +????????#?. 1,2 +#??#??##??##?. 8,4 +???##?????...???? 2,2,4 +?#.??.##??????. 1,2,4,1,1 +#??#..##?...?? 1,2,2,2 +.#??????????. 3,1,1,1 +.???.?###?..?#????? 4,2 +???.??.?##.#? 1,2,2 +#.???????? 1,5 +.??????????.????.?? 3,3 +.??????????????.?. 5,5,1 +?#???#?#????#??? 2,4,1,1 +#?##??.?#? 6,1 +??????.?#? 3,2 +??#???????????#.#?.? 1,1,1,6,1,1 +?.#.??????.??.? 1,1,6,1,1 +?.#?#?#.?.?###?? 5,1,6 +.??#?##?#???.?.#.?? 10,1 +??.??###????#. 1,1,6,1 +??..???.#?.?? 1,1 +??..?..?????.?? 1,2 +???.??#?#??#??? 1,1,4,2 +????#??????..????? 7,1,2,1 +?#?#???#.?.?.?#??#. 3,1,1,1,2,1 +??????..#?.? 3,1 +????.???#??###? 2,1,7 +.?.#??###?#?#???#? 1,1,13 +??.??#?#????.#???? 3,2 +????#??#.???#. 1,4,2 +#????.??.?#???..? 5,1,4 +?#??.???#?????#? 3,1,9 +??##??#?????#??. 7,1,1 +????????#????.#??? 3,8,1,1 +???##????#???? 5,5 +??????.???.? 2,1,1 +?????#?#????????#??? 1,6,4,1 +??????##??? 3,3,1 +.#???????. 2,3 +????#????????#.#?? 2,4,2,2 +#..##?????.????.? 1,6,1,1 +???????.???#??..#?? 3,6,2 +??#????#??#.? 2,2,1 +?.?????#?# 1,5 +???##..?.?#.??? 1,2,1,1,1 +??#.?.?#?? 2,1,3 +.??#.?.?????????. 3,1,1,4 +?#???#???.#?? 1,2,1,1 +?.?.?#.??.?.###???? 1,1,1,1,1,6 +??#..#??##??.? 1,7,1 +.?.?.?.????##?? 1,1,1,1,5 +?#??#??#???##???? 2,11,1 +.???????.##?? 1,2,4 +?##???????? 2,4,1 +.#?#?????#?.?? 4,3,1 +?#???#?..##?#?#?.?.? 2,4,2,4 +?#???#??.?#????. 3,1,5 +?#???#?###????#.?? 10,3 +##???.#??# 4,1,2 +#??#.?.#??#??#??.? 1,1,1,7,1 +???#??????.??##????# 8,3,3 +???##??#?#????? 8,1 +.#?#??#?#?#.#?????? 8,1,6 +?.???##??###??#.?? 9,1,1 +??.?.???#?.? 1,1,3,1 +#??????#??##.#.?#. 12,1,2 +????#??#??.??? 2,7,2 +???.#?#.?#????## 1,1,1,8 +???.???#?.?.?. 3,1,1,1 +#????#????.??????#? 8,1,4,2 +?##??.?#.?#.??#??? 4,1,1,1,1,1 +????####?? 7,1 +??????#.??.#. 2,2,2,1 +?###?????????. 8,1 +??#.?#????#?.#.??# 2,7,1,1,1 +????.?#???#???. 1,8 +??#?###????#???.?#?? 1,1,8,1,2,1 +???.?#?#.#..???? 1,1,3,1,2 +?.????#?.??? 1,1,1,2 +???#????###?????##?? 4,6,3 +?..?#?#?#???.????? 1,9,1,1 +#?##????#? 4,2 +???????.?.?#??? 1,3,3 +?.??#?????#???#?? 7,1,1,1 +???.??.???#..??#? 1,2,1,1,4 +?#??.?.?#.?. 2,1 +.?#.?????. 2,2 +?????????? 1,2,2 +.????..??#.? 2,1,1,1 +?????????.???? 1,1,3,1 +??#?#??#???..?.??. 10,1,1 +.??#??##???#??##?? 3,3,9 +.???#???????#????? 1,2,3,1,1,1 +??.???.?.????????#?? 3,3,3 +#???????#? 2,3,2 +#??????????.??#?#? 1,1,2,2,5 +?#?????#??.?.??# 4,4,3 +.?#..?.???# 1,1,4 +.#????#?.?# 1,3,1 +???????????####.# 1,1,1,7,1 +####???#????????.?# 5,3,1,2,2 +??????.???#?? 1,1,6 +????##.??#?.. 3,2 +?????##?.?.#??????? 1,6,3,1,1 +?.???#.??.??#?#. 2,5 +?????.?#?. 1,1,2 +???.?????#??.?#?#.? 1,3,4 +?????#?#?????#??#?#? 1,8,1,6 +?.??.???#.???.?..?? 2,4,1,1,2 +???????????##?.??## 1,1,3,5,3 +.?#?.#.?.??.?.???.? 2,1,1,1,3,1 +.?.#.??.??? 1,1,2 +.?????##.. 1,2 +..??#????????#.?#?? 4,1,5,3 +????????.?#??.? 2,2,1,3,1 +???..####?##??? 2,10 +?.?.??#??. 1,3,1 +#???.??.#..? 3,1,1,1 +##.#?#???#####?????? 2,3,10 +?###?##?.?###?#??? 8,6 +?????###?#?.?.??##. 9,1,4 +??.???.##??###????#? 1,1,13 +?.??##.??.?#?.. 3,3 +?.??????##?.??.?.? 1,1,5,1,1,1 +.????#????.??????? 4,1,3,1 +.?????????##????? 1,11,1 +?????#??#?#? 4,1,1 +#.#??#???..??##????? 1,5,1,4,3 +??#..??.??????#?# 1,1,1,9 +???#.??#?? 1,1,1 +.#??.#?????#??. 1,1,7,1 +?##?????##? 3,4 +????????#.???#?.??? 3,1,1,1,2,2 +?.?#?#??#? 1,4 +?????#.??#?#?.???.?# 1,1,1,5,1,2 +??#?###..#??#?? 6,5 +??????????#??#??.#?? 1,6,2,1,1 +???#??????#?. 5,2 +??##????????## 9,2 +?#??????????#? 1,4,5 +??.?##??#?.#.?? 1,4,1,1,1 +???#??##??#?. 3,6 +???.?????..#??#? 2,2,1,2,1 +.??.????.??#? 1,3,1,2 +??.?.????#? 1,1,1 +???????????.....#?#. 11,1,1 +.?.#????#??.??.?##?. 8,3 +?????????????? 4,4 +?.???#??#??????#??? 3,9,1 +????#??.?? 3,1 +?.??#??#??#.?#.? 9,1,1 +??#??#??????. 7,1 +???##?.#?.??.??? 2,3,1,1,1 +??#?#??#?#???.??#. 1,9,3 +????????#.?????? 6,1,6 +???#?????? 2,4 +?????????..?. 2,5 +?##???????.??# 3,2,1,2 +??.?????.?? 2,5,1 +????????.. 1,2 +#??..??.?..??##??# 1,1,1,1,4,1 +????#????.??.??? 5,1 +?#?.??.??. 1,1,1 +???..#?#??#???#? 1,1,1,2,6 +???????##?. 2,1,3 +??.##??????#???? 3,1,2,1,1 +??.??..????? 2,1,1,2 +???????#??.#?.?## 1,5,1,2 +?#?#?##??##?#?? 12,1 +#..?.#?????.???#???? 1,1,1,3,2,2 +???????...??#?#. 3,2,5 +.??#.??#??.?? 3,1,3,1 +?#????#?#? 1,4 +?#?????#?.????#? 2,3,1,1 +####?????????????? 4,1,1,1,1,1 +#??.#???#??.??.. 1,1,2,1,2 +?????..?#??#??? 4,1,3,1 +..???#????.??#?.???. 6,2,1 +#?#???????#??? 3,5 +????#??????#? 1,3,6 +.??.??.?###?#????#.# 1,1,6,2,1 +.#????????? 3,3,1 +.?.#?#??.?????#??#. 1,2,1,1,4 +##.??????.??? 2,1,2,2 +#???#???.?.? 1,1,1 +?.?.#?????#? 2,4 +???.#????.#??. 2,2 +.?????##?????#???? 9,4 +?#?????????#?? 2,1,3,1 +??.#??.?????#???.? 1,2,6,1 +?.#?#?..?#???. 4,2,1 +.?????..?.???.?? 1,2,3 +?#??#???#???.??#??? 1,9,1,1 +??.?????..?? 1,3,1 +?.#??#????#? 1,1,4 +?.?.??.??#?#? 1,5 +???.??.???#?#??#??# 1,1,1,12 +?.##??#.#? 5,1 +??.????#???.. 1,2,1,2 +???#???..#.? 1,1,1,1 +?.???#??.?#?#??##??# 1,5,1,2,3,1 +????##????.?#?#.? 7,4 +#???##.????? 1,4,1,1 +##?.???.???#? 3,1,1 +????.??#?????? 1,1,4,4 +???#?.##?????? 2,2,1 +???#..??#?##??????? 4,9 +?##?..##.???##???# 3,2,7 +??????????##??????.? 1,1,1,5,3,1 +..??#.?.?# 1,1,1 +???#.???#? 4,1,2 +#.??????#?##??#???. 1,3,11 +?.???#???.??#????.?? 1,6,5,2 +#?..?.????? 1,1,2 +?#?????.?????..?# 3,3,1,2 +?????#?????????#.? 8,1,2,1,1 +??.?.#?#???#??# 1,1,10 +????#???.???????#?? 5,1,10 +??##????##?.??# 3,2,2,1,1 +..#?#?.?.???.#?? 4,2,3 +????#??????????. 1,5,3 +?###??..?#?..# 5,3,1 +??#??..????.?? 3,3,1 +?.#.?#??#? 1,1,5 +???????#?????..?? 9,1,1 +.????????##??.? 2,2,3,1 +.????.???.?#??.??? 1,2,1,2,3 +?.??.?.#?????????.?. 6,1,1 +.??.?.???.?#?#. 1,2,3 +?.?????#####??#?.??? 10,1 +??#.?.???# 1,1,1 +??.??????#?? 1,5,3 +????.????#.???.#? 1,1,2,2,2 +#???#.??????# 2,2,5 +###.?##?.??#. 3,4,2 +#??.??#?###??# 2,2,3,1 +.#???#?#?? 1,5 +.????..???###? 2,7 +.##.??##?? 2,3,1 +??#??#?????## 3,5,2 +.?.??#?##???? 6,1 +??##.?#?#?? 2,4 +?.??#?#????.#. 1,1,6,1 +?.???????..?##??? 6,3 +?????.??#???#??? 1,3,8 +.??#????.??????? 3,1,1,1,1 +..???#.????.###???.? 4,1,6 +?????#?..??##????? 2,1,9 +?.?.??????#??#???? 1,3,10 +??????#?#?? 5,1,1 +?.???#?..??.?.??#?? 1,4,1,1,1,3 +?.??###?#?????##.? 1,12 +?#???#??#?????? 4,1,1,1,1 +???#????.?????.??? 1,6,1,2,1 +?##.#?#?#???.?.??#?? 2,8,1,4 +?#??#??.?#?????#?#? 6,2,4 +#??#?????# 1,2,4 +.#?.?#??.??#?.? 1,2,1,4,1 +?..?#?#?..?#?? 3,1 +???..???.??????#?? 3,1,1,2,3 +?##?#?.?#???#??.?? 2,2,8,2 +?????#??.??#??? 1,1 +?##??#?????????##. 3,12 +##.??#??.#?#?.?#.? 2,3,3,2 +????#.?????#?? 1,2,5 +.?.#???#..?# 3,1,1 +????##..??.???? 4,2 +?.?.?##?????? 3,3 +.???.??###???????#. 1,1,12 +??..##????#???#? 1,4,2,1 +????????#? 2,1,3 +?##??????.???.?#?? 3,1,1,2,3 +#.????.#?#?????##??? 1,1,1,5,2,1 +#?#????#???.???#?.?? 8,1,1,3,1 +?.???.#???.. 1,3,2 +...#..????#?#??# 1,1,5,1 +?.#??.?????. 3,1 +#?..#??????#?#?? 2,1,1,4,1 +?#??.?.?????#??.. 2,5 +??????.?.?????##..? 1,1,1,1,7,1 +?.#???#???. 1,3 +????.?#?????.# 2,1,3,1 +???..?.???????#?#?? 3,1,1,1,3,1 +?#????#?## 3,5 +..??????.###? 4,3 +.??.?##???? 1,4 +????.???...??? 3,2,3 +??????#?..? 2,3 +?#.????#.?.??.#?.?? 1,1,2,2,1,2 +?#?##?.?##??...???# 5,3,4 +???.??????. 1,2,1 +#??..???????##? 2,1,1,3 +??#?...????.?.?????# 1,1,2,1,6 +#???#??#?#???###?? 1,5,1,1,5 +??#???##??????.?? 1,2,3,4,2 +???.???#.##? 1,2,2 +???????##.????. 3,3,4 +#???#?.?#?. 3,1,2 +.???????.#????? 3,1,1,3 +???.?.##.. 1,2 +???.#??#??? 1,1,4 +??????.??#.?#???#? 1,1,1,1,1,3 +????#??.??.???? 4,1 +??.#??#?????????#??# 1,5,1,3,1,1 +??????.#??.??? 1,1,1,3 +??.?#???.????#?#??? 1,3,1,4,1 +????????#?#.? 3,4 +?##.??#??##.. 2,7 +????.??.#??##?.#? 1,1,1,5,2 +?.#???##???##????.? 1,4,6 +???#??????#..? 2,1,1,2 +?.??????.????#???? 1,2,3,5 +.????#??.? 1,5 +.?.????#??# 1,1,2 \ No newline at end of file diff --git a/2023/day-12/part1.lua b/2023/day-12/part1.lua new file mode 100644 index 0000000..45f4c38 --- /dev/null +++ b/2023/day-12/part1.lua @@ -0,0 +1,55 @@ +require("lib") + +local input = GetInput("demo") + +-- # has to be filled + +local function countSymbols() + local t = {} + local currentStr = "" + for i = 1, #input[2] do + local s = input[2]:sub(i, i) + if s == " " then break end + + if #currentStr > 0 and currentStr:sub(1, 1) == "." and s ~= "." then + table.insert(t, currentStr) + currentStr = "" + elseif #currentStr > 0 and currentStr:sub(1, 1) ~= "." and s == "." then + table.insert(t, currentStr) + currentStr = "" + end + currentStr = currentStr .. s + end + return t +end + +local function calculatePossibilites(n, s) + for _, num in ipairs(n) do + local currentNumber = num + for k, v in ipairs(s) do + local checkType = v:sub(1, 1) + if checkType ~= "." then + -- do something + print(k, v, num) + end + end + end + -- Pdump(n) + -- Pdump(s) + + if s[1]:sub(1, 1) == "." then + + end +end + +local function springs() + local nums = {} + for num in input[2]:gmatch("(%d+)") do + table.insert(nums, num) + end + local symbols = countSymbols() + calculatePossibilites(nums, symbols) + return 0 +end + +print("What is the sum of those counts?\nAnswer: " .. springs()) \ No newline at end of file diff --git a/2023/day-12/part2.lua b/2023/day-12/part2.lua new file mode 100644 index 0000000..e69de29 diff --git a/2023/day-4/part2.lua b/2023/day-4/part2.lua index fe68dd3..7cb25dc 100644 --- a/2023/day-4/part2.lua +++ b/2023/day-4/part2.lua @@ -1,3 +1,4 @@ +-- Bugged, runs slow sometimes require("lib") local fileContent = ReadFile() @@ -43,4 +44,4 @@ local function scratchcards() return table.sum(totalCards) end -print("How many total scratchcards do you end up with?\nAnswer: " .. scratchcards()) \ No newline at end of file +print("How many total scratchcards do you end up with?\nAnswer: " .. scratchcards()) diff --git a/2023/day-5/demo-input.txt b/2023/day-5/demo-input.txt new file mode 100644 index 0000000..bd902a4 --- /dev/null +++ b/2023/day-5/demo-input.txt @@ -0,0 +1,33 @@ +seeds: 79 14 55 13 + +seed-to-soil map: +50 98 2 +52 50 48 + +soil-to-fertilizer map: +0 15 37 +37 52 2 +39 0 15 + +fertilizer-to-water map: +49 53 8 +0 11 42 +42 0 7 +57 7 4 + +water-to-light map: +88 18 7 +18 25 70 + +light-to-temperature map: +45 77 23 +81 45 19 +68 64 13 + +temperature-to-humidity map: +0 69 1 +1 0 69 + +humidity-to-location map: +60 56 37 +56 93 4 \ No newline at end of file diff --git a/2023/day-5/input.txt b/2023/day-5/input.txt new file mode 100644 index 0000000..ffbe4b2 --- /dev/null +++ b/2023/day-5/input.txt @@ -0,0 +1,236 @@ +seeds: 2880930400 17599561 549922357 200746426 1378552684 43534336 155057073 56546377 824205101 378503603 1678376802 130912435 2685513694 137778160 2492361384 188575752 3139914842 1092214826 2989476473 58874625 + +seed-to-soil map: +341680072 47360832 98093750 +1677587229 1836834678 160297919 +1122651749 4014790961 280176335 +2279929873 2689269992 53644948 +3916120104 1199400457 172302726 +0 381576527 58197295 +1402828084 3450816018 274759145 +3909949227 2540063154 6170877 +802918801 2384227172 155835982 +4088422830 3244271552 206544466 +958754783 1997132597 28874650 +58197295 306349987 75226540 +180784667 145454582 160895405 +2334903647 1543332738 293501940 +3699983017 2997982209 25342830 +2333574821 2687941166 1328826 +3111317969 1371703183 171629555 +2806959198 2135774873 248452299 +2766721604 717118138 40237594 +3055411497 2632034694 55906472 +2628405587 3023325039 138316017 +1837885148 757355732 442044725 +3725325847 2813358829 184623380 +3353391413 2026007247 109767626 +987629433 3962399141 10015813 +717118138 2546234031 85800663 +3282947524 2742914940 70443889 +1080275742 3972414954 42376007 +133423835 0 47360832 +3463159039 3725575163 236823978 +997645246 3161641056 82630496 + +soil-to-fertilizer map: +303672059 1087423328 103502353 +171922589 2907629744 91556518 +2064217168 468859004 91214014 +1129888530 1046445685 40977643 +3698610046 4215442249 79525047 +1045870106 1586657152 41455160 +1170866173 1322928302 17679660 +4160148003 3332238470 107558461 +4267706464 3853049576 27260832 +0 3007612896 90771201 +3447204990 3880310408 249339913 +1189561657 1438888401 43309463 +4019710828 3219712242 104981462 +2226263856 2187322171 114088350 +553216166 1847338068 182148047 +3217647099 3439796931 229557891 +2832115692 1482197864 23307900 +867366834 94995931 178503272 +1969221237 0 94995931 +3785679859 3704810535 148239041 +1095751900 2693816297 34136630 +4124692290 3669354822 35455713 +454935727 1340607962 98280439 +2204466075 1628112312 21797781 +1947833351 2164918461 21387886 +2634687717 1649910093 197427975 +263479107 2850768768 40192952 +3696544903 3217647099 2065143 +735364213 1190925681 132002621 +3050783393 2337205982 47600704 +1087325266 2999186262 8426634 +3778135093 3324693704 7544766 +2855423592 273499203 195359801 +90771201 1505505764 81151388 +2340352206 560073018 290906919 +1531641800 939263745 107181940 +1188545833 2186306347 1015824 +1355686961 850979937 88283808 +1492181516 2029486115 39460284 +1638823740 2384806686 309009611 +2155431182 2894390312 13239432 +1443970769 2068946399 48210747 +1232871120 2727952927 122815841 +3933918900 4129650321 85791928 +2631259125 2890961720 3428592 +407174412 2117157146 47761315 +2168670614 2301410521 35795461 + +fertilizer-to-water map: +4253126168 3603943470 41841128 +3150812716 3873122781 161556325 +4132148538 3445929121 16652907 +4071215062 2557593856 10373731 +3585414898 2401284809 61555959 +124617758 989226185 56063423 +1311995731 916233018 72993167 +180681181 891200267 25032751 +1577315548 1448436684 231921083 +69948934 1391916079 39397864 +2730663795 3577458422 26485048 +2453473122 3255362867 102306532 +4148801445 3801350502 12292818 +3002725397 3107275548 148087319 +3525935437 3813643320 59479461 +3982955340 3357669399 88259722 +2631712351 2567967587 98951444 +628324302 2038793089 109830184 +3427245435 3721480891 3936914 +796140554 1045289608 36965524 +939693576 1140241200 24301167 +205713932 1680357767 358435322 +4161094263 2666919031 92031905 +1103981621 0 206162329 +1809236631 761213122 129987145 +1310143950 1431313943 1851781 +4081588793 3056715803 50559745 +738154486 1082255132 57986068 +564149254 206162329 64175048 +3722667150 4034679106 260288190 +3431182349 2462840768 94753088 +109346798 1433165724 15270960 +2757148843 2811139249 245576554 +1044349135 2294919620 59632486 +833106078 270337377 106587498 +3646970857 3645784598 75696293 +0 2354552106 4006979 +1974270838 376924875 384288247 +3312369041 3462582028 114876394 +2401284809 2758950936 52188313 +1384988898 1199589429 192326650 +963994743 2214565228 80354392 +1939223776 1164542367 35047062 +4006979 2148623273 65941955 +2555779654 3725417805 75932697 + +water-to-light map: +1553071310 2767299260 81555093 +1638385137 3758734 7165416 +3923895602 3742459208 355646104 +2563492152 40550035 317968 +357175543 151852464 53516575 +756535305 2730597762 36701498 +1142337672 1915537677 164067723 +436470886 2848854353 61956232 +1316538987 1679005354 102639946 +609765571 2079605400 146769734 +1306405395 2660382036 10133592 +3817572860 3406157555 106322742 +2023184953 353497588 62195869 +3531543848 4223491605 71475691 +410692118 126073696 25778768 +4279541706 3727562743 14896465 +2903607795 1495097536 74179449 +1794747312 2279656479 95385933 +2783150325 2269091374 10565105 +3406157555 4098105312 125386293 +2145462956 205369039 148128549 +2833741244 2401175172 69866551 +793236803 685594104 306384629 +1645550553 2511185277 149196759 +1419178933 1781645300 133892377 +1634626403 0 3758734 +3274934245 2471041723 36449164 +0 1097896179 357175543 +2563810120 991978733 105917446 +4294438171 3727033618 529125 +2688189328 1569276985 94960997 +2669727566 2507490887 3694390 +3311383409 10924150 29625885 +1099621432 2226375134 42716240 +1890133245 2910810585 133051708 +583632811 2375042412 26132760 +498427118 40868003 85205693 +2293591505 415693457 269900647 +2673421956 1664237982 14767372 +2085380822 2670515628 60082134 +3603019539 3512480297 214553321 +2977787244 3043862293 297147001 +2793715430 1455071722 40025814 + +light-to-temperature map: +3752181853 3850028427 61847460 +3392702182 4061054452 68370555 +3610251302 4129425007 141930551 +2019529001 2633762146 55812503 +1423059901 2612524947 21237199 +1637625157 3160312690 128493598 +2109055159 2018596226 368399035 +343891384 811352094 920120231 +154347384 2422980947 189544000 +2075341504 1978947609 33713655 +1444297100 2966984633 193328057 +35985686 2689574649 118361698 +2477454194 0 811352094 +1772053717 1854798742 124148867 +1264011615 2807936347 159048286 +0 2386995261 35985686 +1766118755 2012661264 5934962 +3814029313 3392702182 457326245 +3461072737 3911875887 149178565 +1896202584 1731472325 123326417 + +temperature-to-humidity map: +3344602117 2991074372 262457649 +1707309180 3911386116 383581180 +3778482785 2130995124 374719434 +3607059766 3253532021 171423019 +584508486 478912361 161371970 +1578590582 2505714558 128718598 +3294145751 1806488186 50456366 +1143023241 2829557603 161516769 +1304540010 1856944552 274050572 +2090890360 3424955040 344665999 +2435556359 1143023241 663464945 +496214964 1000471163 88293522 +0 640284331 360186832 +3099021304 2634433156 195124447 +360186832 342884229 136028132 +745880456 0 342884229 +4153202219 3769621039 141765077 + +humidity-to-location map: +3114211644 984440400 35385940 +3530465412 479339778 128291026 +0 3699707734 285474938 +2898087648 3606829306 92878428 +2762235329 607630804 135852319 +4210792153 4197161772 84175143 +3149597584 31394121 380867828 +1848709689 0 31394121 +1880103810 412261949 67077829 +285474938 1579019790 1563234751 +2990966076 3566305423 40523883 +2434079297 1019826340 328156032 +2371232521 3985182672 62846776 +1947181639 3142254541 424050882 +3899713715 1347982372 148315733 +3031489959 1496298105 82721685 +4197161772 4281336915 13630381 +3658756438 743483123 240957277 \ No newline at end of file diff --git a/2023/day-5/part1.lua b/2023/day-5/part1.lua new file mode 100644 index 0000000..41f5968 --- /dev/null +++ b/2023/day-5/part1.lua @@ -0,0 +1,97 @@ +require("lib") + +local input = GetInput() + +-- Figure out which one of the seeds have the lowest location number +-- Keep track of every seed and their respective next type individually + +local maps = { + "seed", + "soil", + "fertilizer", + "water", + "light", + "temperature", + "humidity", + "location" +} + +-- Should modify this function, feels backwards and inefficient right now +local function getContentRows(str) + str = str:escape() + local firstRow = -1 + local checkRows = false + for k, v in ipairs(input) do + if k == #input then + return firstRow, k + end + + if checkRows then + local containsDigits = v:match("%d+") + if not containsDigits then + return firstRow, k - 1 + end + end + + local found = v:match(str) + if found then + firstRow = k + 1 + checkRows = true + end + end + return nil +end + +local function getMapString(loop) + return maps[loop] .. "-to-" .. maps[loop+1] .. " map:" +end + +local function fillTables(seedTable, str, currentContent, lastContent) + local first, last = getContentRows(str) + local cc = maps[currentContent] + local lc = maps[lastContent] + + for i = first, last do + local info = { input[i]:match("(%d+) (%d+) (%d+)") } + local destStart, srcStart, length = tonumber(info[1]), tonumber(info[2]), tonumber(info[3]) + + for index, content in ipairs(seedTable) do + if content[lc] >= srcStart and content[lc] < srcStart + length then + local diff = content[lc] - srcStart + seedTable[index][cc] = destStart + diff + end + + if i == last then + if not seedTable[index][cc] then + seedTable[index][cc] = seedTable[index][lc] + end + end + end + end +end + +local function getLowestLocation(seedTable) + local lowest = math.huge + for i = 1, #seedTable do + if seedTable[i].location < lowest then + lowest = seedTable[i].location + end + end + return lowest +end + +local function seeds() + local seedTable = {} + + for seedNumber in input[1]:gmatch("%d+") do + table.insert(seedTable, {seed = tonumber(seedNumber)}) + end + + for i = 1, #maps-1 do + fillTables(seedTable, getMapString(i), i+1, i) + end + + return getLowestLocation(seedTable) +end + +print("What is the lowest location number that corresponds to any of the initial seed numbers?\nAnswer: " .. seeds()) diff --git a/2023/day-5/part2.lua b/2023/day-5/part2.lua new file mode 100644 index 0000000..69bcd65 --- /dev/null +++ b/2023/day-5/part2.lua @@ -0,0 +1,99 @@ +require("lib") + +local input = GetInput("demo") + +-- Figure out which one of the seeds have the lowest location number +-- Keep track of every seed and their respective next type individually + +local maps = { + "seed", + "soil", + "fertilizer", + "water", + "light", + "temperature", + "humidity", + "location" +} + +-- Should modify this function, feels backwards and inefficient right now +local function getContentRows(str) + str = str:escape() + local firstRow = -1 + local checkRows = false + for k, v in ipairs(input) do + if k == #input then + return firstRow, k + end + + if checkRows then + local containsDigits = v:match("%d+") + if not containsDigits then + return firstRow, k - 1 + end + end + + local found = v:match(str) + if found then + firstRow = k + 1 + checkRows = true + end + end + return nil +end + +local function getMapString(loop) + return maps[loop] .. "-to-" .. maps[loop+1] .. " map:" +end + +local function fillTables(seedTable, str, currentContent, lastContent) + local first, last = getContentRows(str) + local cc = maps[currentContent] + local lc = maps[lastContent] + + for i = first, last do + local info = { input[i]:match("(%d+) (%d+) (%d+)") } + local destStart, srcStart, length = tonumber(info[1]), tonumber(info[2]), tonumber(info[3]) + + for index, content in ipairs(seedTable) do + if content[lc] >= srcStart and content[lc] < srcStart + length then + local diff = content[lc] - srcStart + seedTable[index][cc] = destStart + diff + end + + if i == last then + if not seedTable[index][cc] then + seedTable[index][cc] = seedTable[index][lc] + end + end + end + end +end + +local function getLowestLocation(seedTable) + local lowest = math.huge + for i = 1, #seedTable do + if seedTable[i].location < lowest then + lowest = seedTable[i].location + end + end + return lowest +end + +local function seeds() + local seedTable = {} + + for seedNumber, length in input[1]:gmatch("(%d+) (%d+)") do + for i = tonumber(seedNumber), seedNumber + length - 1 do + table.insert(seedTable, {seed = i}) + end + end + + for i = 1, #maps-1 do + fillTables(seedTable, getMapString(i), i+1, i) + end + + return getLowestLocation(seedTable) +end + +print("What is the lowest location number that corresponds to any of the initial seed numbers?\nAnswer: " .. seeds()) diff --git a/2023/day-8/demo-input.txt b/2023/day-8/demo-input.txt new file mode 100644 index 0000000..a8e2c98 --- /dev/null +++ b/2023/day-8/demo-input.txt @@ -0,0 +1,10 @@ +LR + +11A = (11B, XXX) +11B = (XXX, 11Z) +11Z = (11B, XXX) +22A = (22B, XXX) +22B = (22C, 22C) +22C = (22Z, 22Z) +22Z = (22B, 22B) +XXX = (XXX, XXX) \ No newline at end of file diff --git a/2023/day-8/input.txt b/2023/day-8/input.txt new file mode 100644 index 0000000..283a4e2 --- /dev/null +++ b/2023/day-8/input.txt @@ -0,0 +1,800 @@ +LRLRRRLRRRLLLRLRRLLRLRRRLRLRRRLRLRRRLRLRRRLRRRLRLLRRRLRLRLRRLRRLRLRRLRRLRRLLRRRLRRRLRRLRRLRRLRRRLLRRLRLRRLRLRRLRRLRLRRLRRLLRLRRRLRRLRRRLLRLRLRLLRLLRLLRLRRLLRRLRLRLRRLRLLRRRLLRRRLRRLLRRRLRRRLRLRRRLLRRRLRLRRRLLLRRRLRLRLRRRLRRRLRRRLRLRRLLLRRLRRRLLRLRRRLRLRLLLRRLRLRRRLRLRRRR + +GNK = (LBV, QNP) +PJQ = (GHF, FJF) +KLM = (TTR, BQL) +LDT = (FXS, FBB) +TKH = (NBH, JRN) +QND = (KJC, SRD) +SNG = (BQP, LXN) +GMS = (JDN, NKM) +NTL = (PTS, DHK) +NBN = (FFD, PRL) +NCP = (QKB, HMR) +NQT = (RDK, BHC) +TDK = (GHM, GHM) +BJS = (TGC, GBJ) +XNH = (GGJ, TKL) +NKV = (GTC, NCP) +HFL = (LQQ, RVT) +HKC = (BQM, NKP) +KCH = (GJG, GJG) +MFD = (CRD, VDP) +FNZ = (XSM, PQQ) +NVT = (TDN, JVT) +PCQ = (HLD, BKQ) +GPF = (MNJ, NGP) +PCX = (LPD, BJK) +CCG = (TTS, TTS) +BGG = (TQP, NFG) +HSP = (DVS, QQM) +TSX = (GBV, KXM) +RKK = (BNC, FNZ) +HVJ = (RPD, MGB) +CXC = (BTD, VDN) +NBH = (SQQ, PJB) +CQN = (SRV, MCF) +LPD = (PPR, RHS) +BKM = (FJV, XTV) +KQV = (PCK, DXJ) +VCL = (PDN, MTC) +JVS = (QQP, BDM) +MJT = (JCX, NRR) +VSR = (NQT, KNG) +NKM = (HNF, BFD) +HGJ = (BNT, KFK) +VMC = (QND, RKC) +DJG = (PRD, LBD) +JCT = (NFM, NJF) +FPX = (NJF, NFM) +HPD = (SNT, JXR) +QLK = (KXV, KLF) +HMR = (TDK, CXJ) +RQL = (QDP, GBQ) +VDT = (BGP, MXH) +PFV = (TNH, LQV) +TTF = (FLV, SKM) +QKL = (JNB, SKX) +RXC = (QFP, VMV) +NGJ = (QPN, GSF) +MPZ = (JVH, BNB) +FPB = (XNH, NMS) +LQP = (SNG, VVM) +HQF = (MNM, VHL) +XXJ = (PRL, FFD) +KPH = (TTF, SNQ) +JDT = (KCH, JMC) +KRK = (PCX, BMG) +FJV = (QLK, QSN) +MPG = (LJG, PKD) +TCH = (RRQ, QTL) +SDS = (JQR, BXR) +RKR = (KVD, NGN) +TVJ = (XGS, PCQ) +VSQ = (NHP, QQS) +RDK = (XTD, MHB) +SGP = (PRP, XJD) +SVN = (BKM, NSV) +SJC = (DGL, FRH) +NJX = (TRN, MHN) +RCG = (BSN, DQR) +HXJ = (KDL, SRR) +BQZ = (PQL, FRM) +NKS = (SHM, SHM) +FPJ = (STM, CTN) +SFM = (PVC, TGM) +VSS = (MGV, JLS) +DGL = (NBB, BST) +XRQ = (LPN, MKF) +RSZ = (SVM, XMG) +TTK = (KST, MGQ) +FJF = (CRC, RXF) +CMT = (HPH, KPL) +SDR = (LTD, TVK) +BST = (KQV, QPH) +DGT = (BCQ, MLX) +QPN = (MMD, LKL) +SHM = (FRM, PQL) +XDD = (QCS, VMD) +SNQ = (FLV, SKM) +TLF = (QTC, GRK) +CPB = (DFX, GDN) +BRJ = (LDR, CDR) +JNL = (JTD, SMV) +FTG = (VRN, VRN) +GBJ = (VGH, DJT) +TGS = (FPB, QGT) +MHB = (DKL, KMX) +GNH = (SFQ, JXK) +LTD = (XJQ, MBL) +PCR = (JDD, KTL) +DMD = (KHC, KVH) +FTT = (LTB, BLD) +LMT = (RKC, QND) +JGT = (FDT, VDD) +MDV = (XTS, MRF) +PLV = (KXC, CNM) +PRJ = (SHC, MNL) +PML = (GRX, QGJ) +VVM = (LXN, BQP) +NGN = (GBG, XJX) +VCG = (SRV, MCF) +QFP = (TJS, XPD) +LVX = (FPX, JCT) +RBC = (DRM, VHC) +XKT = (CCG, FLM) +SDH = (BNF, GKN) +BVQ = (QSH, VSQ) +SMV = (SKN, HHJ) +DBD = (RSM, PKB) +DQR = (HVS, DVC) +MNK = (DXT, CLD) +FFD = (DLF, JPQ) +GBG = (TKP, KPM) +CHK = (MMT, MQC) +BXR = (GMV, BGT) +SFD = (XSP, SDS) +PRT = (HDB, RCG) +QXJ = (QQT, BHG) +TGR = (TQD, TJM) +GJG = (RVQ, TVJ) +BFD = (SGS, NCH) +PND = (BPL, TKV) +JPG = (GNQ, QKP) +FDT = (NPF, SFF) +DLX = (XVP, BNR) +SNT = (QFR, RMT) +DND = (TVK, LTD) +SSF = (LLF, FRV) +DRK = (FTG, LBT) +VQV = (JVS, RRH) +XBV = (DSC, NRL) +CVL = (KRF, NJX) +XGP = (BQJ, RXC) +MLX = (TBD, QSG) +JDF = (CCG, CCG) +GVN = (SCN, PKH) +NCB = (GKN, BNF) +LLF = (PND, LMM) +SHX = (TXM, PRJ) +KNL = (KSL, VQQ) +JSK = (SQD, MPG) +PPS = (KHC, KVH) +NKJ = (DBD, RFB) +CNM = (FCB, DHP) +TXJ = (DBJ, DLX) +QSH = (QQS, NHP) +BRC = (PLN, GMS) +BHP = (JNH, CLP) +BQL = (SDR, DND) +TGC = (VGH, DJT) +MHM = (VHV, HFP) +NGP = (HNN, HDX) +SKM = (SXH, PTR) +TFN = (SMK, GXL) +NSR = (GLB, PCH) +RHS = (XCX, RFH) +BNC = (PQQ, XSM) +XJX = (KPM, TKP) +LFT = (TMH, SSP) +KVD = (XJX, GBG) +SKX = (NGF, NTC) +CKQ = (FCL, MRM) +MTC = (PBM, TGR) +RHV = (TGS, KDV) +MMD = (VMJ, TFN) +PSM = (XDK, GSG) +KXM = (RDN, XPS) +PLN = (NKM, JDN) +HDK = (SKX, JNB) +XGS = (HLD, BKQ) +FMB = (PHL, TFG) +LHH = (XRF, STP) +LTB = (TDC, BCX) +FRV = (LMM, PND) +GRK = (FDH, CQD) +NRR = (HNS, KBJ) +BGT = (LDT, VBJ) +SRD = (CBG, DMM) +KNF = (DVL, KNL) +KXC = (FCB, DHP) +GHB = (NNJ, QMH) +PGQ = (JJX, VSF) +SKB = (XXT, NTM) +LXP = (PRD, LBD) +PRL = (JPQ, DLF) +FRM = (LBN, CPB) +KSL = (FPT, TTC) +CRC = (RCL, HQF) +SVM = (BJS, XKD) +PXB = (PMC, HPD) +JPQ = (MKJ, MKC) +TTR = (DND, SDR) +CBH = (FTD, JJQ) +XPS = (NSP, LSS) +KMX = (QSL, SJC) +CLD = (MDP, CKQ) +GXV = (MKK, DBB) +BQP = (TQH, LKN) +FTB = (GJQ, GXV) +KPL = (DRR, RSZ) +MKF = (SDH, NCB) +SSP = (CBN, XCF) +XJQ = (NND, TPT) +NTT = (NDJ, QFB) +PLF = (NBH, JRN) +XDK = (GPF, FSG) +NTC = (DGT, XRB) +SGJ = (QMH, NNJ) +TNH = (VGB, FDR) +DFX = (HFC, KTX) +DBJ = (XVP, BNR) +VDD = (SFF, NPF) +JKL = (FRT, CVL) +XSP = (BXR, JQR) +DBP = (PSR, LJS) +KHC = (MJT, KTP) +TKP = (VRX, GVN) +DKL = (SJC, QSL) +DLP = (XXJ, NBN) +KLN = (HRP, JPM) +TPP = (NHJ, PCR) +QVF = (QNP, LBV) +VMD = (CTF, SFM) +NFM = (QKL, HDK) +MCF = (BJV, JXL) +PQG = (XTQ, QMC) +BGP = (HFT, KTD) +PTS = (DDG, RBC) +JLS = (SHL, VPT) +DHT = (NPC, KRP) +TJM = (KHM, BXB) +TRH = (NDJ, QFB) +CTF = (PVC, TGM) +PMJ = (BHP, TDF) +AAA = (MPF, VMM) +XCF = (LVX, FNT) +FRH = (BST, NBB) +QLL = (HDB, RCG) +XVP = (QHD, PML) +BNX = (TLQ, TSX) +BXB = (JSJ, KDQ) +FPT = (LBC, VJF) +FCB = (TJK, MJD) +KNG = (RDK, BHC) +DBB = (RFX, FLK) +LQQ = (RTP, HGJ) +LBT = (VRN, RLT) +XKD = (GBJ, TGC) +LKN = (XDD, CPC) +XHM = (CNM, KXC) +DTC = (QQT, BHG) +BPL = (DMS, GQC) +QPP = (MRF, XTS) +PRK = (NKP, BQM) +MGS = (MPG, SQD) +STM = (MTS, GHD) +SKD = (MGV, JLS) +QPH = (DXJ, PCK) +HDB = (DQR, BSN) +DSC = (VXM, CHK) +TQF = (GJT, FNJ) +FXS = (GHQ, BVQ) +SFF = (HKC, PRK) +DRR = (XMG, SVM) +RKP = (XXN, LDQ) +NNJ = (KLG, HFL) +VJF = (HMJ, RDC) +LXN = (TQH, LKN) +CXJ = (GHM, CMT) +HMC = (GMS, PLN) +LJS = (JDF, XKT) +XCH = (TTR, BQL) +LKG = (QXJ, DTC) +QFB = (MHT, CFL) +RDN = (LSS, NSP) +DHS = (SHM, BQZ) +NKT = (GSG, XDK) +MCH = (HTP, BLC) +NVX = (MGS, JSK) +QTC = (FDH, FDH) +NND = (DGP, LBF) +GJV = (XHM, PLV) +GSG = (FSG, GPF) +BNV = (STM, CTN) +LDQ = (MCH, GXS) +MHN = (KPH, PKC) +LBF = (PPS, DMD) +QDP = (NKV, HSQ) +MPF = (MNK, LTH) +DHQ = (CDR, LDR) +VMM = (MNK, LTH) +HFT = (BRC, HMC) +LTR = (NKT, PSM) +HDX = (GJC, FTT) +GHF = (RXF, CRC) +BKQ = (FTB, HJH) +BXX = (NJC, NPK) +FVP = (BRG, NTJ) +RDC = (LHT, VMG) +JKT = (QPP, MDV) +PVP = (GHB, SGJ) +XXN = (GXS, MCH) +SHC = (GNH, PCJ) +GSF = (LKL, MMD) +KRP = (MGL, VGQ) +JXK = (TGN, TJP) +MGQ = (XRQ, VBN) +FLN = (MGB, RPD) +DHP = (MJD, TJK) +SQQ = (DVP, VCD) +HFH = (CBH, JMM) +MBP = (NDF, TFK) +KLG = (RVT, LQQ) +NPF = (PRK, HKC) +NMS = (GGJ, TKL) +QQP = (CGM, TCH) +SFG = (NVG, NSR) +RVQ = (XGS, PCQ) +SQD = (PKD, LJG) +JCX = (HNS, KBJ) +QSN = (KXV, KLF) +GLX = (NKT, PSM) +TJS = (GJV, MPK) +QLJ = (XJD, PRP) +NSV = (FJV, XTV) +GXX = (RFB, DBD) +HSR = (BRG, NTJ) +HBF = (CDC, NXL) +XSS = (PSR, LJS) +QTL = (TQF, HQM) +TKL = (DNF, PVP) +BRK = (JKQ, JKK) +SCN = (MFC, PMJ) +GMV = (VBJ, LDT) +HNS = (LMT, VMC) +RGR = (NTT, TRH) +PNC = (KCH, KCH) +XNK = (JNL, QFH) +RRR = (PQT, NGR) +TDN = (KBC, TTK) +NQN = (KHN, SSF) +HMK = (RRH, JVS) +RFB = (PKB, RSM) +SFQ = (TGN, TJP) +JKQ = (SVN, BDB) +CTN = (MTS, GHD) +QNT = (TQP, NFG) +VHL = (JJP, HBF) +RFH = (PLF, TKH) +KTD = (BRC, HMC) +VRX = (SCN, PKH) +BNT = (JKL, JCL) +MDN = (DLC, BRK) +CBG = (SKS, PJQ) +QFH = (JTD, SMV) +HVS = (XGP, CCX) +NQH = (BKX, VSR) +GQQ = (MBV, HMN) +LSN = (NTM, XXT) +FLQ = (RRR, QLT) +LXM = (PRT, QLL) +HJH = (GXV, GJQ) +SRV = (JXL, BJV) +TMH = (XCF, CBN) +PRB = (KTV, NDD) +JJQ = (QHQ, QDB) +KSV = (NTT, TRH) +XKH = (VJS, JGT) +SJP = (QNT, BGG) +NTR = (BNC, BNC) +PBM = (TJM, TQD) +RPD = (DVG, PRB) +XPD = (MPK, GJV) +NCH = (GKG, NGJ) +KTP = (JCX, NRR) +GQC = (QNR, PFV) +MKC = (VLF, SFD) +NTM = (FBF, XNK) +TVK = (MBL, XJQ) +RMT = (XKV, RHC) +NHP = (DPM, MHM) +JNB = (NGF, NTC) +RTP = (BNT, KFK) +GJT = (TKR, GPL) +TTS = (VFM, VFM) +FLK = (BNV, FPJ) +CJJ = (QVF, GNK) +QKP = (FBG, TPP) +XQT = (JVT, TDN) +JVH = (XKX, JKM) +NDJ = (CFL, MHT) +JXX = (BRK, DLC) +XJD = (SMN, LKG) +JXL = (KVB, RHV) +VMG = (KKM, JKT) +FBG = (NHJ, PCR) +LKL = (VMJ, TFN) +NXL = (XSS, DBP) +SRC = (FTG, LBT) +PDC = (CQN, VCG) +BLD = (TDC, BCX) +NHJ = (KTL, JDD) +DGC = (VFM, ZZZ) +LTX = (QTC, GRK) +CCX = (BQJ, RXC) +DRM = (DGB, PGX) +VQQ = (TTC, FPT) +BHC = (XTD, MHB) +CDC = (DBP, XSS) +SXH = (PNC, PNC) +KBC = (KST, MGQ) +DXT = (CKQ, MDP) +PRP = (SMN, LKG) +SGS = (NGJ, GKG) +VBN = (LPN, MKF) +BNF = (KGK, PGK) +HLD = (FTB, HJH) +FGT = (TCG, NTL) +VBT = (DVS, QQM) +XVT = (QLL, PRT) +SBH = (BNB, JVH) +VGB = (VSS, SKD) +XJJ = (CXC, PKX) +JKK = (BDB, SVN) +BSN = (HVS, DVC) +DBX = (QSR, HXJ) +QSG = (KHJ, VMP) +CPK = (CRD, VDP) +JGD = (JMM, CBH) +VGH = (CQM, DLP) +GBQ = (HSQ, NKV) +GRX = (LSN, SKB) +FLM = (TTS, DGC) +PPR = (XCX, RFH) +VDP = (HVV, VDB) +GKN = (PGK, KGK) +XDA = (BNB, JVH) +MNL = (PCJ, GNH) +MGB = (PRB, DVG) +FBB = (BVQ, GHQ) +NTJ = (LXP, DJG) +PQQ = (NVT, XQT) +TQP = (TVG, FMV) +LQK = (BPC, HSX) +MTG = (TSM, PXB) +VSF = (LXM, XVT) +HJB = (BMG, PCX) +VMJ = (GXL, SMK) +CXB = (QLF, SJP) +HCP = (SSF, KHN) +QLH = (HSX, BPC) +NFG = (TVG, FMV) +PKB = (LHH, HKJ) +BRG = (DJG, LXP) +TLQ = (KXM, GBV) +DDG = (DRM, VHC) +BQM = (NVX, KLT) +KTX = (LJP, DVH) +XTS = (DHQ, BRJ) +TFG = (VQV, HMK) +JCD = (VSF, JJX) +VFM = (MPF, VMM) +LGJ = (NJC, NJC) +PQB = (BGP, MXH) +CBN = (LVX, FNT) +FCL = (NQH, TXN) +JNH = (RKP, QDF) +LHT = (JKT, KKM) +MJD = (PDC, PRV) +QGT = (XNH, NMS) +KST = (XRQ, VBN) +KDV = (FPB, QGT) +HFP = (NNK, MBP) +BJK = (PPR, RHS) +XXM = (MFD, CPK) +QLT = (PQT, NGR) +HMJ = (LHT, VMG) +XDR = (TCG, NTL) +NNK = (TFK, NDF) +VJC = (NSR, NVG) +MMM = (QLF, SJP) +BNB = (XKX, JKM) +LJG = (VJC, SFG) +QQT = (SRF, XXM) +JPM = (HSR, FVP) +GNQ = (FBG, TPP) +PJB = (VCD, DVP) +NKP = (KLT, NVX) +GJC = (LTB, BLD) +MRF = (DHQ, BRJ) +SRF = (CPK, MFD) +FSS = (VXJ, DHG) +XXZ = (TVJ, RVQ) +NDD = (RGN, LSJ) +TQD = (KHM, BXB) +XJB = (PXB, TSM) +LSJ = (XCH, KLM) +JBJ = (JGD, HFH) +DMS = (QNR, PFV) +DLF = (MKC, MKJ) +HNN = (FTT, GJC) +VXM = (MQC, MMT) +LMM = (TKV, BPL) +BMG = (BJK, LPD) +QGJ = (LSN, SKB) +FRT = (NJX, KRF) +SKN = (DHT, DBM) +LBD = (JXX, MDN) +KFK = (JKL, JCL) +RRH = (BDM, QQP) +NRL = (CHK, VXM) +LCX = (VJS, JGT) +CNR = (GBQ, QDP) +TGN = (PQB, VDT) +GRT = (DBJ, DLX) +FDH = (NTR, NTR) +CRD = (VDB, HVV) +DMM = (PJQ, SKS) +VHC = (PGX, DGB) +FTD = (QDB, QHQ) +NPC = (MGL, VGQ) +PRV = (VCG, CQN) +TSM = (PMC, HPD) +CQM = (XXJ, NBN) +BNR = (PML, QHD) +NSP = (CBR, GQQ) +TJK = (PRV, PDC) +MST = (KNL, DVL) +VMP = (JFF, PQG) +TDF = (JNH, CLP) +MQC = (HVJ, FLN) +VPT = (BNX, JCC) +GKP = (PHL, TFG) +JJX = (XVT, LXM) +MMT = (FLN, HVJ) +CRP = (HFH, JGD) +DBM = (KRP, NPC) +LQV = (VGB, FDR) +XRF = (GFV, PHK) +RRQ = (TQF, HQM) +RXF = (RCL, HQF) +JRN = (PJB, SQQ) +JTD = (SKN, HHJ) +HTP = (JTR, VCL) +JMM = (FTD, JJQ) +MBL = (NND, TPT) +RCL = (MNM, VHL) +LGS = (QVF, GNK) +CSC = (CNR, RQL) +MFC = (BHP, TDF) +HSX = (HSP, VBT) +GBV = (RDN, XPS) +VXJ = (QHV, LQP) +JKM = (XJJ, GMC) +MTS = (KRK, HJB) +QDB = (DRK, SRC) +GGJ = (DNF, PVP) +XXT = (XNK, FBF) +XSM = (XQT, NVT) +QQM = (XJB, MTG) +KDQ = (QLH, LQK) +HNB = (TMH, SSP) +FRJ = (VXJ, DHG) +PQL = (LBN, CPB) +SKS = (GHF, FJF) +DLC = (JKQ, JKK) +JMC = (GJG, XXZ) +STP = (GFV, PHK) +QNP = (LCX, XKH) +KLF = (CJJ, LGS) +XSA = (PQQ, XSM) +KTV = (RGN, LSJ) +FDR = (SKD, VSS) +PCH = (GRT, TXJ) +KTL = (XDR, FGT) +LBB = (NRL, DSC) +XKV = (JBJ, CRP) +KHJ = (JFF, PQG) +NGF = (XRB, DGT) +DVH = (QLJ, SGP) +MRM = (TXN, NQH) +TGM = (LGJ, BXX) +MKK = (RFX, FLK) +RLT = (FBH, LGL) +GXS = (HTP, BLC) +XKX = (GMC, XJJ) +VMV = (XPD, TJS) +MGL = (LTX, TLF) +NJC = (NKS, NKS) +CLP = (QDF, RKP) +SMK = (NKJ, GXX) +KPM = (GVN, VRX) +BCQ = (TBD, QSG) +TPT = (LBF, DGP) +CFA = (FRM, PQL) +KVB = (TGS, KDV) +BDM = (CGM, TCH) +JJP = (CDC, NXL) +PMC = (JXR, SNT) +PGX = (HCP, NQN) +LBC = (RDC, HMJ) +MBV = (DBX, DDQ) +KXV = (LGS, CJJ) +DJT = (DLP, CQM) +LDR = (LFT, HNB) +GXL = (NKJ, GXX) +SMN = (QXJ, DTC) +DCJ = (GKP, FMB) +GDN = (KTX, HFC) +KGK = (PHN, KLN) +VBJ = (FBB, FXS) +DDQ = (QSR, HXJ) +KJC = (CBG, DMM) +BLC = (VCL, JTR) +QNR = (LQV, TNH) +KRF = (TRN, MHN) +JFF = (QMC, XTQ) +MPK = (PLV, XHM) +PKC = (TTF, SNQ) +VRN = (FBH, FBH) +DVL = (VQQ, KSL) +XTD = (KMX, DKL) +VDB = (MXN, JPG) +FMV = (RGR, KSV) +HMN = (DDQ, DBX) +TRN = (PKC, KPH) +GKG = (QPN, GSF) +MDP = (MRM, FCL) +DHG = (QHV, LQP) +BDB = (NSV, BKM) +HPH = (DRR, DRR) +BKX = (KNG, NQT) +KVH = (KTP, MJT) +VDN = (GLX, LTR) +TFK = (CXB, MMM) +CQD = (NTR, RKK) +HHJ = (DBM, DHT) +VHV = (NNK, MBP) +FBF = (JNL, QFH) +PKX = (BTD, VDN) +PHK = (XBV, LBB) +QMH = (KLG, HFL) +SHL = (JCC, BNX) +FNT = (JCT, FPX) +HNF = (NCH, SGS) +LBV = (LCX, XKH) +MKJ = (SFD, VLF) +CCL = (RRR, QLT) +RSM = (HKJ, LHH) +HFC = (LJP, DVH) +MXH = (KTD, HFT) +PVC = (LGJ, BXX) +MNJ = (HNN, HDX) +DHK = (DDG, RBC) +JCL = (FRT, CVL) +FSG = (NGP, MNJ) +PHL = (HMK, VQV) +GFV = (XBV, LBB) +TXN = (BKX, VSR) +GJQ = (DBB, MKK) +XCX = (TKH, PLF) +MHT = (KNF, MST) +KDL = (FRJ, FSS) +MNM = (JJP, HBF) +XMG = (BJS, XKD) +QHQ = (DRK, SRC) +DVC = (CCX, XGP) +QQS = (MHM, DPM) +TVG = (KSV, RGR) +CGM = (QTL, RRQ) +QFR = (RHC, XKV) +VLF = (XSP, SDS) +DNF = (GHB, SGJ) +QHV = (SNG, VVM) +RVT = (HGJ, RTP) +RGN = (XCH, KLM) +QMC = (FLQ, CCL) +TJP = (VDT, PQB) +QKB = (TDK, CXJ) +SND = (GKP, FMB) +CPC = (QCS, VMD) +KHN = (LLF, FRV) +QLF = (BGG, QNT) +VJS = (FDT, VDD) +FNJ = (GPL, TKR) +MXN = (GNQ, QKP) +BQJ = (VMV, QFP) +NPK = (NKS, DHS) +HJA = (XMG, SVM) +HQM = (FNJ, GJT) +DVP = (DCJ, SND) +BCX = (RKR, NTH) +BHG = (XXM, SRF) +HSQ = (GTC, NCP) +TXM = (MNL, SHC) +PQT = (CSC, XGC) +NJF = (QKL, HDK) +MGV = (VPT, SHL) +TKR = (PGQ, JCD) +LGL = (SBH, MPZ) +PHN = (HRP, JPM) +LBN = (GDN, DFX) +JCC = (TSX, TLQ) +DXJ = (SHX, CHB) +KHM = (KDQ, JSJ) +XRB = (BCQ, MLX) +PCJ = (SFQ, JXK) +DVS = (XJB, MTG) +PCK = (CHB, SHX) +TTC = (VJF, LBC) +PKD = (VJC, SFG) +GHM = (HPH, HPH) +CHB = (PRJ, TXM) +QSR = (KDL, SRR) +TCG = (DHK, PTS) +NGR = (CSC, XGC) +VGQ = (LTX, TLF) +JQR = (GMV, BGT) +TQH = (CPC, XDD) +KKM = (MDV, QPP) +LSS = (CBR, GQQ) +DVG = (KTV, NDD) +TBD = (KHJ, VMP) +PRD = (MDN, JXX) +GPL = (PGQ, JCD) +TKV = (GQC, DMS) +RKC = (SRD, KJC) +QSL = (DGL, FRH) +JXR = (RMT, QFR) +CFL = (MST, KNF) +BJV = (RHV, KVB) +PSR = (JDF, XKT) +HPA = (RVQ, TVJ) +QDF = (LDQ, XXN) +GLB = (GRT, TXJ) +BPC = (HSP, VBT) +FLV = (SXH, PTR) +JTR = (MTC, PDN) +QCS = (CTF, SFM) +SRR = (FSS, FRJ) +DPM = (HFP, VHV) +PDN = (PBM, TGR) +VCD = (DCJ, SND) +KBJ = (LMT, VMC) +RHC = (CRP, JBJ) +DGP = (DMD, PPS) +HVV = (MXN, JPG) +LTH = (DXT, CLD) +XTV = (QSN, QLK) +CBR = (MBV, HMN) +CDR = (HNB, LFT) +GHQ = (VSQ, QSH) +TDC = (NTH, RKR) +XTQ = (FLQ, CCL) +GMC = (CXC, PKX) +PGK = (PHN, KLN) +NTH = (NGN, KVD) +PKH = (PMJ, MFC) +JDN = (HNF, BFD) +FBH = (SBH, SBH) +JDD = (FGT, XDR) +HKJ = (XRF, STP) +KLT = (MGS, JSK) +GHD = (HJB, KRK) +HRP = (FVP, HSR) +PTR = (PNC, JDT) +LJP = (SGP, QLJ) +JVT = (TTK, KBC) +ZZZ = (VMM, MPF) +BTD = (GLX, LTR) +GTC = (QKB, HMR) +NDF = (CXB, MMM) +DGB = (NQN, HCP) +JSJ = (QLH, LQK) +NBB = (KQV, QPH) +XGC = (RQL, CNR) +QHD = (GRX, QGJ) +RFX = (FPJ, BNV) +LPN = (NCB, SDH) +NVG = (PCH, GLB) \ No newline at end of file diff --git a/2023/day-8/part1.lua b/2023/day-8/part1.lua new file mode 100644 index 0000000..b12be53 --- /dev/null +++ b/2023/day-8/part1.lua @@ -0,0 +1,42 @@ +require("lib") + +local input = GetInput() + +-- Loop one direction at a time +-- Remember the last line number + +local function getLine(letters) + for line, str in ipairs(input) do + if str:match(letters .. " = ") then + return line + end + end + return nil +end + +local function getLetters(dir, line) + local left, right = input[line]:match("%((%u+), (%u+)%)") + return dir == "R" and right or left +end + +local function hauntedWasteland(s, l) + local steps = s or 0 + local currentLetters = l or "AAA" + + for direction in input[1]:gmatch("%u") do + local currentLine = getLine(currentLetters) + currentLetters = getLetters(direction, currentLine) + steps = steps + 1 + + if currentLetters == "ZZZ" then + break + end + end + + if currentLetters ~= "ZZZ" then + return hauntedWasteland(steps, currentLetters) + end + return steps +end + +print("How many steps are required to reach ZZZ?\nAnswer: " .. hauntedWasteland()) diff --git a/2023/day-8/part2.lua b/2023/day-8/part2.lua new file mode 100644 index 0000000..548950c --- /dev/null +++ b/2023/day-8/part2.lua @@ -0,0 +1,64 @@ +-- Probably (?) works but takes too long to run, have to use other method +require("lib") + +local input = GetInput("demo") + +local cachedLines = {} +local positions = {} +local steps = 0 + +local function getLine(letters) + if not cachedLines[letters] then + for line, str in ipairs(input) do + if str:match(letters .. " = ") then + cachedLines[letters] = line + break + end + end + end + return cachedLines[letters] +end + +local function runLetters(dir) + for _, data in ipairs(positions) do + local left, right = input[data.num]:match("%((.*), (.*)%)") + local line = (dir == "R" and getLine(right)) or getLine(left) + local lastNode = input[line]:match("(..Z) = ") + data.num = line + data.done = (lastNode and true) or false + end +end + +local function checkCompletion() + for _, v in ipairs(positions) do + if not v.done then + return false + end + end + return true +end + +local function hauntedWasteland() + if #positions == 0 then + for line, str in ipairs(input) do + local validStart = str:match("..(A)") + if validStart then + local subTable = {num = line, done = false} + table.insert(positions, subTable) + end + end + end + + for direction in input[1]:gmatch("%u") do + steps = steps + 1 + runLetters(direction) + + if checkCompletion() then + return steps + end + end + + return hauntedWasteland() +end + +print("How many steps does it take before you're only on nodes that end with Z?\nAnswer: " .. hauntedWasteland())