├── .gitignore ├── src ├── day-06 │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ └── java │ │ │ │ └── ru │ │ │ │ └── gnkoshelev │ │ │ │ └── aoc │ │ │ │ └── lanternfish │ │ │ │ ├── Algorithm.java │ │ │ │ ├── Lanternfish.java │ │ │ │ ├── LanternfishCalculator.java │ │ │ │ ├── TickerAlgorithm.java │ │ │ │ └── RecurrentAlgorithm.java │ │ └── test │ │ │ └── java │ │ │ └── ru │ │ │ └── gnkoshelev │ │ │ └── aoc │ │ │ └── lanternfish │ │ │ └── AlgorithmTest.java │ ├── README.md │ └── pom.xml ├── day-01 │ └── AoC_Day1 │ │ ├── obj │ │ ├── rider.project.restore.info │ │ ├── Debug │ │ │ └── net6.0 │ │ │ │ ├── AoC_Day1.csproj.AssemblyReference.cache │ │ │ │ ├── AoC_Day1.AssemblyInfoInputs.cache │ │ │ │ ├── AoC_Day1.assets.cache │ │ │ │ ├── .NETCoreApp,Version=v6.0.AssemblyAttributes.cs │ │ │ │ ├── AoC_Day1.GlobalUsings.g.cs │ │ │ │ ├── AoC_Day1.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ └── AoC_Day1.AssemblyInfo.cs │ │ ├── AoC_Day1.csproj.nuget.g.targets │ │ ├── project.nuget.cache │ │ ├── project.packagespec.json │ │ ├── AoC_Day1.csproj.nuget.g.props │ │ ├── project.assets.json │ │ └── AoC_Day1.csproj.nuget.dgspec.json │ │ ├── input.txt │ │ ├── .idea │ │ └── .idea.AoC_Day1 │ │ │ └── .idea │ │ │ ├── encodings.xml │ │ │ ├── vcs.xml │ │ │ ├── indexLayout.xml │ │ │ └── .gitignore │ │ ├── Program.cs │ │ ├── AoC_Day1.csproj │ │ └── AoC_Day1.sln ├── day-02 │ ├── input.txt │ └── solution.py ├── day-07 │ ├── AoC2021 Day7.pptx │ ├── 07-crabs.py │ └── 07.txt ├── day-05 │ ├── Cargo.toml │ ├── .gitignore │ └── src │ │ ├── main.rs │ │ └── in ├── day-10 │ ├── test_input.txt │ ├── day10.py │ ├── day10.l │ └── prod_input.txt ├── day-04 │ ├── input.txt │ ├── day04_1.os │ └── day04_2.os ├── day-03 │ ├── part1.js │ ├── part2.js │ └── input.txt ├── day-11 │ └── core.clj ├── day-14 │ └── Day14.kt ├── day-08 │ ├── 08.js │ └── 08.txt ├── day-09 │ ├── day09.go │ └── day09.txt ├── day-12 │ └── 12.cpp └── day-13 │ └── singlefile13.scala ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /src/day-06/.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | *.iml 3 | /target 4 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/rider.project.restore.info: -------------------------------------------------------------------------------- 1 | 16383678876930352 -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.csproj.AssemblyReference.cache: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /src/day-02/input.txt: -------------------------------------------------------------------------------- 1 | forward 5 2 | down 5 3 | forward 8 4 | up 3 5 | down 8 6 | forward 2 7 | -------------------------------------------------------------------------------- /src/day-07/AoC2021 Day7.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skbkontur/AoC2021/HEAD/src/day-07/AoC2021 Day7.pptx -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/input.txt: -------------------------------------------------------------------------------- 1 | 199 2 | 200 3 | 208 4 | 210 5 | 200 6 | 207 7 | 240 8 | 269 9 | 260 10 | 263 -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 2760c6de2cd0eec1eb0d1e0b627455df27839670 2 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.assets.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skbkontur/AoC2021/HEAD/src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.assets.cache -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/AoC_Day1.csproj.nuget.g.targets: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/.idea/.idea.AoC_Day1/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/day-06/src/main/java/ru/gnkoshelev/aoc/lanternfish/Algorithm.java: -------------------------------------------------------------------------------- 1 | package ru.gnkoshelev.aoc.lanternfish; 2 | 3 | /** 4 | * @author Gregory Koshelev 5 | */ 6 | public interface Algorithm { 7 | long compute(int[] counters, int days); 8 | } 9 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/.idea/.idea.AoC_Day1/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/day-05/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "day-05" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | itertools = "0.10.1" 10 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/.idea/.idea.AoC_Day1/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/.NETCoreApp,Version=v6.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /src/day-10/test_input.txt: -------------------------------------------------------------------------------- 1 | [({(<(())[]>[[{[]{<()<>> 2 | [(()[<>])]({[<{<<[]>>( 3 | {([(<{}[<>[]}>{[]{[(<()> 4 | (((({<>}<{<{<>}{[]{[]{} 5 | [[<[([]))<([[{}[[()]]] 6 | [{[{({}]{}}([{[{{{}}([] 7 | {<[[]]>}<{[{[{[]{()[[[] 8 | [<(<(<(<{}))><([]([]() 9 | <{([([[(<>()){}]>(<<{{ 10 | <{([{{}}[<[[[<>{}]]]>[]] 11 | -------------------------------------------------------------------------------- /src/day-06/src/main/java/ru/gnkoshelev/aoc/lanternfish/Lanternfish.java: -------------------------------------------------------------------------------- 1 | package ru.gnkoshelev.aoc.lanternfish; 2 | 3 | /** 4 | * @author Gregory Koshelev 5 | */ 6 | public class Lanternfish { 7 | public static final int REPRODUCTIVE_AGE_DAYS = 9; 8 | public static final int REPRODUCING_INTERVAL_DAYS = 7; 9 | } 10 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/project.nuget.cache: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "dgSpecHash": "GcxCn4FENzWJ6ZGqZNgfFbm5deIwJ8ZnQiONkeKzIq3XhaLeM36qIgAOaqWUW1b9Iy+MNq9L91ClI9edT4MEPw==", 4 | "success": true, 5 | "projectFilePath": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj", 6 | "expectedPackageFiles": [], 7 | "logs": [] 8 | } -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.GlobalUsings.g.cs: -------------------------------------------------------------------------------- 1 | // 2 | global using global::System; 3 | global using global::System.Collections.Generic; 4 | global using global::System.IO; 5 | global using global::System.Linq; 6 | global using global::System.Net.Http; 7 | global using global::System.Threading; 8 | global using global::System.Threading.Tasks; 9 | -------------------------------------------------------------------------------- /src/day-05/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/.idea/.idea.AoC_Day1/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /contentModel.xml 6 | /projectSettingsUpdater.xml 7 | /modules.xml 8 | /.idea.AoC_Day1.iml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /src/day-04/input.txt: -------------------------------------------------------------------------------- 1 | 7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 2 | 3 | 22 13 17 11 0 4 | 8 2 23 4 24 5 | 21 9 14 16 7 6 | 6 10 3 18 5 7 | 1 12 20 15 19 8 | 9 | 3 15 0 2 22 10 | 9 18 13 17 5 11 | 19 8 7 25 23 12 | 20 11 10 24 4 13 | 14 21 16 12 6 14 | 15 | 14 21 17 24 4 16 | 10 16 15 9 19 17 | 18 8 23 26 20 18 | 22 11 13 6 5 19 | 2 0 12 3 7 -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | 5 | // Put your input to "input.txt" file 6 | var depths = File.ReadAllLines("input.txt").Select(int.Parse).ToList(); 7 | 8 | var answer1 = depths.Skip(1).Where((depth, i) => depth > depths[i]).Count(); 9 | 10 | var answer2 = depths.Skip(3).Where((depth, i) => 11 | depth > depths[i] 12 | ).Count(); 13 | 14 | Console.WriteLine($"First puzzle answer: {answer1}, second puzzle answer: {answer2}"); 15 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/AoC_Day1.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | Always 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net6.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.InvariantGlobalization = 7 | build_property.PlatformNeutralAssembly = 8 | build_property._SupportedPlatformList = Linux,macOS,Windows 9 | build_property.RootNamespace = AoC_Day1 10 | build_property.ProjectDir = /Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/ 11 | -------------------------------------------------------------------------------- /src/day-03/part1.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const inputLines = fs.readFileSync("./input.txt", "utf-8").split("\r\n"); 3 | 4 | const bitsCount = inputLines[0].length; 5 | let gammaRate = 0; 6 | for (let i = 0; i < bitsCount; i++) { 7 | const maxBit = getMaxBit(inputLines, i); 8 | gammaRate = gammaRate + maxBit * Math.pow(2, bitsCount - i - 1); 9 | } 10 | const epsilonRate = gammaRate ^ ((1 << bitsCount) - 1); 11 | console.log(gammaRate * epsilonRate); 12 | 13 | function getMaxBit(lines, position) { 14 | const numberOfOnes = lines.reduce( 15 | (prev, curr) => (curr[position] == 1 ? prev + 1 : prev), 16 | 0 17 | ); 18 | const numberOfZeroes = lines.length - numberOfOnes; 19 | return numberOfOnes > numberOfZeroes ? 1 : 0; 20 | } 21 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/AoC_Day1.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AoC_Day1", "AoC_Day1.csproj", "{CC0964A8-655D-48A3-BE3F-5A59B47D34AF}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Any CPU = Debug|Any CPU 8 | Release|Any CPU = Release|Any CPU 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {CC0964A8-655D-48A3-BE3F-5A59B47D34AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 12 | {CC0964A8-655D-48A3-BE3F-5A59B47D34AF}.Debug|Any CPU.Build.0 = Debug|Any CPU 13 | {CC0964A8-655D-48A3-BE3F-5A59B47D34AF}.Release|Any CPU.ActiveCfg = Release|Any CPU 14 | {CC0964A8-655D-48A3-BE3F-5A59B47D34AF}.Release|Any CPU.Build.0 = Release|Any CPU 15 | EndGlobalSection 16 | EndGlobal 17 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/project.packagespec.json: -------------------------------------------------------------------------------- 1 | "restore":{"projectUniqueName":"/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj","projectName":"AoC_Day1","projectPath":"/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj","outputPath":"/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net6.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net6.0":{"targetAlias":"net6.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net6.0":{"targetAlias":"net6.0","imports":["net461","net462","net47","net471","net472","net48"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/usr/local/share/dotnet/sdk/6.0.100/RuntimeIdentifierGraph.json"}} -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/Debug/net6.0/AoC_Day1.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | //------------------------------------------------------------------------------ 9 | 10 | using System; 11 | using System.Reflection; 12 | 13 | [assembly: System.Reflection.AssemblyCompanyAttribute("AoC_Day1")] 14 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 15 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 16 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 17 | [assembly: System.Reflection.AssemblyProductAttribute("AoC_Day1")] 18 | [assembly: System.Reflection.AssemblyTitleAttribute("AoC_Day1")] 19 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 20 | 21 | // Generated by the MSBuild WriteCodeFragment class. 22 | 23 | -------------------------------------------------------------------------------- /src/day-02/solution.py: -------------------------------------------------------------------------------- 1 | from typing import List, Tuple 2 | 3 | 4 | def parse_line(line: str) -> Tuple[str, int]: 5 | name, x = line.strip().split(" ") 6 | return (name, int(x)) 7 | 8 | 9 | with open("input.txt") as f: 10 | input = list(map(parse_line, f.readlines())) 11 | 12 | 13 | def part1(commands: List[Tuple[str, int]]) -> int: 14 | pos = [0, 0] 15 | 16 | for name, amount in commands: 17 | if name == "forward": 18 | pos[0] += amount 19 | if name == "down": 20 | pos[1] += amount 21 | if name == "up": 22 | pos[1] -= amount 23 | 24 | return pos[0] * pos[1] 25 | 26 | 27 | def part2(commands: List[Tuple[str, int]]) -> int: 28 | pos = [0, 0, 0] 29 | 30 | for name, amount in commands: 31 | if name == "forward": 32 | pos[0] += amount 33 | pos[1] += amount * pos[2] 34 | if name == "down": 35 | pos[2] += amount 36 | if name == "up": 37 | pos[2] -= amount 38 | 39 | return pos[0] * pos[1] 40 | 41 | 42 | print(part1(input)) 43 | print(part2(input)) 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Kontur 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/day-06/src/main/java/ru/gnkoshelev/aoc/lanternfish/LanternfishCalculator.java: -------------------------------------------------------------------------------- 1 | package ru.gnkoshelev.aoc.lanternfish; 2 | 3 | import java.util.stream.Stream; 4 | 5 | /** 6 | * @author Gregory Koshelev 7 | */ 8 | public class LanternfishCalculator { 9 | public static void main(String[] args) { 10 | //String input = "4,1,3,2,4,3,1,4,4,1,1,1,5,2,4,4,2,1,2,3,4,1,2,4,3,4,5,1,1,3,1,2,1,4,1,1,3,4,1,2,5,1,4,2,2,1,1,1,3,1,5,3,1,2,1,1,1,1,4,1,1,1,2,2,1,3,1,3,1,3,4,5,1,2,2,1,1,1,4,1,5,1,3,1,3,4,1,3,2,3,4,4,4,3,4,5,1,3,1,3,5,1,1,1,1,1,2,4,1,2,1,1,1,5,1,1,2,1,3,1,4,2,3,4,4,3,1,1,3,5,3,1,1,5,2,4,1,1,3,5,1,4,3,1,1,4,2,1,1,1,1,1,1,3,1,1,1,1,1,4,5,1,2,5,3,1,1,3,1,1,1,1,5,1,2,5,1,1,1,1,1,1,3,5,1,3,2,1,1,1,1,1,1,1,4,5,1,1,3,1,5,1,1,1,1,3,3,1,1,1,4,4,1,1,4,1,2,1,4,4,1,1,3,4,3,5,4,1,1,4,1,3,1,1,5,5,1,2,1,2,1,2,3,1,1,3,1,1,2,1,1,3,4,3,1,1,3,3,5,1,2,1,4,1,1,2,1,3,1,1,1,1,1,1,1,4,5,5,1,1,1,4,1,1,1,2,1,2,1,3,1,3,1,1,1,1,1,1,1,5"; 11 | String input = "3,4,3,1,2"; 12 | int[] counters = Stream.of(input.split(",")).mapToInt(Integer::parseInt).toArray(); 13 | System.out.println(new TickerAlgorithm().compute(counters, 80)); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/day-06/src/main/java/ru/gnkoshelev/aoc/lanternfish/TickerAlgorithm.java: -------------------------------------------------------------------------------- 1 | package ru.gnkoshelev.aoc.lanternfish; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * @author Gregory Koshelev 7 | */ 8 | public class TickerAlgorithm implements Algorithm { 9 | @Override 10 | public long compute(int[] counters, int days) { 11 | for (int d = 0; d < days; d++) { 12 | int newLanternfish = 0; 13 | for (int c : counters) { 14 | if (c == 0) { 15 | newLanternfish++; 16 | } 17 | } 18 | int[] nextCounters = new int[counters.length + newLanternfish]; 19 | int i = 0; 20 | while (i < counters.length) { 21 | int counter = counters[i] - 1; 22 | nextCounters[i] = counter < 0 ? Lanternfish.REPRODUCING_INTERVAL_DAYS - 1 : counter; 23 | i++; 24 | } 25 | Arrays.fill(nextCounters, i, nextCounters.length, Lanternfish.REPRODUCTIVE_AGE_DAYS - 1); 26 | 27 | counters = nextCounters; 28 | } 29 | 30 | return counters.length; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/day-06/README.md: -------------------------------------------------------------------------------- 1 | `X(n)` – количество рыбок, воспроизведённых из одной рыбки по прошествии `n` дней. 2 | Иначе говоря, `X(n)` — количество всех потомков первой рыбки. 3 | Предполагается, что "счётчик" у рыбки в нулевой день равен `0`. 4 | 5 | Таким образом, 6 | - `X(0) = 0` (рыбка готова к воспроизведению, счётчик равен `0`) 7 | - `X(1) = 1` (рыбка воспроизвела на свет ещё одну рыбку, счётчик равен `6`, у второй рыбки — `8`) 8 | - `X(2) = 1` (значения счётчиков: `[5, 7]`) 9 | - `X(3) = 1` (значения счётчиков: `[4, 6]`) 10 | - `X(4) = 1` (значения счётчиков: `[3, 5]`) 11 | - `X(5) = 1` (значения счётчиков: `[2, 4]`) 12 | - `X(6) = 1` (значения счётчиков: `[1, 3]`) 13 | - `X(7) = 1` (первая рыбка готова к воспроизведению, значения счётчиков: `[0, 2]`) 14 | - `X(8) = 2` (первая рыбка воспроизвела на свет ещё одну рыбку, значения счётчиков: `[6, 1, 8]`) 15 | - `X(9) = 2` (вторая рыбка готова к воспроизведению, значения счётчиков: `[5, 0, 7]`) 16 | - `X(10) = 3` (вторая рыбка воспроизвела на свет ещё одну рыбку, значения счётчиков: `[4, 6, 6, 8]`). 17 | 18 | В общем виде справедливо рекуррентное соотношение: 19 | ``` 20 | X(n) = 1 + X(n-7) + X(n-9), для n ≥ 9 21 | ``` 22 | -------------------------------------------------------------------------------- /src/day-07/07-crabs.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | inp = np.loadtxt('07.txt', delimiter=',', dtype=int) 4 | 5 | # Part 1 6 | x = int(np.median(inp)) 7 | delta = abs(inp - x) 8 | print('Part One', delta.sum()) 9 | 10 | 11 | # Part 2 12 | # 13 | # $$f = \sum_{i=1..n} \frac{|x_i - x|(|x_i - x| + 1)}{2} = $$ 14 | # $$= \frac{1}{2}\sum_{i=1..n} (x_i - x)^2 + \frac{1}{2}\sum_{i=1..n} |x_i - x| =$$ 15 | # $$= \frac{1}{2}\sum_{i=1..n} (x_i - x)^2 + \frac{1}{2}\sum_{i=1..n, x_i > x} (x_i - x) + \frac{1}{2}\sum_{i=1..n, x_i \le x} (x - x_i)$$ 16 | # $$ f'(x) = 0$$ 17 | # $$ f'(x) = \frac{1}{2} \sum_{i=1..n} (x_i^2 - 2 x_i x + x^2)' - \frac{m}{2} + \frac{n-m}{2} = $$ 18 | # $$ = \sum_{i=1..n} (- x_i + x) - \frac{2m - n}{2} = $$ 19 | # $$ = x n - \sum_{i=1..n} x_i - n \epsilon, \; \epsilon \in [-0.5 .. 0.5]$$ 20 | # $$ f'(x) = 0 $$ 21 | # $$ x = \frac{1}{n} \sum_{i=1..n} x_i + \epsilon $$ 22 | # 23 | # https://www.overleaf.com/read/jkmrbmfpqqrf 24 | 25 | candidates = [] 26 | for dx in [-1, 0, 1]: 27 | x = np.mean(inp) + dx 28 | delta = abs(inp - x).round().astype(int) 29 | candidates.append((delta * (delta + 1) // 2).sum()) 30 | 31 | print('Part Two', min(candidates)) 32 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/AoC_Day1.csproj.nuget.g.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | True 5 | NuGet 6 | $(MSBuildThisFileDirectory)project.assets.json 7 | /Users/nevoroman/.nuget/packages/ 8 | /Users/nevoroman/.nuget/packages/ 9 | PackageReference 10 | 6.0.0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/day-05/src/main.rs: -------------------------------------------------------------------------------- 1 | use itertools::Itertools; 2 | use std::collections::HashMap; 3 | 4 | type Vent = (i32, i32, i32, i32); 5 | 6 | fn main() { 7 | let vents = include_str!("in") 8 | .lines() 9 | .map(parse) 10 | .collect::>(); 11 | 12 | dbg!(part1(&vents)); 13 | dbg!(part2(&vents)); 14 | } 15 | 16 | fn parse(line: &str) -> Vent { 17 | line.split(" -> ") 18 | .flat_map(|s| s.split(",")) 19 | .map(|i| i.parse().unwrap()) 20 | .collect_tuple() 21 | .unwrap() 22 | } 23 | 24 | fn part1(vents: &[Vent]) -> usize { 25 | let no_daigonals = vents 26 | .iter() 27 | .copied() 28 | .filter(|(x1, y1, x2, y2)| x1 == x2 || y1 == y2); 29 | count_intersections(no_daigonals) 30 | } 31 | 32 | fn part2(vents: &[Vent]) -> usize { 33 | count_intersections(vents.iter().copied()) 34 | } 35 | 36 | fn count_intersections(vents: Vents) -> usize 37 | where 38 | Vents: Iterator, 39 | { 40 | let mut points = HashMap::new(); 41 | for (x1, y1, x2, y2) in vents { 42 | let dx = (x2 - x1).signum(); 43 | let dy = (y2 - y1).signum(); 44 | let mut x = x1; 45 | let mut y = y1; 46 | while (x, y) != (x2 + dx, y2 + dy) { 47 | *points.entry((x, y)).or_insert(0) += 1; 48 | x += dx; 49 | y += dy; 50 | } 51 | } 52 | points.values().filter(|&&n| n > 1).count() 53 | } 54 | -------------------------------------------------------------------------------- /src/day-10/day10.py: -------------------------------------------------------------------------------- 1 | # Solution to Advent Of Code 2021, Day 10. 2 | # 3 | 4 | # Reading input lines. 5 | lines = open('prod_input.txt').read().split('\n') 6 | 7 | # Mapping opening parenthesis to closing parenthesis. 8 | couple = { 9 | ')': '(', 10 | ']': '[', 11 | '}': '{', 12 | '>': '<'} 13 | opens = set(couple.values()) 14 | 15 | # Score for corrupted symbols. 16 | corruption_score_map = { 17 | ')': 3, 18 | ']': 57, 19 | '}': 1197, 20 | '>': 25137} 21 | 22 | # Score for completion of each symbol. 23 | completion_score_map = { 24 | '(': 1, 25 | '[': 2, 26 | '{': 3, 27 | '<': 4} 28 | 29 | corruption_total_score = 0 30 | completion_scores = [] 31 | 32 | for line in lines: 33 | state = [] 34 | for c in line: 35 | if c in opens: 36 | state.append(c) 37 | else: # We have a closing parenthesis. 38 | if len(state) > 0 and state[-1] == couple[c]: 39 | state.pop() 40 | else: 41 | # Corrupting parenthesis found. 42 | corruption_total_score += corruption_score_map[c] 43 | break 44 | else: 45 | completion_score = 0 46 | for s in reversed(state): 47 | completion_score = completion_score * 5 + completion_score_map[s] 48 | completion_scores.append(completion_score) 49 | 50 | def Middle(l): 51 | return list(sorted(l))[len(l) // 2] 52 | 53 | print('Total corruption score:', corruption_total_score) 54 | print('Total completion score:', Middle(completion_scores)) 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/day-06/src/main/java/ru/gnkoshelev/aoc/lanternfish/RecurrentAlgorithm.java: -------------------------------------------------------------------------------- 1 | package ru.gnkoshelev.aoc.lanternfish; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author Gregory Koshelev 8 | */ 9 | public class RecurrentAlgorithm implements Algorithm { 10 | private final List reproducedByDays = new ArrayList<>(257); 11 | 12 | { 13 | reproducedByDays.add(0L); 14 | reproducedByDays.add(1L); 15 | reproducedByDays.add(1L); 16 | reproducedByDays.add(1L); 17 | reproducedByDays.add(1L); 18 | reproducedByDays.add(1L); 19 | reproducedByDays.add(1L); 20 | reproducedByDays.add(1L); 21 | reproducedByDays.add(2L); 22 | } 23 | 24 | @Override 25 | public long compute(int[] counters, int days) { 26 | long count = counters.length; 27 | for (int c : counters) { 28 | if (c > days) { 29 | continue; 30 | } 31 | count += reproducedForDays(days - c); 32 | } 33 | return count; 34 | } 35 | 36 | private long reproducedForDays(int days) { 37 | if (reproducedByDays.size() <= days) { 38 | int start = reproducedByDays.size(); 39 | for (int i = start; i <= days; i++) { 40 | reproducedByDays.add(1 + 41 | reproducedByDays.get(i - Lanternfish.REPRODUCING_INTERVAL_DAYS) + 42 | reproducedByDays.get(i - Lanternfish.REPRODUCTIVE_AGE_DAYS)); 43 | } 44 | } 45 | 46 | return reproducedByDays.get(days); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/day-06/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | ru.gnkoshelev.aoc 8 | lanternfish 9 | 1.0.0 10 | 11 | 12 | 11 13 | 11 14 | 15 | 16 | 17 | 18 | 19 | org.junit 20 | junit-bom 21 | 5.8.2 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.junit.jupiter 31 | junit-jupiter 32 | test 33 | 34 | 35 | 36 | 37 | 38 | 39 | maven-compiler-plugin 40 | 3.8.1 41 | 42 | 43 | maven-surefire-plugin 44 | 2.22.2 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/project.assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "targets": { 4 | "net6.0": {} 5 | }, 6 | "libraries": {}, 7 | "projectFileDependencyGroups": { 8 | "net6.0": [] 9 | }, 10 | "packageFolders": { 11 | "/Users/nevoroman/.nuget/packages/": {} 12 | }, 13 | "project": { 14 | "version": "1.0.0", 15 | "restore": { 16 | "projectUniqueName": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj", 17 | "projectName": "AoC_Day1", 18 | "projectPath": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj", 19 | "packagesPath": "/Users/nevoroman/.nuget/packages/", 20 | "outputPath": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/obj/", 21 | "projectStyle": "PackageReference", 22 | "configFilePaths": [ 23 | "/Users/nevoroman/.nuget/NuGet/NuGet.Config" 24 | ], 25 | "originalTargetFrameworks": [ 26 | "net6.0" 27 | ], 28 | "sources": { 29 | "https://api.nuget.org/v3/index.json": {} 30 | }, 31 | "frameworks": { 32 | "net6.0": { 33 | "targetAlias": "net6.0", 34 | "projectReferences": {} 35 | } 36 | }, 37 | "warningProperties": { 38 | "warnAsError": [ 39 | "NU1605" 40 | ] 41 | } 42 | }, 43 | "frameworks": { 44 | "net6.0": { 45 | "targetAlias": "net6.0", 46 | "imports": [ 47 | "net461", 48 | "net462", 49 | "net47", 50 | "net471", 51 | "net472", 52 | "net48" 53 | ], 54 | "assetTargetFallback": true, 55 | "warn": true, 56 | "frameworkReferences": { 57 | "Microsoft.NETCore.App": { 58 | "privateAssets": "all" 59 | } 60 | }, 61 | "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/6.0.100/RuntimeIdentifierGraph.json" 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /src/day-01/AoC_Day1/obj/AoC_Day1.csproj.nuget.dgspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "format": 1, 3 | "restore": { 4 | "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj": {} 5 | }, 6 | "projects": { 7 | "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj": { 8 | "version": "1.0.0", 9 | "restore": { 10 | "projectUniqueName": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj", 11 | "projectName": "AoC_Day1", 12 | "projectPath": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/AoC_Day1.csproj", 13 | "packagesPath": "/Users/nevoroman/.nuget/packages/", 14 | "outputPath": "/Users/nevoroman/dev/AoC2021/src/day-01/AoC_Day1/obj/", 15 | "projectStyle": "PackageReference", 16 | "configFilePaths": [ 17 | "/Users/nevoroman/.nuget/NuGet/NuGet.Config" 18 | ], 19 | "originalTargetFrameworks": [ 20 | "net6.0" 21 | ], 22 | "sources": { 23 | "https://api.nuget.org/v3/index.json": {} 24 | }, 25 | "frameworks": { 26 | "net6.0": { 27 | "targetAlias": "net6.0", 28 | "projectReferences": {} 29 | } 30 | }, 31 | "warningProperties": { 32 | "warnAsError": [ 33 | "NU1605" 34 | ] 35 | } 36 | }, 37 | "frameworks": { 38 | "net6.0": { 39 | "targetAlias": "net6.0", 40 | "imports": [ 41 | "net461", 42 | "net462", 43 | "net47", 44 | "net471", 45 | "net472", 46 | "net48" 47 | ], 48 | "assetTargetFallback": true, 49 | "warn": true, 50 | "frameworkReferences": { 51 | "Microsoft.NETCore.App": { 52 | "privateAssets": "all" 53 | } 54 | }, 55 | "runtimeIdentifierGraphPath": "/usr/local/share/dotnet/sdk/6.0.100/RuntimeIdentifierGraph.json" 56 | } 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AoC2021 2 | 3 | [Advent of Code 2021](https://adventofcode.com/2021) solutions from our community. 4 | 5 | Puzzle solutions are located in the `src` directory, separated by day and part. 6 | 7 | [Telegram-channel](https://t.me/konturAoC2021) 8 | [Telegram-chat](https://t.me/konturAoC2021_chat) 9 | [YouTube Channel](https://www.youtube.com/c/KonturTech) 10 | 11 | ## Our journey (videos in Russian) 12 | 13 | 1. [Day 1](https://youtu.be/6i7jm8W0Aic), C# 14 | 2. [Day 2](https://youtu.be/IeTh8WQ5qYU), Python 15 | 3. [Day 3](https://youtu.be/9iRd2tGbOcE), JS 16 | 4. [Day 4](https://youtu.be/JcVwLp9Nv4k), 1С 17 | 5. [Day 5](https://youtu.be/wBaR6XcoYWM), Rust 18 | 6. [Day 6](https://youtu.be/XNAkYQjttYM), Java 19 | 7. [Day 7](https://youtu.be/6zKZ_L5ynzk), Python + numpy 20 | 8. [Day 8](https://youtu.be/TzCuFI1jZrA), JS + Copilot 21 | 9. [Day 9](https://youtu.be/SI4iFdw1W3g), Go 22 | 10. [Day 10](https://youtu.be/fW_EgB-DDFM), Logica + Python 23 | 11. [Day 11](https://youtu.be/GrUkAVovk4U), Clojure 24 | 12. [Day 12](https://youtu.be/NUovaPGYaHg), C++ 25 | 13. [Day 13](https://youtu.be/OTFNP00g0P8), Scala 26 | 27 | ## Santa's nice list 28 | 29 | - [Aminopyridin](https://github.com/Aminopyridin/AoC2021) [C#] 30 | - [nulladdict](https://github.com/nulladdict/aoc-2021) [Rust] 31 | - [mazharenko](https://github.com/mazharenko/AoC-2021) [F#] 32 | - [reacheight](https://github.com/reacheight/AdventOfCode) [Scala] 33 | - [Решения на Python и обзоры reddit-а от xoposhiy](https://github.com/xoposhiy/aoc/) [Python] 34 | - [BurningMarshmallow](https://github.com/BurningMarshmallow/aoc-2021) [Kotlin] 35 | - [yalexaner](https://github.com/yalexaner/advent-of-code-2021-go) [Go] 36 | - [AxelUser](https://github.com/AxelUser/aoc-2021) [Kotlin] 37 | - [nanot1m](https://github.com/nanot1m/adventofcode2021) [JS] 38 | - [RazDva](https://github.com/Razdva122/Advent-of-code-2021) [TS] 39 | - [ulysses4ever](https://github.com/ulysses4ever/adventofcode) [Haskell] 40 | - [g0rd1](https://github.com/g0rd1/advent-of-code-2021) [Kotlin] 41 | - [vanawy](https://github.com/Vanawy/advent-of-code-2021) [C] 42 | - [BurlakovNick](https://github.com/BurlakovNick/aoc-2021) [Clojure] 43 | -------------------------------------------------------------------------------- /src/day-11/core.clj: -------------------------------------------------------------------------------- 1 | (ns day_11.core) 2 | 3 | (defn sum [sequence] (reduce + sequence)) 4 | 5 | (defn slurp-strings 6 | [filename] 7 | (as-> (slurp (clojure.java.io/resource filename)) $ 8 | (clojure.string/split $ #"\n"))) 9 | 10 | (defn is-in? [coll item] (some #{item} coll)) 11 | 12 | (defn ch->int [x] (Character/digit x 10)) 13 | (defn int->ch [x] (Character/forDigit x 10)) 14 | 15 | "Parsing" 16 | (def coords (for [x (range 10) y (range 10)] [x y])) 17 | (defn parse-level [lines p] (ch->int (get-in lines p))) 18 | 19 | (defn parse [] 20 | (let [lines (slurp-strings "day11.txt")] 21 | (into {} (mapv (fn [p] [p (parse-level lines p)]) coords)))) 22 | 23 | "For debugging" 24 | (defn map->str [m] (mapv (partial apply str) (partition 10 (mapv int->ch (mapv (parse) coords))))) 25 | 26 | "Helpers" 27 | (defn inside? [[x y]] (and (>= x 0) (< x 10) (>= y 0) (< y 10))) 28 | 29 | (defn grid-neighbors [p] 30 | (->> [[0 -1] [0 1] [-1 0] [1 0] [-1 -1] [-1 1] [1 -1] [1 1]] 31 | (mapv #(mapv + p %)) 32 | (filterv inside?))) 33 | 34 | (defn zero-level [m p] (assoc m p 0)) 35 | (defn inc-level [m p] (update m p inc)) 36 | (defn inc-neighbors [m p] (reduce inc-level m (grid-neighbors p))) 37 | (defn inc-levels [m] (reduce inc-level m coords)) 38 | (defn flashes [m] (filterv #(> (m %) 9) coords)) 39 | (defn flash-to-zero [m] (reduce zero-level m (flashes m))) 40 | 41 | "The meat" 42 | (defn sim [args] 43 | (let [m (:map args) 44 | inced (inc-levels m)] 45 | (loop [visited [] 46 | result inced 47 | flashes-count 0] 48 | (let [flash (first (filterv #(not (is-in? visited %)) (flashes result)))] 49 | (if (some? flash) 50 | (let [visited' (conj visited flash) 51 | result' (inc-neighbors result flash)] 52 | (recur visited' result' (inc flashes-count))) 53 | {:map (flash-to-zero result), :flashes flashes-count}))))) 54 | 55 | (def iterations (iterate sim {:map (parse) :flashes 0})) 56 | 57 | "Easy" 58 | (println (sum (mapv :flashes (take 101 iterations)))) 59 | 60 | "Hard" 61 | (println (count (take-while #(not= (:flashes %) 100) iterations))) 62 | -------------------------------------------------------------------------------- /src/day-03/part2.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const inputLines = fs.readFileSync("./input.txt", "utf-8").split("\r\n"); 3 | 4 | const bitsCount = inputLines[0].length; 5 | const tree = buildTree(inputLines); 6 | 7 | const oxygenRatingDigits = []; 8 | const co2RatingDigits = []; 9 | 10 | let currentVertex = tree; 11 | while (currentVertex.oneCount || currentVertex.zeroCount) { 12 | let bit; 13 | if (currentVertex.oneCount && !currentVertex.zeroCount) { 14 | bit = 1; 15 | } else if (currentVertex.zeroCount && !currentVertex.oneCount) { 16 | bit = 0; 17 | } else { 18 | bit = currentVertex.oneCount >= currentVertex.zeroCount ? 1 : 0; 19 | } 20 | oxygenRatingDigits.push(bit); 21 | currentVertex = bit == 1 ? currentVertex.oneVertex : currentVertex.zeroVertex; 22 | } 23 | 24 | currentVertex = tree; 25 | while (currentVertex.oneCount || currentVertex.zeroCount) { 26 | let bit; 27 | if (currentVertex.oneCount && !currentVertex.zeroCount) { 28 | bit = 1; 29 | } else if (currentVertex.zeroCount && !currentVertex.oneCount) { 30 | bit = 0; 31 | } else { 32 | bit = currentVertex.zeroCount <= currentVertex.oneCount ? 0 : 1; 33 | } 34 | co2RatingDigits.push(bit); 35 | currentVertex = bit == 1 ? currentVertex.oneVertex : currentVertex.zeroVertex; 36 | } 37 | 38 | console.log( 39 | parseInt(oxygenRatingDigits.join(""), 2) * 40 | parseInt(co2RatingDigits.join(""), 2) 41 | ); 42 | 43 | function buildTree(lines) { 44 | const topVertex = { 45 | zeroCount: 0, 46 | oneCount: 0, 47 | zeroVertex: null, 48 | oneVertex: null, 49 | }; 50 | for (const line of inputLines) { 51 | let currentVertex = topVertex; 52 | for (let i = 0; i < bitsCount; i++) { 53 | const symbol = line[i]; 54 | if (symbol == 0) { 55 | currentVertex.zeroCount = currentVertex.zeroCount + 1 || 1; 56 | if (!currentVertex.zeroVertex) 57 | currentVertex.zeroVertex = { 58 | zeroCount: 0, 59 | oneCount: 0, 60 | }; 61 | currentVertex = currentVertex.zeroVertex; 62 | } else { 63 | currentVertex.oneCount = currentVertex.oneCount + 1 || 1; 64 | if (!currentVertex.oneVertex) 65 | currentVertex.oneVertex = { 66 | zeroCount: 0, 67 | oneCount: 0, 68 | }; 69 | currentVertex = currentVertex.oneVertex; 70 | } 71 | } 72 | } 73 | return topVertex; 74 | } 75 | -------------------------------------------------------------------------------- /src/day-06/src/test/java/ru/gnkoshelev/aoc/lanternfish/AlgorithmTest.java: -------------------------------------------------------------------------------- 1 | package ru.gnkoshelev.aoc.lanternfish; 2 | 3 | import org.junit.jupiter.params.ParameterizedTest; 4 | import org.junit.jupiter.params.provider.Arguments; 5 | import org.junit.jupiter.params.provider.MethodSource; 6 | 7 | import java.util.stream.Stream; 8 | 9 | import static org.junit.jupiter.api.Assertions.assertEquals; 10 | 11 | /** 12 | * @author Gregory Koshelev 13 | */ 14 | public class AlgorithmTest { 15 | private static final Algorithm algorithm = new TickerAlgorithm(); 16 | 17 | private static Stream args() { 18 | return Stream.of( 19 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{3, 4, 3, 1, 2}, 0), 20 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{2, 3, 2, 0, 1}, 1), 21 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{1, 2, 1, 6, 0, 8}, 2), 22 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{0, 1, 0, 5, 6, 7, 8}, 3), 23 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{6, 0, 6, 4, 5, 6, 7, 8, 8}, 4), 24 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{5, 6, 5, 3, 4, 5, 6, 7, 7, 8}, 5), 25 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{4, 5, 4, 2, 3, 4, 5, 6, 6, 7}, 6), 26 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{3, 4, 3, 1, 2, 3, 4, 5, 5, 6}, 7), 27 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{2, 3, 2, 0, 1, 2, 3, 4, 4, 5}, 8), 28 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{1, 2, 1, 6, 0, 1, 2, 3, 3, 4, 8}, 9), 29 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{0, 1, 0, 5, 6, 0, 1, 2, 2, 3, 7, 8}, 10), 30 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{6, 0, 6, 4, 5, 6, 0, 1, 1, 2, 6, 7, 8, 8, 8}, 11), 31 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{5, 6, 5, 3, 4, 5, 6, 0, 0, 1, 5, 6, 7, 7, 7, 8, 8}, 12), 32 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{4, 5, 4, 2, 3, 4, 5, 6, 6, 0, 4, 5, 6, 6, 6, 7, 7, 8, 8}, 13), 33 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{3, 4, 3, 1, 2, 3, 4, 5, 5, 6, 3, 4, 5, 5, 5, 6, 6, 7, 7, 8}, 14), 34 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{2, 3, 2, 0, 1, 2, 3, 4, 4, 5, 2, 3, 4, 4, 4, 5, 5, 6, 6, 7}, 15), 35 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{1, 2, 1, 6, 0, 1, 2, 3, 3, 4, 1, 2, 3, 3, 3, 4, 4, 5, 5, 6, 8}, 16), 36 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{0, 1, 0, 5, 6, 0, 1, 2, 2, 3, 0, 1, 2, 2, 2, 3, 3, 4, 4, 5, 7, 8}, 17), 37 | Arguments.of(new int[]{3, 4, 3, 1, 2}, new int[]{6, 0, 6, 4, 5, 6, 0, 1, 1, 2, 6, 0, 1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 8, 8, 8, 8}, 18) 38 | ); 39 | } 40 | 41 | @ParameterizedTest 42 | @MethodSource("args") 43 | public void test(int[] source, int[] result, int days) { 44 | assertEquals(result.length, algorithm.compute(source, days)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/day-14/Day14.kt: -------------------------------------------------------------------------------- 1 | fun main() { 2 | fun parseInput(input: List): Pair> { 3 | val source = input.first() 4 | val replacements = input 5 | .filter { it.contains("->") } 6 | .map { it.split(" -> ") } 7 | .associate { (a, b) -> a to b } 8 | return Pair(source, replacements) 9 | } 10 | 11 | fun part1(input: List, iterations: Int): Int { 12 | val (source, replacements) = parseInput(input) 13 | val freqs = (0 until iterations) 14 | .fold(source) { it, _ -> 15 | it 16 | .windowed(2, partialWindows = true) { 17 | if (it.length == 2) 18 | "${it[0]}${replacements[it.toString()]}" 19 | else it 20 | } 21 | .joinToString("") 22 | } 23 | .groupingBy { it } 24 | .eachCount() 25 | .values 26 | val max = freqs.maxOf { it } 27 | val min = freqs.minOf { it } 28 | return max - min 29 | } 30 | 31 | fun countPairs(source: String): Map { 32 | return source 33 | .windowed(2) { it.toString() } 34 | .groupingBy { it } 35 | .eachCount() 36 | .mapValues { it.value.toLong() } 37 | } 38 | 39 | fun part2(input: List, iterations: Int): Long { 40 | val (source, replacements) = parseInput(input) 41 | val freqs = (0 until iterations) 42 | .fold(countPairs(source)) { map, _ -> 43 | map 44 | .flatMap { (symbolPair, count) -> 45 | val newChar = replacements[symbolPair]!! 46 | val fst = symbolPair[0] + newChar 47 | val snd = newChar + symbolPair[1] 48 | listOf(fst to count, snd to count) 49 | } 50 | .groupBy { it.first } 51 | .mapValues { (_, counts) -> counts.sumOf { it.second } } 52 | } 53 | .flatMap { (pair, count) -> pair.map { it to count } } 54 | .groupBy { (char, _) -> char } 55 | .mapValues { (_, listCounts) -> listCounts.sumOf { (_, count) -> count } } 56 | .mapValues { (char, count) -> 57 | if (char == source.first() || char == source.last()) (count + 1) / 2 58 | else count / 2 59 | } 60 | .values 61 | val max = freqs.maxOf { it } 62 | val min = freqs.minOf { it } 63 | return max - min 64 | } 65 | 66 | // test if implementation meets criteria from the description, like: 67 | val testInput = readInput("Day14_test") 68 | check(part1(testInput, 10) == 1588) 69 | println(part1(testInput, 10)) 70 | println(part2(testInput, 10)) 71 | 72 | val input = readInput("Day14") 73 | println(part1(input, 10)) 74 | println(part2(input, 10)) 75 | 76 | println(part2(input, 40)) 77 | } 78 | 79 | -------------------------------------------------------------------------------- /src/day-04/day04_1.os: -------------------------------------------------------------------------------- 1 | Перем Высота, Ширина; 2 | Перем Билеты, Номера; 3 | 4 | Функция ПрочитатьДанные() 5 | 6 | ЧтениеТекста = Новый ЧтениеТекста("input.txt"); 7 | 8 | Номера = СтрРазделить(ЧтениеТекста.ПрочитатьСтроку(), ","); 9 | Билеты = Новый Массив; 10 | 11 | Строка = ЧтениеТекста.ПрочитатьСтроку(); 12 | Пока Строка <> Неопределено Цикл 13 | 14 | Если Строка = "" Тогда 15 | 16 | Билет = Новый Массив; 17 | Билеты.Добавить(Билет); 18 | 19 | Иначе 20 | 21 | Строка = СокрЛП(СтрЗаменить(Строка, " ", " ")); 22 | Билет.Добавить(СтрРазделить(Строка, " ")); 23 | 24 | КонецЕсли; 25 | 26 | Строка = ЧтениеТекста.ПрочитатьСтроку(); 27 | 28 | КонецЦикла; 29 | 30 | ЧтениеТекста.Закрыть(); 31 | 32 | КонецФункции 33 | 34 | Функция ВыигралБилет(Билет, Номер) 35 | 36 | // Сначала вычеркнем номер 37 | 38 | Для Сч1 = 0 По Высота - 1 Цикл 39 | 40 | Для Сч2 = 0 По Ширина - 1 Цикл 41 | 42 | Если Билет[Сч1][Сч2] = Номер Тогда 43 | 44 | Билет[Сч1][Сч2] = Неопределено; 45 | 46 | КонецЕсли; 47 | 48 | КонецЦикла; 49 | 50 | КонецЦикла; 51 | 52 | Возврат ВыигралПоСтрокам(Билет) ИЛИ ВыигралПоСтолбцам(Билет); 53 | 54 | КонецФункции 55 | 56 | Функция ВыигралПоСтрокам(Билет) 57 | 58 | Для Сч1 = 0 По Высота - 1 Цикл 59 | 60 | Выигрыш = Истина; 61 | 62 | Для Сч2 = 0 По Ширина - 1 Цикл 63 | 64 | Если НЕ Билет[Сч1][Сч2] = Неопределено Тогда 65 | 66 | Выигрыш = Ложь; 67 | Прервать; 68 | 69 | КонецЕсли; 70 | 71 | КонецЦикла; 72 | 73 | Если Выигрыш Тогда 74 | 75 | Возврат Истина; 76 | 77 | КонецЕсли; 78 | 79 | КонецЦикла; 80 | 81 | Возврат Ложь; 82 | 83 | КонецФункции 84 | 85 | Функция ВыигралПоСтолбцам(Билет) 86 | 87 | Для Сч1 = 0 По Ширина - 1 Цикл 88 | 89 | Выигрыш = Истина; 90 | 91 | Для Сч2 = 0 По Высота - 1 Цикл 92 | 93 | Если НЕ Билет[Сч2][Сч1] = Неопределено Тогда 94 | 95 | Выигрыш = Ложь; 96 | Прервать; 97 | 98 | КонецЕсли; 99 | 100 | КонецЦикла; 101 | 102 | Если Выигрыш Тогда 103 | 104 | Возврат Истина; 105 | 106 | КонецЕсли; 107 | 108 | КонецЦикла; 109 | 110 | Возврат Ложь; 111 | 112 | КонецФункции 113 | 114 | Функция СуммаБилета(Билет) 115 | Сумма = 0; 116 | 117 | Для Сч1 = 0 По Высота - 1 Цикл 118 | 119 | Для Сч2 = 0 По Ширина - 1 Цикл 120 | 121 | Если Не Билет[Сч1][Сч2] = Неопределено Тогда 122 | 123 | Сумма = Сумма + Число(Билет[Сч1][Сч2]); 124 | 125 | КонецЕсли; 126 | 127 | КонецЦикла; 128 | 129 | КонецЦикла; 130 | 131 | Возврат Сумма; 132 | 133 | КонецФункции 134 | 135 | Высота = 5; 136 | Ширина = 5; 137 | 138 | ПрочитатьДанные(); 139 | 140 | ЕстьВыигрыш = Ложь; 141 | Для Каждого Номер Из Номера Цикл 142 | 143 | Для Каждого Билет Из Билеты Цикл 144 | 145 | Если ВыигралБилет(Билет, Номер) Тогда 146 | 147 | Сообщить(СуммаБилета(Билет) * Число(Номер)); 148 | ЕстьВыигрыш = Истина; 149 | Прервать; 150 | 151 | КонецЕсли; 152 | 153 | КонецЦикла; 154 | Если ЕстьВыигрыш Тогда 155 | 156 | Прервать; 157 | 158 | КонецЕсли; 159 | 160 | КонецЦикла; 161 | -------------------------------------------------------------------------------- /src/day-04/day04_2.os: -------------------------------------------------------------------------------- 1 | Перем Высота, Ширина; 2 | 3 | Функция ВыигралПоСтрокам(Билет) 4 | 5 | Для Сч1 = 0 По Высота - 1 Цикл 6 | 7 | Выигрыш = Истина; 8 | 9 | Для Сч2 = 0 По Ширина - 1 Цикл 10 | 11 | Если НЕ Билет[Сч1][Сч2] = Неопределено Тогда 12 | 13 | Выигрыш = Ложь; 14 | Прервать; 15 | 16 | КонецЕсли; 17 | 18 | КонецЦикла; 19 | 20 | Если Выигрыш Тогда 21 | 22 | Возврат Истина; 23 | 24 | КонецЕсли; 25 | 26 | КонецЦикла; 27 | 28 | Возврат Ложь; 29 | 30 | КонецФункции 31 | 32 | Функция ВыигралПоСтолбцам(Билет) 33 | 34 | Для Сч1 = 0 По Ширина - 1 Цикл 35 | 36 | Выигрыш = Истина; 37 | 38 | Для Сч2 = 0 По Высота - 1 Цикл 39 | 40 | Если НЕ Билет[Сч2][Сч1] = Неопределено Тогда 41 | 42 | Выигрыш = Ложь; 43 | Прервать; 44 | 45 | КонецЕсли; 46 | 47 | КонецЦикла; 48 | 49 | Если Выигрыш Тогда 50 | 51 | Возврат Истина; 52 | 53 | КонецЕсли; 54 | 55 | КонецЦикла; 56 | 57 | Возврат Ложь; 58 | 59 | КонецФункции 60 | 61 | Функция ВыигралБилет(Билет, Номер) 62 | 63 | // Сначала вычеркнем номер 64 | 65 | Для Сч1 = 0 По Высота - 1 Цикл 66 | 67 | Для Сч2 = 0 По Ширина - 1 Цикл 68 | 69 | Если Билет[Сч1][Сч2] = Номер Тогда 70 | 71 | Билет[Сч1][Сч2] = Неопределено; 72 | 73 | КонецЕсли; 74 | 75 | КонецЦикла; 76 | 77 | КонецЦикла; 78 | 79 | Возврат ВыигралПоСтрокам(Билет) ИЛИ ВыигралПоСтолбцам(Билет); 80 | 81 | КонецФункции 82 | 83 | Функция СуммаБилета(Билет) 84 | Сумма = 0; 85 | 86 | Для Сч1 = 0 По Высота - 1 Цикл 87 | 88 | Для Сч2 = 0 По Ширина - 1 Цикл 89 | 90 | Если Не Билет[Сч1][Сч2] = Неопределено Тогда 91 | 92 | Сумма = Сумма + Число(Билет[Сч1][Сч2]); 93 | 94 | КонецЕсли; 95 | 96 | КонецЦикла; 97 | 98 | КонецЦикла; 99 | 100 | Возврат Сумма; 101 | 102 | КонецФункции 103 | 104 | Высота = 5; 105 | Ширина = 5; 106 | 107 | ЧтениеТекста = Новый ЧтениеТекста("input.txt"); 108 | 109 | Числа = СтрРазделить(ЧтениеТекста.ПрочитатьСтроку(), ","); 110 | 111 | Билеты = Новый Массив; 112 | 113 | Строка = ЧтениеТекста.ПрочитатьСтроку(); 114 | Пока Строка <> Неопределено Цикл 115 | 116 | Если Строка = "" Тогда 117 | 118 | Билет = Новый Массив; 119 | Билеты.Добавить(Билет); 120 | 121 | Иначе 122 | 123 | Строка = СокрЛП(СтрЗаменить(Строка, " ", " ")); 124 | Билет.Добавить(СтрРазделить(Строка, " ")); 125 | 126 | КонецЕсли; 127 | 128 | Строка = ЧтениеТекста.ПрочитатьСтроку(); 129 | 130 | КонецЦикла; 131 | 132 | ЧтениеТекста.Закрыть(); 133 | 134 | ПоследнийБилет = Неопределено; 135 | ПоследнийНомер = Неопределено; 136 | БилетыКУдалению = Новый Массив; 137 | 138 | Для Каждого Номер Из Числа Цикл 139 | 140 | Для СчетчикБилетов = 0 По Билеты.Количество() - 1 Цикл 141 | 142 | Билет = Билеты[СчетчикБилетов]; 143 | Если ВыигралБилет(Билет, Номер) Тогда 144 | 145 | ПоследнийБилет = Билет; 146 | ПоследнийНомер = Номер; 147 | БилетыКУдалению.Вставить(0, СчетчикБилетов); 148 | 149 | КонецЕсли; 150 | 151 | КонецЦикла; 152 | 153 | Для Каждого КУдалению Из БилетыКУдалению Цикл 154 | 155 | Билеты.Удалить(КУдалению); 156 | 157 | КонецЦикла; 158 | БилетыКУдалению.Очистить(); 159 | 160 | КонецЦикла; 161 | 162 | Сообщить(СуммаБилета(ПоследнийБилет) * Число(ПоследнийНомер)); -------------------------------------------------------------------------------- /src/day-10/day10.l: -------------------------------------------------------------------------------- 1 | # Solution to Advent Of Code 2021 - Day 10, Part I only. 2 | # 3 | # To run this you need to install Logica language: 4 | # python3 -m pip install logica 5 | # Then you can run this as: 6 | # python3 -m logica day10.l run TotalCorruptionScore 7 | # 8 | # Written by Evgeny Skvortsov, 9 | # you can reach me at https://twitter.com/evgskvdev 10 | 11 | 12 | @Engine("sqlite"); 13 | 14 | # Uncomment for quick debugging: 15 | # Input() = "{([(<{}[<>[]}>{[]{[(<()>"; 16 | 17 | # Uncomment to read the test input: 18 | # Input() = ReadFile("test_input.txt"); 19 | 20 | # Production input: 21 | Input() = ReadFile("prod_input.txt"); 22 | 23 | # Reading the lines into database: 24 | @Ground(Line); 25 | Line(i) = line :- 26 | lines == Split(Input(), SqlExpr("char(10)", {})), 27 | i in Range(Size(lines)), 28 | line == Element(lines, i); 29 | 30 | # Mathing opening parenthesis to the closed parenthesis: 31 | Couple("{") = "}"; 32 | Couple("[") = "]"; 33 | Couple("<") = ">"; 34 | Couple("(") = ")"; 35 | 36 | # Using the mapping above to identify parenthesis that open and ones 37 | # that close. 38 | Opens(x) :- Couple(x); 39 | Closes(Couple()); 40 | 41 | # Simplest non-empty complete strings look like (), [], etc. 42 | Core() = a ++ Couple(a); 43 | 44 | # Convenience function extracting one character at a position. 45 | At(l, i) = Substr(l, i, 1); 46 | 47 | # Alright, let's solve the problem! 48 | 49 | # Identifying smallest non-empty complete strings in the input: 50 | CorePart(l, i, i + 1) :- 51 | l == Line(), 52 | i in Range(Length(l)), 53 | Substr(l, i, 2) == Core(); 54 | 55 | # Identifying complete substrings in the input strings: 56 | @Recursive(CompletePart, 10); 57 | @Ground(CompletePart); 58 | # Core substring is complete. 59 | CompletePart(l, i, j) :- CorePart(l, i, j); 60 | # Two complete substrings side-by-side form a complete string. 61 | CompletePart(l, i, k) :- 62 | CompletePart(l, i, j), 63 | CompletePart(l, j + 1, k); 64 | # A complete string enclosed in parenthesis is complete. 65 | CompletePart(l, i - 1, j + 1) :- 66 | CompletePart(l, i, j), 67 | Couple(At(l, i - 1)) == At(l, j + 1); 68 | 69 | # A predicate to show complete strings for debugging: 70 | @OrderBy(ShowComplete, "col1"); 71 | ShowComplete(l, i, j, p) :- 72 | CompletePart(l, i, j), 73 | p == Substr(l, i, j - i + 1); 74 | 75 | # Identifying corruption. 76 | # We have a corruption if we have a complete string, which is surrounded 77 | # by an open and a close parenthesis, while the closing parenthesis does not 78 | # match the open parenthesis. 79 | BadSign(l, j + 1) = At(l, j + 1) :- 80 | CompletePart(l, i, j), 81 | a == At(l, i - 1), 82 | b == At(l, j + 1), 83 | Opens(a), 84 | Closes(b), 85 | Couple(a) != b; 86 | 87 | # If a string starts with a complete string, followed by a closed parenthesis 88 | # then we have corruption. 89 | BadSign(l, j + 1) = At(l, j + 1) :- 90 | CompletePart(l, 1, j), 91 | b == At(l, j + 1), 92 | Closes(b); 93 | 94 | # Corruption score function. 95 | CorruptionScore(")") = 3; 96 | CorruptionScore("]") = 57; 97 | CorruptionScore("}") = 1197; 98 | CorruptionScore(">") = 25137; 99 | 100 | # Calculating total corruption score. 101 | TotalCorruptionScore() += CorruptionScore(BadSign()); 102 | 103 | -------------------------------------------------------------------------------- /src/day-07/07.txt: -------------------------------------------------------------------------------- 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,1247,39,529,198,497,33,1618,2,28,653,764,312,163,62,263,4,243,1277,8,432,324,564,44,56,745,0,534,558,1026,313,482,410,411,63,461,261,561,62,428,42,1806,251,1186,553,241,795,127,1004,94,183,382,194,890,1025,1153,1064,155,278,203,666,1098,678,228,12,530,226,680,476,74,122,136,64,515,630,137,187,146,249,77,879,1174,257,9,353,1496,239,131,21,330,922,110,5,804,2,1195,756,195,399,1306,1495,1088,687,102,901,222,3,717,853,1242,573,406,645,1211,193,319,35,302,677,704,42,69,228,247,420,401,1006,124,662,355,746,483,211,1484,146,104,314,154,170,932,215,1600,1250,20,134,1038,724,728,157,261,1373,1113,449,339,415,1165,172,956,466,327,1342,27,1031,1233,547,636,100,440,510,154,28,949,222,867,11,297,218,814,169,358,1088,1071,630,1360,1106,249,13,312,7,56,1667,948,69,767,279,1032,82,139,636,592,684,294,952,83,252,158,450,1250,78,548,1052,1,1231,888,253,533,637,694,955,448,1351,1569,1060,65,269,450,102,962,408,259,61,20,437,14,1676,16,533,90,1727,623,286,48,395,169,271,140,652,139,1497,356,98,60,362,964,880,934,544,140,322,428,80,215,192,300,431,126,46,109,780,209,776,203,443,60,889,21,882,22,127,476,694,174,226,1041,364,282,541,429,755,770,931,967,1346,1240,647,150,199,137,181,1177,571,150,1104,56,517,286,1204,346,619,1269,307,425,228,254,328,570,956,1567,810,356,196,77,31,429,1178,6,502,310,443,1221,119,571,583,18,256,460,694,650,799,200,121,119,125,894,1263,610,892,635,93,320,252,371,1416,150,664,154,344,381,610,819,591,536,1312,1521,148,1232,70,50,328,226,752,1685,729,449,31,963,402,62,1365,928,619,538,950,202,19,271,292,59,55,345,189,302,29,217,486,1576,62,1364,122,1667,388,62,182,1278,13,459,729,821,293,78,5,111,135,868,94,196,14,342,185,271,1055,350,363,235,137,142,31,30,466,922,436,1174,81,114,244,770,54,288,579,4,1287,36,321,849,751,1081,342,359,829,1147,1092,125,269,1652,493,22,456,193,49,70,288,4,954,1718,84,154,24,171,220,1033,66,289,395,1732,1553,616,411,899,1398,402,219,621,343,293,422,494,80,732,1210,449,72,236,307,541,10,620,1361,605,351,1304,475,215,989,153,8,1229,113,216,3,170,998,308,964,1755,223,1694,1937,60,41,1120,491,1270,766,501,326,236,632,163,880,963,1213,1030,444,229,425,239,834,59,66,580,488,303,475,457,1182,150,1273,53,22,53,224,536,945,824,56,694,187,586,555,1464,188,538,286,120,260,38,70,13,678,916,542,235,1138,34,259,12,280,178,45,213,1,580,268,114,1076,536,185,825,374,282,186,3,356,393,385,597,53,187,288,10,194,447,949,521,84,124,16,221,153,800,969,241,40,76,565,7,238,252,13,276,461,30,1034,129,204,657,793,630,1068,97,537,226,155,363,531,458,123,442,1155,371,196,1764,1049,73,258,853,2,653,923,189,472,1119,582,974,948,447,161,1737,765,93,369,48,293,762,58,2,1282,242,67,1310,129,468,425,116,471,768,291,878,1138,569,427,725,515,67,526,766,213,1307,288,1589,1304,3,287,1050,14,7,428,1684,479,355,72,1233,21,1449,284,11,27,315,274,181,215,486,247,946,59,158,432,231,178,1722,13,189,439,13,72,211,239,841,175,893,234,328,154,134,13,653,31,40,303,110,172,113,515,69,1009,1413,450,172,168,92,385,1555,216,1487,72,173,339,496,779,1696,153,49,342,1225,141,873,402,777,269,767,361,108,536,1432,343,23,380,716,1609,958,1512,743,246,315,220,1634,16,405,61,1150,350,620,1,13,749,9,738,1391,334,148,1142,220,662,1612,878,65,164,235,95,499,929,399,1675,886,86,452,238,487,354,103,7,372,428,971,419,41,56,613,126,819,354,170,1025,1183,2,1201,813,339,272,400,13,221,1021,182,192,1239,52,508,266,42,504,1281,779,1629,46,65,541,1004,115,384,922,89,372,56,211,419,420,149,316,670,1271,253,845,260,25,624,402,54,270,1366,831,170,47,11,235,106,757,854,1343,548,32,29,283,200,11,443,12,372,239,165,440,1099,104,686,335,656,1182,994,1126,14,503,508,766,634,744,660,102,56,449,227,96,357,23,83,653,519,144,9,59,892,253,984,777,178,629,82 2 | -------------------------------------------------------------------------------- /src/day-08/08.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Function parses line "dfgabce cadfgb cefa ca aecbg dfcegb geabd ecbfg cab agcfbe | egbfadc dbgae gcfeb abgdfc" 3 | * to pattern and output devided by '|', where pattern and output are arrays of strings. 4 | */ 5 | function parseInput(input) { 6 | const pattern = input.split(" | ")[0].split(" ") 7 | const output = input.split(" | ")[1].split(" ") 8 | return { pattern, output } 9 | } 10 | 11 | // Function treat input as list of lines and parses each line to pattern and output. 12 | function parseInputToPatterns(input) { 13 | return input.split("\n").map(parseInput) 14 | } 15 | 16 | /** 17 | * Function 18 | * parses input 19 | * iterates over the outputs in every line 20 | * return the count of entries that have length 2, 3, 4 or 7 21 | * 22 | * @param {string} input 23 | */ 24 | function solvePart1(input) { 25 | const patterns = parseInputToPatterns(input) 26 | let count = 0 27 | patterns.forEach(({ pattern, output }) => { 28 | output.forEach((word) => { 29 | if ( 30 | word.length === 2 || 31 | word.length === 3 || 32 | word.length === 4 || 33 | word.length === 7 34 | ) { 35 | count++ 36 | } 37 | }) 38 | }) 39 | return count 40 | } 41 | 42 | /** 43 | * @param {string} input 44 | */ 45 | function solvePart2(input) { 46 | const patterns = parseInputToPatterns(input) 47 | 48 | let sum = 0 49 | patterns.forEach(({ pattern, output }) => { 50 | const one = pattern.find((segments) => segments.length === 2) 51 | const four = pattern.find((segments) => segments.length === 4) 52 | const seven = pattern.find((segments) => segments.length === 3) 53 | const eight = pattern.find((segments) => segments.length === 7) 54 | 55 | const candidatesForSix = pattern.filter((segments) => segments.length === 6) 56 | const six = candidatesForSix.find((pattern) => { 57 | return ![...one].every((segment) => pattern.includes(segment)) 58 | }) 59 | 60 | const zero = candidatesForSix 61 | .filter((pattern) => pattern !== six) 62 | .find((pattern) => { 63 | return ![...four].every((segment) => pattern.includes(segment)) 64 | }) 65 | 66 | const nine = candidatesForSix.find( 67 | (pattern) => pattern !== six && pattern !== zero, 68 | ) 69 | 70 | const candidatesForThree = pattern.filter( 71 | (segments) => segments.length === 5, 72 | ) 73 | const three = candidatesForThree.find((pattern) => { 74 | return [...one].every((segment) => pattern.includes(segment)) 75 | }) 76 | 77 | const five = candidatesForThree.find((pattern) => { 78 | return [...pattern].every((segment) => six.includes(segment)) 79 | }) 80 | 81 | const two = candidatesForThree.find((pattern) => { 82 | return pattern !== three && pattern !== five 83 | }) 84 | 85 | const sortStr = (str) => str.split("").sort().join("") 86 | 87 | const patternsToNumbers = { 88 | [sortStr(one)]: 1, 89 | [sortStr(two)]: 2, 90 | [sortStr(three)]: 3, 91 | [sortStr(four)]: 4, 92 | [sortStr(five)]: 5, 93 | [sortStr(six)]: 6, 94 | [sortStr(seven)]: 7, 95 | [sortStr(eight)]: 8, 96 | [sortStr(nine)]: 9, 97 | [sortStr(zero)]: 0, 98 | } 99 | 100 | const outputNumber = output 101 | .map((pattern) => { 102 | return patternsToNumbers[sortStr(pattern)] 103 | }) 104 | .join("") 105 | 106 | sum += parseInt(outputNumber, 10) 107 | }) 108 | 109 | return sum 110 | } 111 | 112 | function main() { 113 | const input = require('fs').readFileSync('./08.txt', 'utf8') 114 | console.log("Part 1:", solvePart1(input)) 115 | console.log("Part 2:", solvePart2(input)) 116 | } 117 | 118 | main() 119 | -------------------------------------------------------------------------------- /src/day-09/day09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "os" 6 | "sort" 7 | ) 8 | 9 | func main() { 10 | layout := readCavesLayout() 11 | println(calculateRisk(layout)) 12 | 13 | lowestPoints := findLowestPoints(layout) 14 | basinsSizes := bfsBasinsSize(layout, lowestPoints) 15 | sort.Sort(sort.Reverse(sort.IntSlice(basinsSizes))) 16 | println(basinsSizes[0] * basinsSizes[1] * basinsSizes[2]) 17 | 18 | } 19 | 20 | func readCavesLayout() [][]int { 21 | file, _ := os.Open("day-09/day09.txt") 22 | var layout [][]int 23 | scanner := bufio.NewScanner(file) 24 | 25 | for scanner.Scan() { 26 | line := scanner.Text() 27 | var numbers []int 28 | for _, ch := range line { 29 | numbers = append(numbers, int(ch-'0')) 30 | } 31 | layout = append(layout, numbers) 32 | } 33 | return layout 34 | } 35 | 36 | func calculateRisk(layout [][]int) int { 37 | risk := 0 38 | for i := 0; i < len(layout); i++ { 39 | for j := 0; j < len(layout[0]); j++ { 40 | // current element: (i, j) 41 | // neighbours: (i+1, j), (i-1, j), (i, j+1), (i, j-1) 42 | current := layout[i][j] 43 | var neighbours []int 44 | if i != 0 { 45 | neighbours = append(neighbours, layout[i-1][j]) 46 | } 47 | if j != 0 { 48 | neighbours = append(neighbours, layout[i][j-1]) 49 | } 50 | if i != len(layout)-1 { 51 | neighbours = append(neighbours, layout[i+1][j]) 52 | } 53 | if j != len(layout[0])-1 { 54 | neighbours = append(neighbours, layout[i][j+1]) 55 | } 56 | currentRisk := current + 1 57 | for _, neighbour := range neighbours { 58 | if current >= neighbour { 59 | currentRisk = 0 60 | break 61 | } 62 | } 63 | risk += currentRisk 64 | } 65 | } 66 | return risk 67 | } 68 | 69 | func findLowestPoints(layout [][]int) [][]int { 70 | var lowestPoints [][]int 71 | for i := 0; i < len(layout); i++ { 72 | for j := 0; j < len(layout[0]); j++ { 73 | // current element: (i, j) 74 | // neighbours: (i+1, j), (i-1, j), (i, j+1), (i, j-1) 75 | current := layout[i][j] 76 | var neighbours []int 77 | if i != 0 { 78 | neighbours = append(neighbours, layout[i-1][j]) 79 | } 80 | if j != 0 { 81 | neighbours = append(neighbours, layout[i][j-1]) 82 | } 83 | if i != len(layout)-1 { 84 | neighbours = append(neighbours, layout[i+1][j]) 85 | } 86 | if j != len(layout[0])-1 { 87 | neighbours = append(neighbours, layout[i][j+1]) 88 | } 89 | isLowest := true 90 | for _, neighbour := range neighbours { 91 | if current >= neighbour { 92 | isLowest = false 93 | break 94 | } 95 | } 96 | if isLowest { 97 | point := []int{i, j} 98 | lowestPoints = append(lowestPoints, point) 99 | } 100 | } 101 | } 102 | return lowestPoints 103 | } 104 | 105 | func bfsBasinsSize(layout [][]int, lowestPoints [][]int) []int { 106 | visited := make([][]bool, len(layout)) 107 | for i := range visited { 108 | visited[i] = make([]bool, len(layout[0])) 109 | } 110 | var results []int 111 | for _, lowestPoint := range lowestPoints { 112 | var queue [][]int 113 | queue = append(queue, lowestPoint) 114 | currentResult := 0 115 | for len(queue) > 0 { 116 | point := queue[0] 117 | i := point[0] 118 | j := point[1] 119 | if !visited[i][j] { 120 | if i != 0 && layout[i-1][j] > layout[i][j] && layout[i-1][j] != 9 { 121 | queue = append(queue, []int{i - 1, j}) 122 | } 123 | if j != 0 && layout[i][j-1] > layout[i][j] && layout[i][j-1] != 9 { 124 | queue = append(queue, []int{i, j - 1}) 125 | } 126 | if i != len(layout)-1 && layout[i+1][j] > layout[i][j] && layout[i+1][j] != 9 { 127 | queue = append(queue, []int{i + 1, j}) 128 | } 129 | if j != len(layout[0])-1 && layout[i][j+1] > layout[i][j] && layout[i][j+1] != 9 { 130 | queue = append(queue, []int{i, j + 1}) 131 | } 132 | visited[i][j] = true 133 | currentResult++ 134 | } 135 | queue = queue[1:] 136 | } 137 | results = append(results, currentResult) 138 | } 139 | return results 140 | } 141 | -------------------------------------------------------------------------------- /src/day-12/12.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | using std::cout; 10 | using std::unordered_map; 11 | using std::unordered_set; 12 | using std::string; 13 | using std::transform; 14 | using std::vector; 15 | using std::ifstream; 16 | 17 | class TraversalPolicy { 18 | public: 19 | virtual void PushVisit(const string& node) = 0; 20 | virtual void PopVisit(const string& node) = 0; 21 | virtual bool CanVisit(const string& node) = 0; 22 | }; 23 | 24 | class Graph: public unordered_map> { 25 | public: 26 | void Load(ifstream& in) { 27 | string s; 28 | while (in >> s) { 29 | size_t hyphenPos = s.find('-'); 30 | string lhs = s.substr(0, hyphenPos); 31 | string rhs = s.substr(hyphenPos + 1, string::npos); 32 | (*this)[lhs].push_back(rhs); 33 | (*this)[rhs].push_back(lhs); 34 | } 35 | } 36 | 37 | size_t NumberOfPaths(string start, string finish, std::shared_ptr policy) const { 38 | if (start == finish) { 39 | return 1; 40 | } 41 | auto neighbours = this->find(start); 42 | if (neighbours == this->end()) { 43 | return 0; 44 | } 45 | size_t result = 0; 46 | for (auto&& it : neighbours->second) { 47 | if (!policy->CanVisit(it)) { 48 | continue; 49 | } 50 | policy->PushVisit(it); 51 | result += this->NumberOfPaths(it, finish, policy); 52 | policy->PopVisit(it); 53 | } 54 | return result; 55 | } 56 | 57 | template 58 | size_t NumberOfPaths() const { 59 | return NumberOfPaths("start", "end", std::make_shared("start")); 60 | } 61 | }; 62 | 63 | string Upper(const string& str) { 64 | string upper = str; 65 | transform(upper.begin(), upper.end(),upper.begin(), ::toupper); 66 | return upper; 67 | } 68 | 69 | string Lower(const string& str) { 70 | string lower = str; 71 | transform(lower.begin(), lower.end(),lower.begin(), ::tolower); 72 | return lower; 73 | } 74 | 75 | bool IsUpper(const string& str) { 76 | return Upper(str) == str; 77 | } 78 | 79 | bool IsLower(const string& str) { 80 | return Lower(str) == str; 81 | } 82 | 83 | class FirstPuzzlePolicy: public TraversalPolicy { 84 | private: 85 | unordered_map Counter; 86 | public: 87 | FirstPuzzlePolicy(string start) { 88 | ++Counter[start]; 89 | } 90 | 91 | ~FirstPuzzlePolicy() { 92 | } 93 | 94 | void PushVisit(const string& node) override { 95 | ++Counter[node]; 96 | } 97 | void PopVisit(const string& node) override { 98 | --Counter[node]; 99 | } 100 | bool CanVisit(const string& node) override { 101 | return IsUpper(node) || Counter[node] == 0; 102 | } 103 | }; 104 | 105 | class SecondPuzzlePolicy: public TraversalPolicy { 106 | private: 107 | unordered_map Counter; 108 | int NumTwiceVisited; 109 | public: 110 | SecondPuzzlePolicy(string start) 111 | : NumTwiceVisited(0) 112 | { 113 | ++Counter[start]; 114 | } 115 | 116 | ~SecondPuzzlePolicy() { 117 | } 118 | 119 | void PopVisit(const string& node) override { 120 | if (Counter[node]-- == 2 && IsLower(node)) { 121 | --NumTwiceVisited; 122 | } 123 | } 124 | 125 | void PushVisit(const string& node) override { 126 | if (++Counter[node] == 2 && IsLower(node)) { 127 | ++NumTwiceVisited; 128 | } 129 | } 130 | 131 | bool CanVisit(const string& node) override { 132 | if (node == "start") { 133 | return false; 134 | } 135 | if (IsUpper(node)) { 136 | return true; 137 | } 138 | if (IsLower(node) && NumTwiceVisited == 0) { 139 | return Counter[node] < 2; 140 | } 141 | return Counter[node] == 0; 142 | } 143 | }; 144 | 145 | int main() { 146 | std::ifstream in("/Users/ashagraev/Desktop/input.txt"); 147 | Graph g; 148 | g.Load(in); 149 | cout << "default policy paths: " << g.NumberOfPaths() << std::endl; 150 | cout << "second policy paths: " << g.NumberOfPaths() << std::endl; 151 | return 0; 152 | } 153 | -------------------------------------------------------------------------------- /src/day-13/singlefile13.scala: -------------------------------------------------------------------------------- 1 | //working version here https://github.com/FunFunFine/cli/blob/master/src/main/scala/private/DayThirteen.scala 2 | 3 | import zio.* 4 | import zio.Console.* 5 | import language.experimental.fewerBraces 6 | import zio.* 7 | import zio.Console.* 8 | import zio.stream.* 9 | import java.nio.file.* 10 | 11 | //build.sbt 12 | /* 13 | val zioVersion = "2.0.0-M6-2" 14 | 15 | scalaVersion := "3.1.2-RC1-bin-20211213-8e1054e-NIGHTLY" 16 | 17 | libraryDependencies ++= Seq( 18 | "dev.zio" %% "zio" % zioVersion, 19 | "dev.zio" %% "zio-streams" % zioVersion, 20 | ) 21 | */ 22 | object DayThirteen extends ZIOAppDefault: 23 | def run = 24 | for 25 | raw <- readInput("paper.txt") 26 | taskInput = Input.fromRaw(raw) 27 | paper = taskInput.paper 28 | _ <- printLine(paper.show) 29 | _ <- printLine(taskInput.folds.mkString("\n")) 30 | answer = taskInput.folds.foldLeft(paper)(_.fold(_)) 31 | _ <- printLine(answer.show) 32 | _ <- writeOutput("code.txt")(answer.show) 33 | yield () 34 | 35 | 36 | 37 | case class Point(x: Int, y: Int) 38 | 39 | 40 | enum Axis: 41 | case X 42 | case Y 43 | 44 | object Axis: 45 | def unapply(s: String): Option[Axis] = 46 | s match 47 | case "x" => Some(Axis.X) 48 | case "y" => Some(Axis.Y) 49 | case _ => None 50 | 51 | 52 | case class Fold(along: Axis, at: Int) 53 | 54 | object Fold: 55 | def parse(raw: String): Option[Fold] = 56 | raw match 57 | case s"fold along ${Axis(axis)}=${value}" => 58 | value.toIntOption.map(Fold(axis, _)) 59 | case _ => None 60 | 61 | 62 | case class Input(dots: List[Point], folds: List[Fold]): 63 | val paper: Paper = 64 | Paper(dots.toSet) 65 | 66 | object Input: 67 | def fromRaw(data: List[String]): Input = 68 | val paperDataRaw = 69 | data 70 | .takeWhile(_ != "") 71 | .map(_.split(",") 72 | .map(_.toIntOption)) 73 | 74 | val paperData = paperDataRaw 75 | .collect: 76 | case Array(Some(x), Some(y)) => Point(x, y) 77 | 78 | val foldsData = 79 | data.drop(paperData.size + 1) 80 | .map(Fold.parse) 81 | .collect: 82 | case Some(fold) => fold 83 | Input(paperData, foldsData) 84 | 85 | 86 | case class Paper(dots: Set[Point]): 87 | val width = dots.maxBy(_.x).x 88 | val height = dots.maxBy(_.y).y 89 | 90 | def fold(fold: Fold): Paper = 91 | fold.along match 92 | case Axis.X => 93 | val (rightPoints, leftPoints) = dots.partition: 94 | case Point(x, y) => x >= fold.at 95 | 96 | val invertedRightPoints = rightPoints.map { case Point(x, y) => 97 | Point(fold.at - Math.abs(fold.at - x), y) 98 | } 99 | Paper(invertedRightPoints) <+> Paper(leftPoints) 100 | 101 | case Axis.Y => 102 | val (pointsBelow, pointsAbove) = dots.partition: 103 | case Point(x, y) => y >= fold.at 104 | 105 | val invertedPointsBelow = pointsBelow.map: 106 | case Point(x, y) => 107 | Point(x, fold.at - Math.abs(fold.at - y)) 108 | 109 | Paper(invertedPointsBelow) <+> Paper(pointsAbove) 110 | 111 | object Paper: 112 | given Show[Paper] = 113 | paper => 114 | val xs = 0 to paper.width 115 | val ys = 0 to paper.height 116 | val sb = StringBuilder() 117 | ys.foreach: 118 | y => 119 | xs.foreach: 120 | x => 121 | sb.append(if paper.dots.contains(Point(x, y)) then "⬛" else "⬜") 122 | sb.append("\n") 123 | sb.toString 124 | 125 | given Semigroup[Paper] with 126 | def combine(l: Paper, r: Paper): Paper = 127 | Paper(l.dots.union(r.dots)) 128 | 129 | 130 | 131 | 132 | 133 | trait Semigroup[A]: 134 | def combine(l: A, r: A): A 135 | extension (l: A) def <+>(r: A): A = combine(l, r) 136 | 137 | object Semigroup: 138 | given Semigroup[Unit] = (_, _) => () 139 | given Semigroup[Int] = _ + _ 140 | 141 | 142 | 143 | trait Show[A]: 144 | def shown(a: A): String 145 | extension (a: A) def show: String = shown(a) 146 | 147 | object Show: 148 | given Show[String] = identity(_) 149 | given Show[Unit] = _.toString 150 | 151 | 152 | 153 | /** Writes to repository directory */ 154 | def writeOutput(filename: String)(data: String): ZIO[Any, Throwable, Unit] = 155 | def fileSink(path: Path) = 156 | ZSink 157 | .fromFile(path) 158 | .contramapChunks[String](_.flatMap(_.getBytes)) 159 | 160 | ZStream(data).run(fileSink(Paths.get("code.txt"))).ignore 161 | 162 | /** Reads from repository directory */ 163 | def readInput(filename: String): ZIO[Any, Throwable, List[String]] = 164 | ZStream 165 | .fromFile(Paths.get(filename)) 166 | .via(ZPipeline.utf8Decode >>> ZPipeline.splitLines) 167 | .runCollect 168 | .map(_.toList) 169 | 170 | 171 | //@scala_ru 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /src/day-09/day09.txt: -------------------------------------------------------------------------------- 1 | 9899899864598765321239999546794323489012356910136789234678999765986432109874349897678921298754345856 2 | 8798788978989899992398798932986734678943869872345679129789999843497643298765456789568910129983236745 3 | 7676567899976998789977587891297945789654699964557789298999987932599954399897897893457891239765101234 4 | 6545459789765497679765476789349657898765789985668999987899876893989876988998998932378932349874323457 5 | 6435345678987984568974345678998998999997893596779789876789765689878989877569789949989864556995434567 6 | 4323234799999876789743234789997899990199952129895698975678934599769998966445679897899876769876546789 7 | 3210125899989987897654348999876789989987641016954987654699545678958986543234598786788989895989657899 8 | 4391434989878999998776567898765434878999832345693198766789956799346995432123987655677899934598978978 9 | 5989549876567899899987898997654323459876546598789239979899897890239876543099878434566789545987899769 10 | 9878998765456789788798999998765434568997687678898945989999789994345987654987654312345689656976793244 11 | 9767989654345897652649999899876685678998798899987899995697679879959998765699873201239798769865692123 12 | 8656976543234789341234987676987899899219999912345678934987599767898999978798765412345689898764789045 13 | 9947987654375693210359876565499999931929898924569789875699987659946792499899886643459898999893492123 14 | 9858998765466789391398765454346789649898767895798999997893987548937921398965998754567987897632459234 15 | 8769879876879899989989764321234698798789656896897689889902998437898943497994339867899986796543678945 16 | 9897765989989999867879865430126789987654546789989549778919876545999654986789123979999765689954567956 17 | 9976544393499987853467954321245678998793235678965434567924998656998965987991094989998654578899778998 18 | 9999932239599876542346986434358789899986545689876545679895698787897896799432989999987943348799889999 19 | 8987890198989987621234976565469896799998676896987656996789789898956789898549878909876821234589997891 20 | 7896991987678998210123989679578935678999787965498899875678999989545789987699868912985310345678956932 21 | 6545689998899879321234598798689323489899898978309987664567899975434699998989957899976431458999349893 22 | 5434578999998765442456679899799912398789959793212986543446798766323578949879898998997643467921236789 23 | 4323467899989887663567889979899893987664234689323985431234579654212349939765789987698754567890945699 24 | 3214347999876998898779998765998789998543123456939876420256689799903467897654579876569866678999899789 25 | 4301236897654459989899659984345678987655234597899987834569798987894979996543456987456978789298798999 26 | 3213345789542345678978939873234789398976349989999998945678987676569899987632169876345989892197696989 27 | 5624567899643456789568998764566991299987898767998999987989986543456789198721098765456799943987575878 28 | 5438678978954567895478679875678992989998939654767899999899976432345899239433679899587899656943434567 29 | 6648789367896788901234567987789889879899029953459987899769865431235678945954567998679978969832123458 30 | 9859895456789899212349678999898776768799998764567896988998765610123479959895979989989967898751012345 31 | 9967997667899954324568989789999654356679879985778934567899654321234567896789898978997856987632123456 32 | 9878998789999876535679495698998743244598965797899323456998767434345798965698767869896549876543478567 33 | 2989899899999987646789323457987653123697854698965414568959876545756799454987655456789659987754569678 34 | 1095798998989899756793212568999761019986543569876501278945987767867895323986542345678978998978678899 35 | 2124567897679789868965425799999832198765432479987612378929898989978976568997721239899989539989789999 36 | 3236678998554678979996934989987543239874321389998724567998769694989989679999843345789894312999895689 37 | 4545699965433459989989899976797654647989433479999837678909654543295798797899756789898765109876954799 38 | 5666789876212567899876798765698987656897654567892948789219763210134569896798767991949966212965432878 39 | 9877899998434678998555679954459898768998765789910959898923987321949698965329878910123954329896421267 40 | 5989999997565789997434567892346789878919878894329878987894596439898997643201989543239865498765432349 41 | 4399998998776899876723478921234567989329989999456989656789989598797689764312399654345986569989643578 42 | 1299897679897939765434589210565699995498797998968996546789679987654578975323478965696798679698754689 43 | 2989788567998929876547895342456988976987656877989965432433567976543459987634569996989899889579965691 44 | 9976543456899998987656789756769876799876546766899876541012456798952348998545678989878954993499876792 45 | 8765432337899987698767899897898765689985432345789987632323577899891276789789989878767893212988989893 46 | 9875430123789976569898945989999854578997643487892398743439688998789345689899998765456789329776598954 47 | 9965321934567895452959999878987543567898797698990129965998999987678956789998987654349899998665456895 48 | 9875439899998954321234988768987654678999898979789249879867899876598967899987598985269989876542347896 49 | 6986598798789865632459876543298765889899989563678956998756998765456978999876459876378978965431238987 50 | 5597989587678978643598995432139876998798765472489767987645797654327899998764323987889769896670123598 51 | 4459965454597897659987689321025987998679977321238989998434589765458954987643212498997656795431245789 52 | 2398854323456989798776567992134699876468893210137999987514678976579763296543101359894245695432356897 53 | 1987643412345678939654467689657899884245789543236789987623569989697654197653212346792136789565456795 54 | 2498532101246989549743234578968998762136898654345698765434678999789765298894343478891017899877567896 55 | 3987643212397999959832175999878999754547899865466789987545789567996978349965454567892128998987688987 56 | 4998784323498999899943567899989398767898999989877995998766893459545989459876565678943469876898999798 57 | 9859897654679987799654678967895459898919498694989234889877965667934696567989876789656778965569899659 58 | 8743998767899866698769899345989969999902397543992125679989878799323597689999987898767889654398788945 59 | 9632349878998754569889943239879898997893598679875234567897999989434698799989698989898999965235667896 60 | 6531267989989986678997632198767767896789989789994345789976567978965699899978559678999987892123456789 61 | 7545459899878998789898543986553656789899879897989976789987699869998789998765432568990196789014567891 62 | 7656797658768899894698754965432348999998765956978987998798987658789892399986543479989985698925678992 63 | 8769989545656789923999869876521234689998754349869898997679799645679901989987756569876674567896999989 64 | 9898978934345679899897998765420127899976543209655789876567697536796899878999867898985543456789878978 65 | 9997657921234698789656789876431236789898754498743678975434598987895679767899879987654102345678966466 66 | 8987546892945987678945678987654345698789865999654569876545679799934698654568992976543212456789854345 67 | 7895435789896976567998789998765456789679979898785678997697989689996789763499201987954323589898763234 68 | 6796576798789895456899899989876577894578998789876899789989993498989899852178919998765454678997654346 69 | 5987678987676789345901939876987689923489987654987987698778921397878989943267898999986869789039766467 70 | 4599999876575689234899029965499897634590976543499996545567892986565679894356997896897999892123978578 71 | 3459898765434590135678998764345976545692985432459896532346979875434598789459876785698989993239899989 72 | 2599749854325679246999569878967989656789987653498789431234567994323987689998765834569878989398789992 73 | 1987630965434994356789479989878998787896599765987678932345679765509876567899954323498769878987678891 74 | 9999521398946789969892398995989999898965439899876567894467989876798765458998763214987654567898546789 75 | 8998432987656899899901987854699987999654323934985458965678999987987654367959984523986543456789434899 76 | 7987674598967958789319876543598996598743209129994346899899019998998765488945965439876431345678924997 77 | 5499789679878945689498765432387897679654998998789235679999198999879896569239876567989642456789213456 78 | 9329898789989235578999878541266799998769876987698945791098987898965987892123987678998753768995101234 79 | 8910959895490123467899999320145987899898765976587997892397596987654998999934999789989967989654312689 80 | 7892345986321434678978989431239986989987654989456789989996465698789869898899889898879878998765424578 81 | 6996456795432375679767978932398895878996432198568999878789324249898756797765678987666989129987435699 82 | 5979677986545699897659867893987674567987643987678968965679210136999645975654457896544598998976546989 83 | 4367999987656988976543956895698543467998754599889757894568921245695439984323298989323567897987659878 84 | 3246798998789867897432348986987674578979895789997645953457999356976698793210129678912378976498798767 85 | 2124687899898756789321467999898765689357987899898756892345678968998997654323234567924459765349987656 86 | 1012456923987645995436578987789876791268998989769878954596789989459898969864347979895689921234596545 87 | 2423677899999766898656679876565987892379129678945989965678992191298769798765456798789789890145985434 88 | 7634988998919878998787899985434598943468934589959999876899321019497653669986599987678998789959876515 89 | 8795999687909989999998999875323459976567896799898921989987432198976442456797987876589998679899987601 90 | 9989896545798998989659298765435678997878987899767899898976543987664321345679976565456895466789998312 91 | 9878789434567897878943019876546899898989098987656965787987674976543210146798765434345689345679876543 92 | 9965678923456996567932129987656998779692199998767893656899895698956343234999875323239791236799987654 93 | 9876799544799987459543298598998999657569987999898912345678976989765464349878974210178943478989899785 94 | 0999898765678942378954997459679996545498876891959101234567899878999878498769865323367894569876799876 95 | 1298999898799865489769876323589989432397545790943212345678998967889989998659876554459965679965587997 96 | 2997899939894987999878965104678978921239834899865623456789987654378999867543987678767897898743456898 97 | 9876789921923999899999874324989867890398765689976784568891298763254987658902398789879998987652345999 98 | 7665567890199895679765965449898756789459876789987896878932459542123496543212479893989459876541256899 99 | 8543458932987684567964987598765435678968997895398987989656899643234569854324569912995312997632345789 100 | 7652369543498543678932197679886545799878998943219998999768998754545698765537678929876109876543467899 -------------------------------------------------------------------------------- /src/day-10/prod_input.txt: -------------------------------------------------------------------------------- 1 | [(([{<{(<{{[({{}{}}{[]()})<{{}()}>]}}(([{{{}[]}[[]()]}[<{}[]]{()()}]](({{}{}}{{}()}))){[{({}())[[ 2 | <(({[<([{({[{{<>()}}[{<>()}({}{})]]<{<()<>>{[]()}}(((){}>[[][]])>}([{<[]{}>(<>[])}]))<[[[[[][] 3 | (<<(<{{{{<<<[(()<>){()<>}][[()()]]>{<{[]{}}<<>()>>}>{(<{<>}([]{})><(<>())<(){}>>)<(([]{})(()()))<<()[]>{{}[]} 4 | [[[[<[{[(<{{{({}<>)((){})}((()())[()()])}}><[([((){})]<[()[]]{{}<>}>)[[{[]<>}][([]{})[{}()]]]]>)<{(< 5 | [<(<[[((<{((<<<>[]>><<<>{}>>){<[{}<>][<>[]]><<<>()>[(){}]>})[<{[{}<>][(){}]}<[[]<>][{}[]])>{([<>[]][ 6 | (([[[[<([[{([{<>()}{()<>}][((){})]){[{[]<>}({}<>)][(<><>)[()[]]]}}<{{({}{}){[]{}}}<{<><>}({}{})>}> 7 | {{{[<(<([<{({{[]()}[{}()]}{<()<>>(()<>)})}><<[{<()()>(()[])}<<<>[]]>][<{()}{<><>}>({{}[]})]>>]( 8 | (((<<({<{{<[{[{}[]][()<>]}({{}{}}[{}[]])]>}<<((<{}[]>{<>{}})[{{}[]}])>{<({<>}<<>[]>){[{}{}][()[ 9 | <[{{[{[[(<{({{<>[]}<{}{}>}<([]())<[]()>>)}({{[[]<>]]<<<><>>[<>]>}<{([]){(){}}}<{[]<>}{[]<>} 10 | [(<([{[{<{{[<<()()>{<>}>(({}<>)<()()>)]({{{}{}}[{}()]}[[()<>](<><>)]))}(<<{{()<>}([]())}[<{} 11 | (((((<<{<({{<[{}()]({}<>)>(<{}[]>([]()))}<{<()<>>([]<>)]>}[<{<()<>><[]<>>}[{[][]}([]{})]>{[[() 12 | (<(([<[[(<{(({(){}}<[]<>>)[(()[])(()[])])({((){})}{<{}{}>(<>[])})}((({<>()}<<>{}>)(<{}<>>{[][]})))>[<[{<{}( 13 | <(<{([(({<<(<{()<>}[(){}]><{[]{}}<[][]>>)((([]{}){<>{}}){({}<>){<>{}}})>>(<{<({}<>)<{}<>>>({[]()}{<>{}})}>[[ 14 | <{{(<<<[(([[[[{}{}]]<[[]][()()]>][(({}[]){[]})<{(){}}{{}{}}>]][({[(){}]([]())}([()<>][{}()]))({([]<>)}[<< 15 | (([{{<([[[{{[<<>[]>{()()}][{<>()}{{}}]}([<[]><[]{}>]<<[]<>>>)}][{({[()()]<{}{}>})((<[]<>>< 16 | {{<{<[{<[{<[({{}()}([]{})){(<>[])([][])}][[{()[]}][<[]{}>]]>({(<{}{}}<[]{}>)[[()<>][{}{}]]}[<<[]()>[{}{}] 17 | ((<([([(({[([({}{})]({[]<>}<<>()>))({<()()>[<><>]}({<>{}}<{}[]>))]{{[{{}[]}][[()()](()())]}[ 18 | ([<(<[{[<<(<<{<>[]}[[]{}]>([{}][<><>])>[{<<>()><<>()>}])>>]}[(({<{(<()<>>{{}{}})[{[][]}]}<{ 19 | ([(<{{[[[[{{(<{}<>>([]())){{[]<>}{<>()}}}[{[{}<>]<(){}>}]}[<<[(){}]([]<>)><[[][]][<>[]]>>({( 20 | (<{[{{<{<<{{<(<>{}){()[]}><(<><>){[]<>}>}{<[<><>]{[]<>}>[[<><>]{[]}]}}>[([<[{}[]]>(<[]()>([]<>))]<[<[]{ 21 | <{([[<<{[([<<{[]{}}<<><>>><<<>{}>[[]()]>>({<[]<>>({}{})}({()()}(<>[])))][{(<(){}>[<><>])<<{}<>><[][]>>}[[ 22 | {(<[[{<{[[[{[([][])(()())]}[<[[]<>]{{}()}>{<{}[]>[(){}]}]]]{[<({[][]}(<><>))[([][])<<>[]>]>({{{}[]}[<>{ 23 | [({{{(({[<(([<(){}>[[]{}]]){{{{}()}}[<[]()>({})]}){<[<{}{}>{[]()}](({}[]>{<>[]})>[([()<>][[ 24 | {{<{{{<([<<[{[[][]]({}())}[<<>[]><<>[]>]><{(<><>)({}{})}{(()<>)([][])}>>{<[<{}{}>{()()}]{<{}{}><[]> 25 | ([<<[((({{{<([{}[]](()()))<(()()){{}{}}>>{[{<>[]}({}())>}}}<{[<<{}<>>(<>{})>(({}<>)[()[]])](<{()<>} 26 | {(<<<[[<[({{[{{}{}}][[[]{}](<><>)]}<{([]{})<[][]>}[{{}{}}<()()>]>}<[{{()[]}{()[]}}[[[][]]{(){}}]](<({ 27 | <{{((<{[<({{([<><>]([]<>))}(<<()<>><(){}>>{([]<>)([][])})}{[{({}())[()()]}[<<>()>{[][]}]]( 28 | <<<[({({<({[<<<>{}>(<>{})>]((<<>()>[()])(({}{}){()()}))})>{{<(([()<>]<<>[]>)({()}))>}}})}<{({<<(<<{}>( 29 | <(<{<[((<(<[([()<>][[]()])]<((<>)<{}{}>]({()()}[[]{}])>><<{{<><>}{{}<>}}([[][]]<<>>)><(<{}{}>({}[])) 30 | [[([{[{[{({([<()>]{(<>())(()())})[[{<>()}{()<>}][[<><>][[][]]]]}{(({{}{}})[{{}()}[{}<>]]){[<()()>{()[]}] 31 | [<<[{<({([<(<({}())[[]{}]><[[]{}]{<>()}>)>(<(<()()>)(<()<>>[{}[]])>)]<<[{<{}[]>([]{})}<((){})< 32 | {[{{<{[{({{<[<<>{}><[][]>]<<(){}>[[]<>]>>([[<>[]]<()[]>](({}{})(()<>)))}}{<<{<(){}><()[]>}[(<>[])( 33 | [<<[[([[{{[({<<><>><<>[]>})({<{}()>({}[])}((()<>)[<>()]))](<([()()])<<<>[]><()()>>>)}<{<{(()<>)[()[]]}<({}()) 34 | [{([{<([<(<<(([][])<<>[]>)<{<><>}(<><>)>>(<(<>[])([]{})>{<()<>><{}<>>})>((<[<>[]][[][]]><{<><>}(<>[])>)))[ 35 | <{{([{[([[{<[(()())[{}{}]]><[<[]>[(){}]](([]<>)(()()))>}{([{[]()}[{}[]]]<[<>[]][<>{}]>)}]][<[<<(<>{})[{}{}]>> 36 | {{[<<{{({({<<{<>()}<{}[]>>>{<[<>()](()<>)>{(()<>)<{}[]>}}}<((<<>[]>{()[]))<{[]()}{<>[]}>)<[[{}][{}[ 37 | [<<[<<{[[<({[[{}[]]([][])]<({}[])>}<{{<>{}}<[]()>}{([]<>){()<>}}>)<{(<()<>>(()<>))(<<>><()<>>)}>>]<{<< 38 | <{({(<<(<{({<({}<>)>({{}}{<>()})}{<(()<>){<>{}}>{{[][]}({}[])}})}>)>>([<(({(({<><>}({}[])){{()<>}[[]]})<((<>< 39 | (<{[[([[<{[<{<[]()>([]())}((()<>>{{}{}})>]}>]]{<<<[(([[]<>]<{}()>)({<>{}}<()[]>)){<{{}()}<[]<>>>[ 40 | [[{[<[[<<{<([{()[]}{{}{}}]<<[]{}>>)<[[{}<>]{{}[]}]{[{}()]{(){}}}>>({([()()]<[]<>>)<{{}()}( 41 | ((([{({[{<{({{[]<>}[{}()>}[({}[])[[]()]])[[{<>[]}{{}[]}]<[(){}]{()()}>]}{<{([]<>)}>([{<>{}}]{ 42 | [(<(<({{{((<[<<>[]>{()<>}][[[][]]<<>[]>]>[[<[]{}>[{}{}]]{([]()){<>())}]))([(<<[]{}>>)][[{(()<>)([][])}]{<(<> 43 | {<[[<<{({[(<(({}{})(<>{}))<{<>[]}<<>()>>><(<()>({}()))[{[]{}}(<>[])}>)]}){(<{(({{}[]})<(<><>)([]())>){[([][ 44 | [[{[<{[((<[<<<<><>>[<><>]>[<<>>{<><>}]>][{{<()>{{}[]}}{({})[{}()]}}[<[[]{}]{()()}>({[]()}(<>{}))]}>{{<([ 45 | {<<({<[<(([[[[[]()]][<{}<>><()()>]](<<{}[]>[<>()]>[{<>{}}[()]])])({(({{}[]}<<>()})(<<>()>)){[{()<>}{(){}}] 46 | <[[<<[{([(({{{<>[]}([]{})}<[[]()]<()()>>}[<({}[])[[]<>]>[<{}()>[()()]]])[{(<[][]>{{}<>}){{<>() 47 | ([[<(<({({(<([<>[]][[][]])[<()[]>[[]()]]>{((()())([]{})){<{}()>{<>{}}}})}[<[<[()<>]{[]{}}>({[][]}( 48 | [<{<([{<[{<[<([][])}([[][]]<<><>>)]><(<(()[])<()<>>>({<>{}}[<><>]))>}<(<(({}()){{}[]})[<<>[]>]>){ 49 | {{[<{<{([<<[{[()()]{[][]}}[[[]{}]{{}[]}]]{<<{}()>[[][]]>{{()[]}(()())}}>{[{[(){}][[]()]}<<()> 50 | <{[<{[{{(<<(<<{}>>{{()[]}({}{})})<{[<>{}][<>{}]}((<>{}))>>([[(<><>){()<>}][(()[]){[]<>}]])>)}<<{{([<<> 51 | {<({<<{((<{<(<{}>[()])[[(){}]]><<[<>[]]>(([]())([][]))>}<[{<{}()>[[]{}]}[[<><>]([]{})]]>)<[[<{[]}[()[] 52 | [{<{[[[([[((<[[]{}][<>{}]>[((){})([][])]]({[[]<>][{}()]}[(<><>){[]<>}])){[<[{}]><[()()]>]<<([]<>)(<>())>{<<>[ 53 | [{[{<([[[(<{<<[]{}>([]{})>[[<>{}]]}>[<[[{}]<<>{}>]{<{}<>>{<>{}}}>([<{}[]><(){}>]<(()())(()<>)>)])<<<[(()<>)( 54 | [(([<{(<({<<<(()()){(){}}>[{<>}(<>{})]>[{([]()>(<>())}<(())[()<>]>]>(([<{}{}>]{[[]{}]({}())})(([<>{}]<()< 55 | {[{([([[[{<{[<{}()>{{}{}}]<{<>[]}([]<>)>}[(<<>{}>({}{}))<<{}()>{{}[]}>]>}{(<[[()()]}>{[[()()]<{}[]>][[()[]]] 56 | [<([[{[<<[{[{({}[]){{}{}}}]}]([({{()()}}<[[]()][{}[]]>)([[()()>])]{<{<()[]>[<>[]]}<[{}{}]{<>()}>> 57 | <<(<[<((((((<{(){}}[<><>]>)[<<()[]><{}[]>><<()[]>{{}[]}>])[(<<()}>([{}<>]))({<{}><[][]>}{([]())[{}<>]})])){< 58 | {[([{[[(<{<{{<{}{}>(())}}>}(({{{[]()}<{}[]>}{([]{}>{<>[]}}}<{<[]()><()[]>}<[<>{}][[]<>]>>)((<[{}[]]<[]<>> 59 | <{{{(([[([{{{<(){}>{{}()}}{({})<()[]>}}[{(()[])({}<>)}[{[]{}}{()<>}]]}]<(<([{}[]](<>{}))[<()[] 60 | <({({[<<([{{({<><>}[{}[]])}{(<<>>([]<>))<{(){}}{<>()}]}}])({{{[{(){}}[(){}]]<[()<>][{}{}]>}}}{ 61 | (({[(({({((<({[]<>}{[]<>}){[[][]][(){}]}><<<{}[]>(<><>)>(({}<>)({}<>))>)<{{[[]<>][<>()]}}<[(() 62 | <([{{[({([([<{()()}<{}>>{((){}){{}[]}}]<<[[][]]({}<>)>((()())[[][]})>){[<[<>()]<{}<>>>(<<>{}>[[]{}])]{[[ 63 | {[[[[<{([<[({[[]()]<{}{}>})((<<>{}>[[]<>])<(()())([]())>)]({{[[]<>][{}[]]>[[[]<>]([]{})]}({{( 64 | [<{<[[<[[({([{{}<>}{<>}][{{}[]}{(){}}])[{<<>()>)([<>()](<>[]))]})]][({[[(([]<>)[{}()])[({})(<> 65 | ([<{{{<([{[[([<>[]]<{}{}>)[({})[<>{}]]]]{<<({}[]){[]()}>[<{}()>]>[([{}[]][()<>]){[()()]<<>()>}]}}<{({{()()}[ 66 | {(({[({<<[{[(([]{})<{}{}>)({[]<>}[<><>])]}({({()[]})(({}<>)[{}]}}([{[]{}}(()())]))]>(<[[[{[]{ 67 | [{[((<{[{<[([{<>[]}<[]{}>]({()<>}[[]{}]))<[[<>{}]<[][]>]<{(){}}{[]{}}>>]<({(()()){[][]}}{{[]{}}{()<>}}){ 68 | {{<{({{<<({{(([]())<<><>>)((<>())[{}{}])}{((<>{})[()<>])[(()<>){{}{}}]]})<({[[<>{}]<{}<>>]([<><> 69 | {<[<[{[(({((<[<><>]([][])>{{<>{}}<{}()>})(<{{}{}}([])><{()<>}(<>{})>))(<{{()<>}{<><>}}[{{}{}}([]<>)]>)}[ 70 | [<[[[(({(([({{<>[]}<()<>>})([[{}()]([]<>)]({<>[]}[{}()]))])<{(<[[]<>]{[]<>}>){{{<>[]}}(([]{}))}}<[<{<><>}{ 71 | [<{{(<[(<<([<<{}[]>[<>()]>({<>[]}{<>})]<[{[][]}[()]]>)({{[()<>]<<>{}>}<(<>[])({}[])>})>((<{{()}}{<()< 72 | [[(([[<{<<({<(()<>)[{}[]]>[<()[]>[()<>]]}(((()())[{}{}])))>[([({{}[]}([]<>)){({}<>)([][])}] 73 | <{<<<<[([([[(<[]<>>){{<>{}}[()[]]}]]{[<<()[]><{}[]>>[<()<>>([]())]][{<<>[]>[{}()]}]})][<[<[ 74 | ({{<[<[(([(([<()()>{()[]}][(()())[{}]])(((()[]){{}[]})({[]}{[][]})))]<[{[[[]()>]<[<><>]>}[( 75 | <[<[[[{(([<(({{}{}}<()[]>))>{[<({}<>}([][])>]<[(()()){()()}]<<{}[]>({}())>>}]<<[([<>]([]<>))[{< 76 | {[[<[(<(<{({[[[]}{<>{}}]}({{{}()}<{}[]>}<<()[]>{[]()}>))}[[{<{{}<>}([][])>[{()()}]}(([{}<>])({[][]}<<>[ 77 | (<({[{[<<<({[[()[]]]})>>{[{{{[()()][[]{}]}{{<>{}}(<>[])}}<{<{}{}>(<>())}<{[][]}[{}[]]>]}<<[<<>()> 78 | [[(<(<{<(<{<<{{}<>}<<>{}>>{{()<>}(<>())}>}>){[[{<<<>{}>[{}<>]><{[]}((){})>}[[<<>[]>{<>()}][{{}{} 79 | {[((((({<({({(()())}([{}<>]<()[]>))([<[]>[[]()]]<[[][]](<><>)>)}[<[{{}<>}[[]<>]]>{<<()[]>{{}()}>[{<>}{()[] 80 | <[{[(<<[{[<<<<[]()>[<><>]>[<{}<>>]>>]}[([[<({}())[{}()]>{({}{})(<>)}]]([<{[][]}((){})>[{{}()} 81 | [[{[[({([<<{[{<><>}<[]{}>][[<><>](()[])]}>[(({{}{}}([][])))((<{}{}>[{}{}])({[]}{{}}))]>]{( 82 | {<[(({{<[(<[{({}{}){(){}}}<(<>{})({})>]<(<<>{}>)<{{}()}<<>[]>>>>{[<<[]{}>{[]()}>{[[][]][()[]] 83 | ({[<[{[<[{[(([{}[]]<{}[])){{{}[]}<{}()>}){[{()[]}(<>{})][{<><>}]}]{{({{}<>}([]{}))}{((<><>)([][ 84 | [[(<[{({({({<{{}[]}<()<>>>[{(){}}{<>[])]}<<<[]()>>{<()[]>({}())}>)(<[{(){}}([]<>)]{[()()]<{}>}> 85 | <{[{[(({{<{(([<>[]]{[]{}})({{}[]}[<>()]))[[{()<>}<{}{}>]<[()<>]<[]()>>]}<(<(()<>)[()[]]><[<>()}{[]{} 86 | (([(<[{[{[({<[[]{}]{{}{}}>}([<[]()>(()())]))<(<(()[])[{}[]]><[()<>][{}<>]>)<(<[]{}>]{({}())[<> 87 | ([{<[<[{{((<<{{}{}}[[]{}]><[{}{}]<{}{}>>><({<>{}}([][]))((<>[]){{}<>})>)[{[([][])[[]{}]]<[{}][<>()]>}])([[<[ 88 | [{({((<({(({({{}<>})({()()}(()()))}(<<[]{}>><(<>())({}<>)>))<[[(<><>)[[][]]]<{()<>}[[]{}]>]<(( 89 | {({{({({[{([[{[][]}([]())]<([]())<{}{}>>][[([])[{}<>]]{{<>[]}<<>{}>}])[<<{<><>}{{}<>}>>{<{ 90 | {{(<<(([<{<((<<>{}>{<><>})[([]()){[][]}]){{{[][]}[()]}[({}[])]}>}[<[<{()<>}<<>()>>]<(<(){}><()[]>){[()[]](<> 91 | {((<(<[[[<(<<[()()]<[]<>>>)({(())[{}[]]}))<{<{{}<>}>[{[]}[()]]}<<(()<>)[[]()]>(<(){}>[<>[]] 92 | <<{<<{({({({({{}()})({{}<>}([]()))}(({()[]}[()<>])[<()[]><[][]>)))(<<[[][]](<><>)>(((){})([ 93 | {<<{(<{{{{((([()[]][[]{}])[{()<>}{<>[]}]){{{<><>}}(([])[[]()])})[((<{}()>[[]<>])({[][]}{()( 94 | [((<{{(<({[<<[<>{}]{(){}}>([{}<>](<>()))>][[([[]()][[][]])<{[]<>}{[]}>]<((()<>))>]}((<[([][ 95 | (<<([(({(([[([[]<>]{<>{}})(<{}[]>[{}<>])]<([[][]][[]{}])>][<<{<>{}}<<>[]>>[<<>{}>{()()}]><(<[]())({}()) 96 | (({[{([({<<{{{{}{}}(<>())}[([]<>)(<><>)]}<{{()}}<<{}<>><(){}>>>>>}>([<((<{{}<>}[[][]]>{{<>[]}[() 97 | ([{(<([<[<([({{}<>}<{}[]>)][{[{}()][[][]]}[(()())(<><>)]>)><([<[()<>]<(){}>>{[<><>]<{}<>>}]{ 98 | [<<(<[({((((<(()<>)[[]{}]>[{<>[]}{()<>}])(<<()[]>(<><>)>{(()[]){[]<>}}))({[{()<>]{()<>}]{{()()}(<>{} 99 | ([<<{({({(<{{<()<>>(<>{})}[<(){}>([]())]}[({{}<>}([]))]>([<({}{})[<>()]><(<>[]][(){}]>]<[<<>[]>({}<>)][{<>} 100 | [<[{[[{[[{[({([][])([][])})[([{}[]][<>[]))<[[][]]<()<>>>]][<([()[]]{[]<>})>[{({}<>)[{}()]}]]}][( 101 | {<<<<[[<{{[{<[[]{}][{}{}]>}(<<{}<>>(<>{})>({<>()}<()<>>))]<<<(<>())<()<>>>><[<(){}>[<><>]>>>}}[(({(<<><>>({ 102 | <[<(<([((<[<(<{}[]>(()<>)){({}[])([]<>)}><[{[]<>}{<>()}]>][<<{<>[]}{(){}}><[()<>]{[]}>][<({}<>)>]]>)[[[(( 103 | -------------------------------------------------------------------------------- /src/day-05/src/in: -------------------------------------------------------------------------------- 1 | 911,808 -> 324,221 2 | 161,890 -> 808,243 3 | 174,59 -> 174,760 4 | 983,983 -> 10,10 5 | 321,12 -> 870,12 6 | 66,936 -> 941,61 7 | 670,141 -> 670,550 8 | 783,935 -> 496,648 9 | 973,651 -> 635,989 10 | 535,47 -> 535,154 11 | 355,183 -> 754,582 12 | 172,111 -> 892,111 13 | 353,66 -> 907,620 14 | 741,960 -> 741,805 15 | 113,895 -> 946,895 16 | 777,280 -> 563,280 17 | 679,815 -> 626,815 18 | 651,848 -> 651,673 19 | 205,834 -> 205,599 20 | 895,118 -> 82,931 21 | 685,303 -> 93,895 22 | 973,38 -> 62,949 23 | 867,23 -> 867,300 24 | 784,947 -> 784,47 25 | 96,168 -> 755,827 26 | 909,321 -> 909,716 27 | 59,881 -> 692,881 28 | 964,19 -> 69,914 29 | 752,869 -> 67,184 30 | 974,877 -> 138,41 31 | 432,389 -> 137,684 32 | 458,822 -> 458,402 33 | 818,852 -> 308,342 34 | 882,484 -> 441,925 35 | 82,959 -> 976,65 36 | 117,487 -> 117,429 37 | 214,673 -> 429,673 38 | 72,955 -> 72,829 39 | 587,109 -> 587,368 40 | 576,17 -> 576,872 41 | 685,102 -> 685,905 42 | 563,394 -> 716,394 43 | 966,145 -> 150,961 44 | 555,582 -> 555,385 45 | 453,31 -> 453,207 46 | 639,815 -> 547,723 47 | 431,869 -> 431,811 48 | 646,938 -> 599,938 49 | 215,513 -> 900,513 50 | 809,82 -> 798,82 51 | 768,344 -> 244,868 52 | 39,962 -> 39,601 53 | 675,186 -> 61,186 54 | 861,967 -> 28,967 55 | 860,550 -> 538,550 56 | 283,740 -> 571,740 57 | 72,297 -> 72,645 58 | 727,801 -> 727,526 59 | 799,519 -> 799,497 60 | 915,24 -> 174,765 61 | 795,943 -> 136,943 62 | 518,971 -> 599,971 63 | 594,676 -> 594,461 64 | 850,799 -> 363,799 65 | 958,575 -> 958,231 66 | 752,576 -> 398,576 67 | 891,433 -> 398,433 68 | 524,126 -> 397,126 69 | 10,890 -> 796,104 70 | 57,228 -> 168,228 71 | 168,521 -> 338,691 72 | 230,83 -> 777,83 73 | 865,677 -> 640,452 74 | 866,821 -> 825,821 75 | 17,143 -> 17,596 76 | 113,916 -> 113,601 77 | 268,187 -> 551,470 78 | 794,167 -> 220,167 79 | 459,17 -> 459,931 80 | 211,31 -> 526,31 81 | 680,57 -> 756,57 82 | 926,190 -> 926,800 83 | 85,284 -> 63,284 84 | 44,988 -> 44,701 85 | 110,941 -> 176,941 86 | 480,163 -> 480,112 87 | 574,538 -> 574,371 88 | 584,473 -> 69,473 89 | 303,621 -> 303,380 90 | 762,652 -> 762,89 91 | 286,195 -> 276,185 92 | 957,87 -> 217,827 93 | 561,858 -> 561,437 94 | 384,55 -> 81,55 95 | 19,977 -> 981,15 96 | 454,747 -> 938,263 97 | 425,836 -> 425,617 98 | 860,135 -> 775,50 99 | 633,131 -> 633,651 100 | 904,912 -> 242,250 101 | 880,177 -> 480,577 102 | 470,162 -> 964,656 103 | 585,376 -> 585,470 104 | 696,760 -> 594,862 105 | 534,225 -> 534,717 106 | 258,816 -> 258,847 107 | 990,244 -> 990,93 108 | 463,462 -> 463,533 109 | 434,928 -> 537,825 110 | 813,734 -> 533,734 111 | 498,673 -> 395,673 112 | 564,312 -> 55,312 113 | 280,550 -> 939,550 114 | 591,247 -> 396,52 115 | 127,516 -> 127,235 116 | 850,425 -> 552,127 117 | 894,428 -> 894,598 118 | 366,960 -> 592,960 119 | 579,488 -> 170,488 120 | 775,92 -> 775,586 121 | 49,909 -> 930,28 122 | 856,113 -> 284,685 123 | 263,175 -> 120,175 124 | 332,592 -> 276,592 125 | 920,157 -> 141,157 126 | 349,776 -> 316,776 127 | 187,863 -> 279,863 128 | 218,872 -> 83,872 129 | 465,430 -> 410,430 130 | 710,218 -> 857,218 131 | 797,314 -> 184,314 132 | 387,327 -> 49,665 133 | 950,812 -> 205,67 134 | 803,133 -> 803,682 135 | 125,972 -> 545,552 136 | 353,901 -> 840,414 137 | 936,843 -> 202,109 138 | 11,904 -> 856,59 139 | 725,757 -> 954,986 140 | 227,697 -> 345,697 141 | 187,520 -> 187,441 142 | 860,262 -> 135,987 143 | 700,95 -> 976,371 144 | 86,946 -> 869,163 145 | 898,806 -> 461,806 146 | 717,796 -> 717,195 147 | 882,127 -> 835,127 148 | 133,48 -> 133,191 149 | 521,51 -> 521,927 150 | 384,806 -> 957,233 151 | 570,139 -> 570,842 152 | 949,819 -> 949,350 153 | 592,230 -> 283,230 154 | 315,856 -> 741,856 155 | 870,674 -> 549,353 156 | 857,306 -> 857,889 157 | 428,217 -> 267,217 158 | 47,93 -> 898,944 159 | 636,238 -> 665,238 160 | 202,910 -> 202,737 161 | 246,432 -> 617,803 162 | 985,24 -> 48,961 163 | 965,876 -> 956,867 164 | 618,650 -> 810,458 165 | 292,356 -> 575,356 166 | 394,585 -> 910,585 167 | 137,453 -> 137,178 168 | 509,737 -> 509,665 169 | 193,350 -> 531,688 170 | 805,219 -> 107,219 171 | 975,506 -> 907,506 172 | 435,303 -> 435,380 173 | 344,83 -> 344,224 174 | 47,66 -> 47,115 175 | 570,516 -> 857,516 176 | 162,91 -> 926,91 177 | 759,417 -> 759,460 178 | 445,942 -> 445,699 179 | 421,340 -> 421,743 180 | 590,590 -> 434,434 181 | 453,38 -> 453,327 182 | 865,134 -> 865,773 183 | 842,609 -> 18,609 184 | 662,282 -> 62,882 185 | 489,32 -> 344,32 186 | 135,496 -> 93,454 187 | 552,211 -> 421,211 188 | 620,678 -> 642,678 189 | 782,158 -> 585,355 190 | 733,509 -> 733,574 191 | 932,383 -> 369,946 192 | 843,705 -> 843,725 193 | 747,414 -> 676,343 194 | 294,218 -> 962,886 195 | 844,175 -> 844,420 196 | 255,489 -> 531,213 197 | 555,532 -> 821,532 198 | 533,15 -> 533,161 199 | 631,778 -> 631,401 200 | 75,282 -> 468,282 201 | 903,838 -> 903,957 202 | 46,293 -> 543,790 203 | 30,834 -> 30,948 204 | 591,720 -> 591,965 205 | 624,36 -> 339,36 206 | 425,323 -> 425,442 207 | 234,939 -> 234,963 208 | 482,912 -> 968,912 209 | 228,614 -> 189,614 210 | 969,472 -> 969,692 211 | 871,494 -> 871,172 212 | 101,624 -> 848,624 213 | 424,918 -> 69,563 214 | 929,671 -> 93,671 215 | 81,187 -> 707,813 216 | 348,923 -> 348,924 217 | 921,524 -> 921,828 218 | 678,454 -> 678,364 219 | 904,227 -> 904,596 220 | 163,344 -> 609,790 221 | 206,180 -> 206,59 222 | 145,519 -> 145,717 223 | 317,679 -> 317,417 224 | 503,724 -> 221,724 225 | 353,448 -> 413,448 226 | 363,643 -> 837,643 227 | 594,54 -> 359,54 228 | 866,117 -> 45,938 229 | 939,210 -> 284,865 230 | 410,556 -> 410,801 231 | 905,111 -> 673,111 232 | 983,167 -> 574,167 233 | 595,758 -> 97,758 234 | 785,10 -> 437,10 235 | 517,414 -> 517,734 236 | 691,567 -> 186,62 237 | 842,51 -> 31,862 238 | 36,199 -> 282,199 239 | 864,758 -> 864,610 240 | 639,918 -> 951,918 241 | 245,516 -> 245,474 242 | 951,203 -> 557,203 243 | 176,728 -> 176,171 244 | 322,217 -> 387,217 245 | 149,208 -> 836,895 246 | 661,298 -> 609,298 247 | 46,47 -> 981,982 248 | 769,45 -> 769,610 249 | 988,932 -> 988,459 250 | 901,97 -> 901,908 251 | 195,395 -> 121,395 252 | 197,403 -> 327,533 253 | 159,456 -> 857,456 254 | 480,981 -> 881,580 255 | 86,958 -> 962,82 256 | 375,198 -> 763,198 257 | 950,381 -> 341,381 258 | 504,679 -> 504,598 259 | 756,659 -> 680,583 260 | 146,328 -> 886,328 261 | 930,412 -> 492,850 262 | 954,54 -> 954,940 263 | 790,498 -> 790,305 264 | 83,270 -> 83,242 265 | 939,268 -> 939,563 266 | 423,756 -> 916,263 267 | 583,756 -> 583,34 268 | 957,639 -> 614,639 269 | 484,523 -> 521,560 270 | 497,809 -> 497,419 271 | 76,17 -> 979,920 272 | 49,39 -> 943,933 273 | 110,289 -> 110,247 274 | 874,868 -> 874,172 275 | 576,127 -> 53,650 276 | 871,879 -> 12,20 277 | 436,711 -> 592,711 278 | 132,285 -> 225,285 279 | 245,147 -> 514,147 280 | 158,882 -> 956,84 281 | 21,984 -> 937,68 282 | 42,275 -> 219,275 283 | 877,143 -> 889,143 284 | 593,841 -> 508,756 285 | 414,289 -> 132,289 286 | 687,655 -> 767,655 287 | 453,981 -> 459,987 288 | 635,433 -> 635,324 289 | 671,347 -> 170,848 290 | 412,579 -> 915,579 291 | 269,677 -> 269,596 292 | 587,121 -> 367,341 293 | 153,883 -> 153,709 294 | 524,580 -> 508,580 295 | 541,232 -> 651,232 296 | 93,948 -> 284,757 297 | 168,745 -> 872,41 298 | 831,657 -> 925,563 299 | 908,389 -> 442,389 300 | 462,445 -> 234,445 301 | 735,493 -> 895,493 302 | 274,624 -> 296,646 303 | 153,130 -> 153,160 304 | 466,214 -> 466,769 305 | 474,499 -> 686,711 306 | 540,428 -> 788,676 307 | 858,215 -> 959,215 308 | 788,91 -> 788,410 309 | 552,505 -> 988,505 310 | 978,312 -> 978,202 311 | 108,321 -> 616,829 312 | 903,359 -> 903,770 313 | 480,331 -> 480,769 314 | 503,842 -> 34,842 315 | 613,732 -> 323,442 316 | 767,949 -> 654,949 317 | 514,589 -> 386,589 318 | 38,554 -> 284,308 319 | 689,268 -> 689,711 320 | 860,66 -> 190,736 321 | 253,865 -> 622,865 322 | 87,658 -> 698,47 323 | 506,892 -> 829,569 324 | 680,910 -> 594,824 325 | 824,603 -> 958,603 326 | 576,802 -> 562,802 327 | 67,27 -> 67,489 328 | 969,461 -> 517,913 329 | 674,763 -> 674,226 330 | 223,955 -> 218,955 331 | 147,540 -> 569,962 332 | 455,703 -> 596,703 333 | 746,899 -> 746,403 334 | 516,476 -> 756,476 335 | 897,674 -> 373,150 336 | 120,395 -> 120,49 337 | 722,443 -> 722,244 338 | 724,924 -> 724,39 339 | 809,930 -> 109,930 340 | 822,816 -> 874,816 341 | 796,539 -> 895,539 342 | 340,88 -> 560,88 343 | 223,158 -> 593,158 344 | 779,977 -> 856,900 345 | 617,461 -> 973,817 346 | 515,62 -> 515,140 347 | 12,586 -> 724,586 348 | 870,50 -> 391,50 349 | 308,123 -> 308,696 350 | 119,164 -> 863,908 351 | 755,599 -> 448,599 352 | 129,526 -> 633,526 353 | 478,668 -> 102,668 354 | 237,637 -> 237,743 355 | 270,102 -> 72,300 356 | 115,470 -> 115,427 357 | 948,233 -> 948,731 358 | 983,135 -> 468,650 359 | 748,439 -> 748,642 360 | 62,862 -> 352,572 361 | 765,901 -> 660,901 362 | 917,807 -> 917,587 363 | 55,81 -> 116,81 364 | 954,972 -> 102,120 365 | 340,503 -> 294,549 366 | 970,661 -> 522,213 367 | 618,92 -> 618,247 368 | 688,965 -> 965,965 369 | 94,241 -> 94,292 370 | 15,132 -> 15,492 371 | 979,927 -> 488,927 372 | 509,26 -> 984,26 373 | 840,530 -> 840,95 374 | 55,956 -> 849,162 375 | 297,297 -> 297,472 376 | 338,780 -> 369,780 377 | 487,292 -> 37,292 378 | 122,117 -> 206,201 379 | 66,807 -> 564,309 380 | 643,242 -> 906,242 381 | 909,833 -> 909,441 382 | 129,128 -> 818,817 383 | 406,42 -> 406,297 384 | 53,20 -> 967,934 385 | 235,285 -> 601,285 386 | 275,625 -> 275,539 387 | 199,732 -> 430,963 388 | 639,187 -> 639,265 389 | 549,740 -> 549,824 390 | 603,140 -> 603,748 391 | 35,455 -> 176,455 392 | 888,611 -> 888,271 393 | 134,154 -> 484,154 394 | 694,820 -> 694,814 395 | 535,584 -> 187,932 396 | 642,510 -> 642,249 397 | 191,886 -> 268,886 398 | 918,353 -> 881,390 399 | 977,13 -> 343,13 400 | 380,243 -> 271,134 401 | 410,758 -> 410,670 402 | 613,551 -> 519,645 403 | 963,84 -> 124,923 404 | 702,252 -> 821,252 405 | 405,237 -> 405,22 406 | 21,139 -> 21,510 407 | 548,499 -> 132,499 408 | 196,104 -> 196,680 409 | 739,145 -> 476,145 410 | 751,746 -> 91,746 411 | 975,628 -> 975,847 412 | 935,520 -> 935,450 413 | 803,372 -> 803,393 414 | 872,77 -> 872,373 415 | 339,130 -> 339,103 416 | 226,886 -> 226,45 417 | 794,647 -> 794,257 418 | 90,922 -> 889,123 419 | 615,971 -> 615,574 420 | 26,278 -> 26,719 421 | 838,88 -> 806,88 422 | 263,691 -> 804,150 423 | 309,721 -> 910,721 424 | 510,496 -> 960,946 425 | 195,236 -> 46,236 426 | 610,143 -> 610,610 427 | 891,412 -> 891,268 428 | 714,21 -> 156,579 429 | 320,935 -> 320,96 430 | 240,782 -> 449,782 431 | 754,472 -> 48,472 432 | 105,481 -> 529,57 433 | 451,301 -> 451,965 434 | 796,638 -> 796,185 435 | 908,553 -> 771,553 436 | 98,543 -> 490,935 437 | 481,159 -> 762,159 438 | 593,527 -> 419,353 439 | 86,391 -> 216,521 440 | 260,716 -> 42,716 441 | 734,538 -> 375,179 442 | 24,974 -> 975,23 443 | 402,466 -> 787,851 444 | 344,409 -> 262,327 445 | 803,443 -> 685,443 446 | 986,152 -> 249,152 447 | 125,738 -> 90,773 448 | 184,772 -> 184,746 449 | 729,829 -> 729,340 450 | 226,527 -> 226,375 451 | 936,231 -> 222,945 452 | 254,333 -> 254,167 453 | 451,234 -> 451,273 454 | 915,790 -> 568,443 455 | 869,794 -> 504,429 456 | 11,878 -> 836,53 457 | 821,231 -> 522,530 458 | 285,419 -> 732,866 459 | 191,272 -> 191,679 460 | 41,651 -> 225,651 461 | 30,13 -> 879,862 462 | 980,488 -> 20,488 463 | 27,187 -> 27,348 464 | 53,238 -> 53,514 465 | 778,306 -> 379,705 466 | 425,399 -> 425,60 467 | 162,859 -> 57,859 468 | 652,926 -> 652,589 469 | 962,489 -> 555,896 470 | 197,378 -> 436,617 471 | 310,190 -> 310,760 472 | 678,20 -> 678,713 473 | 390,653 -> 985,58 474 | 938,351 -> 656,69 475 | 881,39 -> 18,902 476 | 313,681 -> 323,681 477 | 910,907 -> 288,907 478 | 739,977 -> 739,132 479 | 856,479 -> 154,479 480 | 893,785 -> 761,785 481 | 405,247 -> 405,901 482 | 58,933 -> 808,183 483 | 643,156 -> 676,189 484 | 149,773 -> 357,773 485 | 479,518 -> 434,518 486 | 389,518 -> 556,685 487 | 858,449 -> 533,774 488 | 503,133 -> 409,133 489 | 340,315 -> 219,194 490 | 183,701 -> 183,242 491 | 810,151 -> 195,151 492 | 446,686 -> 446,912 493 | 968,482 -> 49,482 494 | 203,20 -> 203,667 495 | 493,516 -> 647,516 496 | 900,91 -> 634,91 497 | 660,554 -> 119,13 498 | 964,864 -> 964,919 499 | 871,293 -> 344,293 500 | 895,258 -> 972,258 -------------------------------------------------------------------------------- /src/day-08/08.txt: -------------------------------------------------------------------------------- 1 | dfgabce cadfgb cefa ca aecbg dfcegb geabd ecbfg cab agcfbe | egbfadc dbgae gcfeb abgdfc 2 | fbcag eg dbge gcbfe acdgfe gec fdcegba efbdc fbedgc efabdc | ge fagbc dfebc eg 3 | da gdbcea gdcfbe acgbd dbfcgea ebad aecdfg afcbg adc ecdbg | afcegd dacebg ad cdbafeg 4 | gafeb ag acfbed ega ebadfg bfcge dgfa begcda edfba cfgedba | ag dafg dfcbgea feacdb 5 | cefdag gcea fag defca gbdaef afcdg dcbgf ga adfecbg fcbdea | geac cfedba cgea fadecg 6 | fcgaed abdecgf cfaed ceb febacd dbecf bc cbfa gecbad fbdeg | facde cfgade acdefb cbe 7 | bcgae cfedba efcbadg dafbc dfbe fcgbad ef aefgcd acfbe fea | abfcd cafbd fbde dcgbaf 8 | geabdc fedga cafdbg cd aefcbg adcge dac bdegafc cegab dceb | dcfgba cad cad deabcg 9 | gdecab fde aecf adbgfe egdcaf dgaebcf decfg bcfdg ef ceadg | cefdabg fcea efac edf 10 | cbgaf edfa bfgecd fcdbae debca dfb bcdaf bdcaeg fecgadb fd | cafdgeb gabcf df afdebc 11 | fdebgc egdfb bfcdg cfedgab fdeagb egcb fcb cfdeba cb fagcd | gebfd afdbgec bc gdcafbe 12 | cb gcdefa cdb bacg eabfd ebdac gdabec gcbefd bgdecaf caedg | cgdeab ebfdgca edgbca cbefadg 13 | efbc aecgbd ebgdfa ecbag afb cfgeadb bf cadgf bgfca egcabf | bf agdbce fab bfcdeag 14 | cedafg aecdbg fcd cgeda cdfag efcg agfdb defcab fagcebd cf | adgcfe daecg abcged fgedbca 15 | bcgaed cfdgea caebd gdebc bega fbecadg ge fcdaeb gde gfbdc | gabe eg cadebf ecgadf 16 | aefc abefg acfbge agedbf dbgce cab abgdfc ecbga ac bfdceag | beafgd ca ac ac 17 | afbde fedag becda dacegf baf gacdbfe fcabdg fgeb fgdabe fb | fb afbdge bcdea fedacbg 18 | bfd cdgbfa dgefca fabdeg cgebdfa cabd gfcda cbgef db dgfcb | bd badegcf acdb adegcf 19 | ef cfbgd cdbfe bef ceadb bfcgead aedf edbagc abgcef aecbdf | bcfegad bef bef fe 20 | cbagef beadgc fae deacb fcagd cgdebfa dfeb bdecaf fe fcdae | dfaceb efdb beafcg bdef 21 | gdfeacb bca gfeacb gfeca egcb bc dgeacf fabgd fbcdae gcbfa | bfdeca bca adbgf abdgf 22 | faedbc egcaf bdgaf agdebcf fagcb cab bcdgaf dbgc fbgead cb | bdgafc cb dgbfa bgcd 23 | dfabc bgacde ad dab edfa bdfec dbgefca facgb eacfbd fcgdeb | ecdbfag bedfc ebfcad bfcdge 24 | dfegbc cfagb ba gefbc abec bfcdega bfa egadbf fgbcea fgcda | eafbdg ebfgc fgbdcea ba 25 | fgdebca dgbcea adbce cfaedb acebf ef efc cfabg edgafc fedb | fdeb fce gcfab bafgc 26 | cfdg daefgcb caedgb aefbc cbdag fg fdbgac fbg beagdf fbcga | dgfc fecgabd fgcd gbf 27 | cbadef abgdef cfea ac gedbc dcbafg dca fdbecag dceab deafb | eafc ebfdga cefa abcde 28 | fcbged ebdca bde ceagb abcdfeg bd cdaef cgabed ecgfab bgda | baecd dgbcea ecafd dbag 29 | bfeag cdabf dbeacg dgbcefa eda fdabge bafde ed egfd ebcafg | ebfcadg defg fadbe cfbgea 30 | bfd dgbec gfcadb ecdf aefbg cfbgead fd gcbdfe debgf gcdeab | ecdbga aebgf abcfgde fd 31 | ecgfda bcafe dgbefca dagcb dfc acdfb cdabfe cebfag fbde fd | bgdefac cfd febgac df 32 | dcafb dgafcb dbeacf bdga degbcfa cgbaf ga fga efdgca cegfb | ag beagdfc abcfg gcdeaf 33 | cgbfd fegcba ecgfb cbe dafebg bdface gace ec fcgdeab eagfb | gcdfb acge ecb cebgf 34 | adbcgf ef fged feb dabfgce bdgfc becfgd dcabe febgac bdfec | cgdbf fdcgeb afcbge fbdgc 35 | cg dagfc dfagbc cgab dagbf gbdcfe dgc aefgdbc aecdf bafegd | cg gfacbed bfgad bgacfed 36 | cadfeg cfdegba edagcb fae faebc decfb fa aebcg fgba egafcb | baegc fa acfbe af 37 | fed bcdge fcbae gbfd gfabecd cdaegb df egdfac egcfbd becdf | cadegf edcgbf fcbde dbgf 38 | fadcg beafcd cedbag edabg abdfge bdagf fba dgcbaef fb fbge | deafcgb dfcaeb geadfb ecfgdba 39 | bec fbcea cgbf bfgcea cdefa cgadeb cb fdbeag bdaegcf fgabe | ebfacg bgcf cb bc 40 | gb agdbce efacgd cgdfbe agdec afcdb ebag gcb eadfgcb bdgac | efcbagd bedcag bgc baeg 41 | fbe dcbgae cedgfba bcgefa bfdge bf dafge edbgc fcdb bcfdeg | bdfc fdabgce ebgfd fegbd 42 | fb abfdge fgdca fedcag bafcgd bfg gdeabfc fbgac eagcb bcdf | gacfedb fb bf fcadg 43 | bg eadgf bcdea gbd gebda edgbac cagb dfecab fgcbead ecfbgd | gbedca adfebgc acgb bdg 44 | adgfce begafc gfeac cde cgabd ed becdfa gfed egfbcda egacd | ed cgeda dfeacb dec 45 | agefcb gadec gdbafe dg cebafdg dcfg ecagf edg gdeacf ceadb | dgaefc egcadbf cdfg faecg 46 | fdec gcbdaf bafedc cf dbegac ceabd gbadecf fca gbefa bacfe | fc fdce acf afc 47 | fdecg gdefcba cg dbcfe dfbeac gcfedb daefg facdgb gebc cfg | begafdc fcdebag dbcgaef gfc 48 | adcgef agbdfec dc ecad cgeabf edfbg bcdgaf fdgce ceagf cdg | cdgef ecda cade cd 49 | abdefc bdaecfg dgeacb fb gfade bacde bdagcf fdb becf adbef | fcbadg cefabd fdb edfga 50 | efcgab bead fcdeg ae cgdab dgcbae aeg edgca bcegdaf gdcfab | gdafceb ea eag aeg 51 | dceafb befac fca cf fdcb cadgef bedaf ebagc aedfbg acgdbef | beadfc cf cfeba gbeca 52 | gce eacgbd afcdbe eg dfcebga bedca gfbca agfedc gcaeb gebd | gdbe ge ge gbde 53 | bcgae bedgfca gde ed gdaec gbfcad cgbdef gdaecf edfa gfadc | cdbfeg bgdfac cfdeag adgfbc 54 | gebca dbacfeg dbfeag bagfe eadfb gf fdge fbg dfceba gafbdc | egfd fedg egafb gf 55 | begfadc bdcae dgbca edbf acbfeg fcgead be eba afdce aedcbf | bfedac edcab eba fdbace 56 | fdbgc cegabf ac dfbage bgfae faec gac caedbg bfgedca bfagc | acef dfgcb face gbafed 57 | cdbfge bfceg dgacbe baegfd ecb dfceabg ebdfg cb acfge bdfc | cbe gcbefd egdcba eafbdg 58 | fecdb dgbcfae bedca edf ef cfebgd ecgf gfdbc fdbagc afbged | aedbgf ef fecg fagcbd 59 | gdecfb fbadge cabe adfcg efcbd ea gbeacfd fcedba dea fdeac | acbe acbe dea fcgedba 60 | bg dgfac gabdec dgcabef beafc gfceab cgb bafcde fegb cgafb | bcg bg fdgca faebcg 61 | adfgc dfcbge dgafbc gaf acfb dgcea gebcdaf fbgdea fbgdc af | fa agcdf fga gfebda 62 | defag begdf fa becgda aef afcg dfaceg cgdae eacdfb acefbgd | cadfeb edgaf fa ecadbf 63 | fec edfbc fagecd cgdfb ef fcabdg cedba fbecdg bfge faegbcd | befdc dbfecga acgdbf gcbedfa 64 | ed cedbfg bdfac fdeac baed fde eagcbdf abgfdc feadbc gaefc | fdbca de cgbdfe de 65 | fcbga ge cagbef acebfdg egbf acbge ceg egcdfa bagdcf adcbe | cgfab ecg ebcda afgcde 66 | df fadcbeg gcfbde dcagb fbd afgdbc cbeagd dfcab cafbe adfg | eagdbcf fgda cgbda gbfced 67 | agef bgdcaef ade adcbf gdbace cefdg febgdc cgefda fedca ae | ae afdgec febgcd agcdeb 68 | gfbc fdg dbaef fg aefgdcb gefdac gebcd dbegac fegcbd fbedg | cfgb gdebc cbaefdg fgd 69 | ebfgac gcf geabdfc cegbda fgade bcaeg fcba cf fdecgb ecafg | cfg fgc acfgdeb gdabfec 70 | gafeb ebdgac ed cgbfad cgeadfb bdecfa bfcda fabde aed ecdf | bgfdaec fedcbag de fedc 71 | age ebcdfg afcdeg dcfeg efadgbc fgad becad ag eacgd gabecf | ag gcdfbe agecd fdgce 72 | aecfbd geb afbde fdgeab gfeba ebgcadf bg gdbf fgeac bceagd | eacdgfb bge edabcf ebdaf 73 | cgabe aefbcdg fagdce abcdfg dcbe aecgbd cge fbaeg ce dcbga | bgacfed gafcdb egc egc 74 | bdefa fagbd fabdce cdae fceagb deb fbdecg fcbea de agedbcf | fgdcabe afbde bde gfcbde 75 | dgfcea dcbea dabcf edcbga cedafb gfabc cgdabfe afd fd dbfe | debf egdacb dbef edabcg 76 | bfdea adfceb fgcbae feg fdebg bagfdce egcdb fedagb dgaf gf | bgdfea gef cdebfag edcbgaf 77 | ade aefgdc ea feac gefdc eacbdfg eabfgd abcdg efbdgc geacd | eafgdc fgebad cbdefg cdefg 78 | egfdab edfb agfec dbcage ade ed badcfg gfcdeba afedg fgadb | aedbcg bgfda aed dae 79 | cfdbge abgc afgbe cb bcf ebfdga adecf efbacdg agfbce bacfe | bfc fbc cfb bfc 80 | gd bgd gcafeb dfcbage ebfgcd egfbd decg gcafdb aedfb ebgfc | gdec gefbacd gdce dg 81 | gf dbegac becgadf dfge facbe gfa acdgfe ecgfa dcfbag gceda | gfed cefba cabfe acedfg 82 | fd cdbagef fdgbec daebcg dfba fbacdg cdf cfadg gabdc gfcae | agecf cfd cdf egcbad 83 | dfca adgefb fbced cfdbge fa egcabfd eabcf eabfcd cabeg afe | acfd dbecf af af 84 | agfdec dfcag edgacfb baegfd fd gfaecb dacgb ecfga dfec daf | gabcd ebcgadf fbegac fgace 85 | edafg gcfea cbaeg afcdgbe fcde fc acf cedagf begfda cdbfag | cf daecbfg bgace dcgabef 86 | bdefagc gcba bfacde adbce ga dgefc cagdeb dgeabf aegdc adg | faecdgb gda ag dga 87 | becdag bceadf edcab dgacb bdgcaef gd dga cedg agbfc dafebg | gd gced gad cgabd 88 | gbfaed bdacf db fcabg ecfda edcb adcfge adb abcfed cgedfba | bad dba fdecgab edacf 89 | ae cabe ecgafb dfgce afbdge gdacfb bdegfca afe agfcb cegfa | ae fgdeab gcfed cgdfabe 90 | ad fdbcg cbfea fdabgec dca cgadfe fbdac dbag gbcfde bgcfad | dbagfc dac ad cbfdge 91 | fdgbaec ab dabe cabegd cgaed bcdag bgfdc gebcfa agb cadefg | efbgac dcgafe dagecb gba 92 | cafbge gdbfac aefcb adfcegb daefc bacge gcabed febg fb bfc | bfcgae gebf bfc abgcdf 93 | dfbgca bfcae ebc ebfdac eb eadfgcb dfeb edbagc fdcba gfcea | becadf ecb bce badcf 94 | cdefa adcgfe fdceb eacdfbg adf ad fcgea deag gacbfd aecfgb | da dega adcebfg acdbefg 95 | dace dcebg adbcfg abdcg de dceagb fcbeg fbacedg bdeafg deb | bed cabgd ed fecbg 96 | edabgc fdbaegc gcadfe afed fcd gecbf fd fgdcab fedcg dgace | gaecd bdgcaf gedfcab fead 97 | gfbae bgefdc cbfgdae dbgfea abgc bc aecbgf adfce bce afbce | aedgfbc bacgfe bcdefg gfbea 98 | cadeg cagdfb bdc bfcedga cgbafe facbe efbd edcba bafdec bd | dbc agdce efdacb bcd 99 | ac fegacb bac afdc aedfbc defba dgefba gcdeb edacb dcbeagf | egdbc egcfbad decba adfc 100 | bcfdag cgfdbea dce gbcfd ed bgced dfbgec gcaeb fcbead dgfe | defg edc gecdb de 101 | eb fbe afdec bfgda cdfbgae fbgcde aedbfc deafgc ecab efdba | aegcdf fedgcab edcfbag be 102 | cfabg aceg gba fcebda egabfc cbaef acfbdeg ga gcfdb adbfge | cgae abg gace dfabec 103 | fabe af fdaeg bdega fdceg adbfge fad gcedbfa dfgbac aedgbc | afdgceb aebf dfa cgbaed 104 | ecgdf bfcagd dcegb gafdc efac feadbgc agcdef eagbfd fge ef | ef egf dcgfa decgf 105 | ag ecbga bga fdegab gbdcfe gbecf afbecg ebdac edacgfb cagf | gafc ecgbf bag eadgbf 106 | dafe fe cef agdebfc fecdg bedcg bdcafg beafcg dcegaf fdcag | dafe fcdag afdgce adef 107 | gefac dagcfe age facdegb acfbg edfa ea edfcg egdcab fcbgde | gcefa ea aebdgc ecfga 108 | cdfbea debgca adbec bgfadc cdg ceadg bgce gc gfaed fcdgeab | cg cgd afdcbg cdg 109 | gcbefda fdcga cfdebg fgdabc abgd fdbcg cabfde fda efagc ad | dgcfa bacfed cfbegd da 110 | cgbaed bcdefg ebdca dcabf feabcdg cgae deabg ced ec efgdba | bgdfce ceag cde dbegac 111 | debgfa gbdce ecdgbf ag agdc bga acdgbfe bceag cbaef cebagd | bga ga gaceb abecgd 112 | dbgcef eafgb fcdeb bdfcae fadc ac degabc agbcefd abfce cba | fcedb cebdga dacf dafcbeg 113 | bag gceb cbafd bg bgfaec dfgcae cbagf gceaf dfageb bcafegd | agb gb gb fedbagc 114 | gadce gecdf cgf egbfd beagfc afdc dfcageb cf bcgdae dgefca | fc gfc eacfdg cgf 115 | dabcfg ebadf cf cebag fbc eagfcb bcegad fgce eabcf ebcgdaf | feacbdg ebadf adfbe fc 116 | ad fgeac afd bfagcde afbcde gdca debgf adgfe fbagec cfaged | adcg adgefc ad adgcef 117 | fcdbeag fdbage cadf daecb bgecd bafce bda ad cdbaef eacbgf | ad caebdf gbcefa bcade 118 | efbgca cabdgef fabcd dafec bf afdgcb fab agcbd fgbd dgceab | fba fb dcagb dbfcag 119 | bea cbfag agefdc cdeb gbadcef aefgdb eagdc cgdeba egbac be | bgace eb be cbde 120 | acbdeg cefda fb cfbaeg ebf aefcb gbfc ceagb cegbfda gebafd | agcfbe afdec fbgc dfcegab 121 | bc cgdab gbfcad ecbdfa cbd fgdac edfacgb dgaeb afecdg bcgf | fcbg dbc dcafgb bcgf 122 | aedf dga cgfbde fgbde cfbgad dabegf cfgabde geacb bdaeg da | dfea agd baecg gcaeb 123 | gc cefga dbefac bacedg afedg afcbe becgaf bcgf bdgfeac cag | cgbf bgcf dabceg gc 124 | db cdegf gcbfd afgbc dgcfba cbgaef dgba fgebacd fadcbe fdb | fgebac bd fdegc db 125 | debgafc dacbeg fdg cgdba fdagcb eacfg bdcf gafbde fd dcagf | fbcd bgcefda cafbged dfbc 126 | fcab gdbef begadc fdecga abdcefg bafgec cb cbe efbgc egacf | bce gcfeb cgbfade cbaf 127 | aedg agfebcd abfge fge cdbefg eg dgcfba gdebfa acbef gafbd | agdfbc baefc efg gbfea 128 | cdgab cbfedga eacbgd cf dceafg cadgfb fdc efbdg bcfa fdbgc | dfc fc cdgbf gcbadf 129 | gce eg edcfagb eacgdb bfegdc cdgaf ecgad cebadf eagb cedab | dcbae cdafg gedacfb ge 130 | dbeagf gfbda fdebgc gabfdc afbgc cgbea fc cdaf ecadbgf fcb | cfgedb bdagf fc gbecfd 131 | bdcefg egcfab acedg fcdb fbgeda bec cebdg deacbgf cb ebdfg | bc decbg eacgd bdcf 132 | dfgeab cegba facbegd edg dfgceb gafcbd edbgc gfcbd dcfe de | bdceg fecd cedf defgcb 133 | egfb dfgace cfgaebd befac adcgb aeg ge cebag bgface bdacfe | cgbea cgbae cbdgaef afebgc 134 | de efd efdbg efabdcg fgaceb bfgdc fgabe edgfab ebda degacf | fecagd ed adbe de 135 | fedbga gc gec gaefd ecagf gecbda bafce cgfead cgdf cadfbeg | gafed gcfd cgfd gcfd 136 | bedfgca ebfdc acgbfd cfb dfbeg decaf bc dabefc beac aedcgf | debgf efacd cb bc 137 | edgcba eg dbfga acfgeb cdbea bcfdaeg dcge gdeba dacefb egb | efgdacb cgeafbd gfadb gedc 138 | bacfde dgcefa eabdf acfebdg afgdbc dba aedfc aebgf db bdce | db afecd agcdfe agfedbc 139 | dga cgadb cdbge bfgca edab ad cbgade efbcdga afedgc ecfgbd | ad dgecb ad bdgac 140 | abfdec dacfegb faecg cbge acgfb fcgaeb bgfda bc bfc fgcdae | cgeb fgaecb cbeg gadbefc 141 | ea ecgbfda eacb efa facegb bgfea ebfdg gfbac edcgaf gcdfba | gabfe bgfeca ae cabe 142 | ecf bfged cebfgd adfebg dfabec cgdf gbeca cf bdfcgea bgfce | cdfgeab gdbfe daebcf bcagdef 143 | ebf efbdc bf bfcdge dgcfea bgfc cedab begdaf egcdf befdcag | ebgcfda gdfaeb bf ecfgd 144 | egcdf ecafg afebdc df dgfa agfecd cfbdgea ecgafb gdceb cfd | cdf cgadef acfgbde defgc 145 | gbdeacf bfcdg cag acdgf efdbcg ac fagdcb gbfeac bcda edfga | agc gaedf abdc cag 146 | cfgd edbcfg gfebc begcdfa acebgf ged dbace faedbg gecbd gd | bagefc dgefabc defabg becgf 147 | gcbe ce ebdfa cae bdcagfe bgdac gdeacb cbdagf dbace caegfd | ec acedb gabcd bcagfed 148 | efdgba cgabfed ec caef ceagb fbega cbgda ebc afbgec ecbdgf | afegdb gacbd dgefab edafgb 149 | ecagd bfdec fabdce bda beadc gfeabd bdfeacg afbc gecbfd ba | becdf dcaeg gcdea adb 150 | cefb cfabdg dbf bfeacd baged bf baefd gaecfd cbfaedg fecda | bf fedac fdgecba bdf 151 | gce gdbcae fecd efcbgd fbdacg eafbg cefgb cbdfg ec fgdacbe | cge ec bgcfead ceg 152 | deagfb af efca gfecad dfa bacdg cfdegb fecdg egdacfb dfcag | fdgce af edbgafc fdgce 153 | fagdce ebd abdegf defba cafebdg eb daefg dfbca ebga defcbg | afdeb eb bde egba 154 | bafed aecdb fbce cbd gdebafc cfbadg badegf bc ecdfab gecad | dbc dbc badgcfe fdgeba 155 | fgbec bfacde ge edgcfb cgdbfae fdecga cfbga efg dbge cdfeb | bedfcg eg ge afebdcg 156 | dcaef ag gcab aeg acedg edgcb efgdacb cgfbed dafgeb agdbec | bedagc bdegc dfcebg adecf 157 | dcfg abecg bgadc dg fcgbda gadebf cdabfe badcf agd fcdbega | abdfeg gd egbac cabgdf 158 | dfgebc eabcd efcdb dbecfa dac aegdb ca bcgafed fbac fcadge | ca egcdafb afcbdge eagdb 159 | ebgdc cbgdfe dcbfae bfagcd gdef cebga bceagfd ecd dfbgc ed | de ed fdegcba edc 160 | eb feb begdcf efgacb gdbe daecf dgcfb fbdcega cebfd gabcdf | efdbc be afdec efb 161 | begac fbec bcdafg acb cb fgaebd afegbc gebadcf dagec beafg | adgce fceb cgdeafb cab 162 | ca cdfagb ebfca ebdcgaf afebg dfbgae cega cebfd fbagce fac | bgedaf cgae gdaecfb egdabcf 163 | gabfd agfc ecdbfag aefcbd afd af gdabfc bgcfed abedg dcgfb | af bdgcef adgbf gcdafb 164 | egfda fed dbfga adgefb de gacbdf aefgc aecbfd bdge fdbecga | ed de eacbgdf bdeg 165 | dbfag cdbfea gfdbec agfedbc gfb bg gabfcd fgeda dbfac acbg | dfbac gcba gb fbgda 166 | dbcgf gba gdcaeb dgbacfe edfba debgcf cbdgaf afcg ag abfdg | bgafecd edfcgb ag dgfba 167 | bdfcg acebfg egfbacd gfdcba fbg dagb bg cbdaf cgdfe edfcab | bagd gfebacd efbcda gfb 168 | cedbf fcabdge cge feagbc dfcge gedb adcgf bdcefg edacfb eg | cbdfe cge efbcad cfagdeb 169 | cga fgeda ceagd ebcg beadc bgfecad fgdcba gc cagebd dfeabc | cag daebgc cg fcdageb 170 | fgdc fda aebgd cabfde fd agbecf fdacgbe dbfga cfgba bdgacf | facbg fbdagec fdcg ebafcgd 171 | gbced efbgca gfebd bdc baecg fcabed dcbgeaf gbedac dc acdg | gfbace cdafbe cbaeg bcd 172 | afgdec ba dbcge daefg dabeg dfbcage afbd fgdaeb gab cfegab | bcfage bgead ba fgdbcea 173 | ace dgcaef daegbc bfgeda ecbd degab cgabf ce eagbdfc bcgea | cdgeaf bdgea edcb cae 174 | cd cadf gfead gdefab dce adcfge degcf cgefb gdfbcae aebcgd | efgdc dce ecd dc 175 | afdbe ad fgdeb fda aebdcgf bcaefg acbfe fdceab bacd dcagef | afd begfd acfeb fda 176 | dfg afgedbc cbfga gbdace dbagf fdegab edgacf df befd edgba | dgeba df efbd cfadge 177 | bdcgaf aebg badfce efagc gdefc cabfeg abgcf ecafbdg afe ae | aegdbcf ageb eagb ebdfgca 178 | gdceab fb bfe cgbfea edbagfc cafed ebacg ebafc defgcb gbfa | efb efcba bf afgb 179 | bafcg cdfgb ac caf fcdabe adgc dbgefc bedafcg bgacdf bfaeg | bcfegad afegb gabfdce bgcfa 180 | dafgb gca fcab fcabgd dcfaebg gfcdae cgdba ac gbadef egcbd | bcedg aebgfcd gfeadb afbc 181 | adebg fcgaedb dagfe agfc fdbaec fgaecd feg acdfe gf becdgf | feg fge gfe egf 182 | gf gfda gfb gfcebd gefab afcbged eabdg adgbfe fbace bgcade | dbafgce fbdaeg dagf fcbae 183 | fbegcd ecg cefdbag fcgd ebdac gbecd cg bfcgea bafdeg edfgb | fcbegd acbde bcgaef cge 184 | gbcadf cf gfbc defbca acgfd bcaedg afegd cfbgeda caf gcdba | begcad cfa bagfedc gbcdeaf 185 | begacdf dcafbg gb cgfbed gbcde cedfab dfcbe gbc cadge ebfg | gbfe gb ebcdfga bfeg 186 | fe bgadefc cbgdf gbfade cefgd ecdgaf efg afce eacgd dcgeab | gdebac fcae egbdfac fgdeab 187 | ebfca fdac fdb bgdecaf dbcgef cedbfa bgcefa fd eadfb baegd | cgfaeb dgbecf dfb bagecf 188 | ebda eagcf gcbea ba bfcegad acebgd gdecb cdafgb acb gfcdbe | fgcebd cedbgf gbfdac cefag 189 | edacf fed eacgd febadc ebafc bfcgea ecafgdb adbf fd gbfdec | fabce egfcbd deafgbc bafd 190 | gfbe fdbga ged ge aegdf baegcd afecd ebgcfda fgacbd gdeafb | cdfae fdaec ge aefdg 191 | gebaf afdbcg cfged dga fgead febdcga ad fbaedg bade gbfaec | cgbfdea gadfecb agfde gad 192 | fdg cfgdbe cfbeadg cgbf gedbc dcfage dfgeb fg agcbed adefb | gdf bdecg faedb gfd 193 | acdgbe cfabg gfbacd cbf dfbcea bcfegad cf gcdab efbag fdcg | dbfagc fgbdcea cbdga fc 194 | afbcg dgbfac dgaebf gcfea gbceadf afb fb abgcd abcdge fdcb | gbceda cgdabe bcgdae fbgdea 195 | cgbedf dbgfc cbef cf bgfda gcedb gadceb efdcag fdc bcfdaeg | fecb ebdcfg cf badgf 196 | fg cafdg fegadbc aefcdb bcagd degf gfecba adegfc cfg fdeac | gdcafe cgfdae gebfca dfcgae 197 | fdbecg fcagbd fgeabd cadbe bcdag dafgb facg gdc bdgeacf cg | cedab cbdga gcd gc 198 | gdeaf edbcag fbac fgecdba dfbcea afdce ac fbecd dbefcg cea | efcbd gdeaf dfceagb ace 199 | abgdc ebcgd ecgdf ebagcd dabe edgbcfa be cgeabf ceb cdfgba | fdacbg abegcd abdgc cabfdge 200 | fbgcd feacb ed eadf becfd bde fdabce cgdbea fadbcge gbefac | dcgbf fcebd ebcfd gbface -------------------------------------------------------------------------------- /src/day-03/input.txt: -------------------------------------------------------------------------------- 1 | 101111101000 2 | 110110011100 3 | 010111111000 4 | 010101000001 5 | 011000000001 6 | 100001111001 7 | 000000001010 8 | 010110111001 9 | 111000011000 10 | 001101010111 11 | 010101110100 12 | 100100010111 13 | 001100010100 14 | 010110010000 15 | 011101001010 16 | 100101111110 17 | 110010100011 18 | 100110000011 19 | 100100000100 20 | 110000000011 21 | 100101000000 22 | 111011010001 23 | 010000101111 24 | 001100001100 25 | 110010101001 26 | 001000001111 27 | 111100001000 28 | 100011111110 29 | 101110011111 30 | 100001001010 31 | 011110111100 32 | 101010000000 33 | 000101000110 34 | 101000000111 35 | 111010000001 36 | 111111101101 37 | 011111100010 38 | 000100111111 39 | 001000111000 40 | 001101100100 41 | 101100010111 42 | 100011101010 43 | 110100101001 44 | 110011001010 45 | 110100001110 46 | 011110011011 47 | 001111001110 48 | 100110011011 49 | 101011011110 50 | 110101000001 51 | 011010010001 52 | 110010111100 53 | 100101010001 54 | 100101010011 55 | 111100110011 56 | 010111000100 57 | 000100000101 58 | 101000010011 59 | 101110111110 60 | 111101001101 61 | 011110011110 62 | 000101001100 63 | 000111010000 64 | 011111011101 65 | 101000010110 66 | 100100001110 67 | 100101111000 68 | 111000001011 69 | 011100001010 70 | 111111000001 71 | 111011111000 72 | 011100111100 73 | 100101001000 74 | 001110000000 75 | 011100111111 76 | 000001010001 77 | 111001000100 78 | 000000000010 79 | 001010011110 80 | 010100001101 81 | 001111111101 82 | 011001101000 83 | 110000101111 84 | 000110001011 85 | 010010110001 86 | 111001101100 87 | 101010101111 88 | 100001100100 89 | 110010010100 90 | 011001000000 91 | 000111100011 92 | 001000010100 93 | 000100110000 94 | 001011001011 95 | 100011011101 96 | 101000011101 97 | 100110111110 98 | 001000100001 99 | 001100010001 100 | 100110010010 101 | 001111000110 102 | 010101100111 103 | 010101101010 104 | 111101001100 105 | 010010110000 106 | 100101100100 107 | 011000100110 108 | 001000010001 109 | 000011100001 110 | 111010000000 111 | 111101000100 112 | 010100110100 113 | 111011110001 114 | 000111011100 115 | 101111010100 116 | 010000000000 117 | 000111010001 118 | 010001100100 119 | 101110110010 120 | 001001110000 121 | 111011000000 122 | 110100000001 123 | 110111101000 124 | 010010110110 125 | 001001101010 126 | 101110101100 127 | 100101001101 128 | 101011111101 129 | 101011000110 130 | 100100011101 131 | 000001111011 132 | 100010000001 133 | 010000110100 134 | 011111011100 135 | 011000111000 136 | 100111101000 137 | 010000011110 138 | 111001011010 139 | 010101011100 140 | 111100101100 141 | 000011101000 142 | 100100001111 143 | 001011000010 144 | 000000100001 145 | 111100101110 146 | 010011011000 147 | 001011001111 148 | 110101110010 149 | 011111001011 150 | 111001110111 151 | 001111111001 152 | 001110011011 153 | 101100001000 154 | 000111000101 155 | 110100100000 156 | 101010100000 157 | 100010110010 158 | 111010111101 159 | 111101000010 160 | 110000101100 161 | 100000111010 162 | 011111011110 163 | 110110001100 164 | 011010111101 165 | 001110111111 166 | 111100010010 167 | 100101110101 168 | 101010011011 169 | 110111000010 170 | 001110101111 171 | 010000111101 172 | 000010101100 173 | 100011101011 174 | 110010100010 175 | 011000100100 176 | 011110101010 177 | 000111110101 178 | 111000010001 179 | 101101001111 180 | 000010001001 181 | 011100000101 182 | 110101010101 183 | 010111001110 184 | 100101011010 185 | 101110010000 186 | 010110111110 187 | 011101100001 188 | 000000110110 189 | 110000101001 190 | 000101101010 191 | 101111111110 192 | 000011100111 193 | 001111101001 194 | 110110000011 195 | 101110011110 196 | 101100010000 197 | 011000000100 198 | 101001101111 199 | 000000011100 200 | 101010010011 201 | 010000010110 202 | 001111110101 203 | 101000100000 204 | 011110001010 205 | 101010101011 206 | 100000101001 207 | 011111111101 208 | 100011110110 209 | 111011101011 210 | 101101100001 211 | 010111010001 212 | 000100100000 213 | 010101010001 214 | 110010001101 215 | 111111011010 216 | 000010100011 217 | 101001000000 218 | 111101111100 219 | 010010111110 220 | 101011011101 221 | 001110010001 222 | 001111010010 223 | 111000101110 224 | 111011011001 225 | 101001010001 226 | 110011110011 227 | 110000100111 228 | 111111111110 229 | 000110001111 230 | 000111001100 231 | 010111111011 232 | 000011001100 233 | 110111111001 234 | 010010001101 235 | 100111101100 236 | 001001111100 237 | 110000001101 238 | 111110001001 239 | 101111111100 240 | 100001011110 241 | 111101100110 242 | 001001100001 243 | 111000001000 244 | 111101110111 245 | 000011010100 246 | 000010101011 247 | 111111010100 248 | 000001110111 249 | 111001101111 250 | 011011110010 251 | 111101101101 252 | 111111101000 253 | 100011011000 254 | 010001001000 255 | 010111001111 256 | 000000110111 257 | 100000101110 258 | 010100110010 259 | 011011001110 260 | 111011011111 261 | 100111110100 262 | 000111101001 263 | 010110110111 264 | 010000111111 265 | 011101011101 266 | 011110110010 267 | 000100001100 268 | 001010001001 269 | 100011101111 270 | 001101111010 271 | 011101111101 272 | 010001110001 273 | 111111011101 274 | 110101111001 275 | 010100111011 276 | 110001011111 277 | 000100101100 278 | 110000111110 279 | 101000001101 280 | 111010111111 281 | 101111110111 282 | 100100100011 283 | 000101111010 284 | 000100011100 285 | 000101111110 286 | 110111111100 287 | 110100010111 288 | 011110111111 289 | 100100011011 290 | 110100000011 291 | 100001101010 292 | 010101001011 293 | 010111111001 294 | 101101000100 295 | 000111010100 296 | 101100100001 297 | 100100100101 298 | 001011111101 299 | 110011100101 300 | 111101010001 301 | 001001111001 302 | 101000010010 303 | 010101010111 304 | 011010000100 305 | 100011111101 306 | 000101010001 307 | 011001101110 308 | 011000000000 309 | 001001111000 310 | 100100001101 311 | 011010110010 312 | 101110111111 313 | 011000011110 314 | 001010011011 315 | 111000100110 316 | 010100011000 317 | 100011011100 318 | 101110110000 319 | 000000110100 320 | 110101001001 321 | 110001111111 322 | 010000001110 323 | 110010011110 324 | 010101100010 325 | 000010111011 326 | 010110011111 327 | 111010100011 328 | 011111101111 329 | 110001000000 330 | 011000001001 331 | 001110100111 332 | 001010000011 333 | 111001100101 334 | 001001100000 335 | 011101101010 336 | 000011000001 337 | 100100011000 338 | 101010110010 339 | 100010001000 340 | 100010010001 341 | 110100100101 342 | 010100100101 343 | 011111101000 344 | 000011110011 345 | 111001110101 346 | 101111001100 347 | 101001101011 348 | 100010001011 349 | 011000101001 350 | 111100011110 351 | 101110000110 352 | 011100101100 353 | 011100100111 354 | 111000011010 355 | 000110110111 356 | 011001110010 357 | 011001111111 358 | 010110010111 359 | 001101110110 360 | 011000011001 361 | 100000100000 362 | 110001000110 363 | 100110110111 364 | 101000011100 365 | 001101001010 366 | 110110110010 367 | 000111100101 368 | 010001110100 369 | 110100001001 370 | 110100100001 371 | 000010010111 372 | 000000000100 373 | 111101110101 374 | 011011100101 375 | 101011011100 376 | 001010000010 377 | 001000100000 378 | 111011110100 379 | 110010010000 380 | 100010000000 381 | 010010010011 382 | 111011000101 383 | 000010110110 384 | 101001100110 385 | 111011001110 386 | 010001001010 387 | 110010001110 388 | 111110001011 389 | 000101101111 390 | 111001010101 391 | 010001101111 392 | 110101000011 393 | 111000111011 394 | 100001110001 395 | 001010111010 396 | 111100011001 397 | 000001001100 398 | 010010001011 399 | 110001100100 400 | 001000100010 401 | 111100010100 402 | 001100001010 403 | 110110001000 404 | 110110011110 405 | 101101111110 406 | 010000110010 407 | 000001100001 408 | 001101110010 409 | 101011011011 410 | 000001010111 411 | 000110010001 412 | 011101111010 413 | 000101011010 414 | 100110011010 415 | 001000000010 416 | 010110001101 417 | 010110001110 418 | 000110011001 419 | 011000101110 420 | 101000011010 421 | 000000110000 422 | 110011110010 423 | 100011000011 424 | 111111110011 425 | 010000100111 426 | 100001101101 427 | 100100101011 428 | 001010000001 429 | 101001011100 430 | 100100011100 431 | 110111000011 432 | 111000010100 433 | 110111110011 434 | 110110001011 435 | 000101001001 436 | 011001110100 437 | 100111010101 438 | 000101100110 439 | 100111001011 440 | 101111100111 441 | 111000011100 442 | 011111001000 443 | 000100101111 444 | 011011101111 445 | 101111101010 446 | 000000101010 447 | 100011001011 448 | 011100101000 449 | 111100100010 450 | 110011001000 451 | 010010101011 452 | 001010110111 453 | 011010101001 454 | 100000000011 455 | 011000010000 456 | 010100001001 457 | 000000100000 458 | 000100010001 459 | 000100110111 460 | 110111011001 461 | 100001001100 462 | 011101101000 463 | 100001101110 464 | 111110110110 465 | 001111010000 466 | 001001001011 467 | 101100110010 468 | 111000110010 469 | 010101111111 470 | 000100011110 471 | 010011011100 472 | 110001001100 473 | 010000101100 474 | 101100001010 475 | 100001011001 476 | 010101010110 477 | 011100001001 478 | 101001100100 479 | 110001010111 480 | 100100110011 481 | 001111110010 482 | 001111010100 483 | 101111011011 484 | 000110111110 485 | 011010010110 486 | 101101110010 487 | 110110110000 488 | 000001101110 489 | 000111110111 490 | 100111001111 491 | 110100110000 492 | 011100000010 493 | 001010100100 494 | 001101100001 495 | 101101010001 496 | 100100110010 497 | 001001111111 498 | 110101110001 499 | 100001111101 500 | 101100100010 501 | 110110110110 502 | 111100001001 503 | 110010101110 504 | 101111010011 505 | 000101101101 506 | 110001101000 507 | 110000101000 508 | 100101101011 509 | 101001110010 510 | 000101000011 511 | 010101000111 512 | 101001001101 513 | 100001111000 514 | 001000111010 515 | 011101101100 516 | 110011101010 517 | 001000001001 518 | 000111011001 519 | 000010011000 520 | 011010011110 521 | 100100000000 522 | 001000000011 523 | 111010110100 524 | 111000100001 525 | 010010111100 526 | 111011101100 527 | 000110111011 528 | 100110011100 529 | 000100011010 530 | 101101010110 531 | 001011100001 532 | 011001010110 533 | 010000010011 534 | 001000010101 535 | 100111010011 536 | 100110100101 537 | 100000100100 538 | 000101010010 539 | 110111111000 540 | 011010111100 541 | 001011010001 542 | 000111101101 543 | 000010101001 544 | 110110001001 545 | 001101111110 546 | 010000101001 547 | 011010110000 548 | 011010001110 549 | 000100110010 550 | 100001100111 551 | 100110111001 552 | 000100001001 553 | 110101011101 554 | 110100101101 555 | 110100011001 556 | 001011001101 557 | 010111100001 558 | 010001011010 559 | 101111111101 560 | 001111111010 561 | 000110100011 562 | 111001010111 563 | 010101001000 564 | 001010110101 565 | 100011101001 566 | 111100000001 567 | 000101100111 568 | 010011000010 569 | 100000010110 570 | 101101101001 571 | 011000010110 572 | 001101100111 573 | 110111011110 574 | 011000100010 575 | 010110110110 576 | 001110110110 577 | 000011111011 578 | 011110011111 579 | 001001101110 580 | 110011000110 581 | 100011001010 582 | 111110101110 583 | 011011101001 584 | 011110001000 585 | 110110001111 586 | 000001010011 587 | 011110110111 588 | 100010010110 589 | 001000011101 590 | 110011100110 591 | 001110001110 592 | 011110110100 593 | 100001010010 594 | 011110000111 595 | 010010011011 596 | 011011010101 597 | 010111001011 598 | 011100101110 599 | 100000101000 600 | 101000110010 601 | 011011101101 602 | 001010100111 603 | 111011101010 604 | 000111100000 605 | 111110001100 606 | 111000100111 607 | 000110011010 608 | 101001010101 609 | 011110111011 610 | 110000010101 611 | 010100000101 612 | 111100000111 613 | 100111010110 614 | 101110000100 615 | 001111110000 616 | 000110110100 617 | 000001111100 618 | 001011010111 619 | 111110011010 620 | 010011101010 621 | 001011000000 622 | 000110010011 623 | 111100100111 624 | 101111110001 625 | 101110010101 626 | 011010011011 627 | 110111110110 628 | 010110100110 629 | 100101010100 630 | 110010100001 631 | 001101110000 632 | 101111010111 633 | 111110010101 634 | 110111001100 635 | 001100101100 636 | 001100111111 637 | 111110011111 638 | 111110001000 639 | 011111011111 640 | 101100000101 641 | 110100000000 642 | 000001111000 643 | 111010001110 644 | 110101010010 645 | 101001110101 646 | 011101110111 647 | 001001000000 648 | 001100101010 649 | 001011011100 650 | 001000101001 651 | 100001001000 652 | 101110010100 653 | 011000001000 654 | 111110010110 655 | 011001101011 656 | 001101101011 657 | 001011111011 658 | 101000111011 659 | 000010111001 660 | 110001011000 661 | 101111011100 662 | 011101001110 663 | 100001010001 664 | 001000000100 665 | 000000001001 666 | 001101000011 667 | 010111110110 668 | 010100101100 669 | 010110001001 670 | 100010111100 671 | 000001110000 672 | 001100001011 673 | 111011000010 674 | 111010000101 675 | 010000100001 676 | 111011111111 677 | 110110001010 678 | 011011011001 679 | 110100010010 680 | 000000110101 681 | 100110000001 682 | 100010010101 683 | 000111100110 684 | 110000011010 685 | 001110110011 686 | 100011001111 687 | 100111111011 688 | 010111000110 689 | 101101111011 690 | 010001001100 691 | 001001111010 692 | 001111000100 693 | 011110110001 694 | 110101010111 695 | 010000011001 696 | 010010000101 697 | 011111010010 698 | 110000001000 699 | 101100110100 700 | 011010110101 701 | 000010010101 702 | 000110010000 703 | 011010001011 704 | 111111000110 705 | 100100100100 706 | 001100111101 707 | 001010101010 708 | 000010011010 709 | 011010000111 710 | 110000101010 711 | 111100010111 712 | 010110100001 713 | 111011111010 714 | 111011011000 715 | 001111100110 716 | 011111001001 717 | 101011100000 718 | 100100011010 719 | 010111011111 720 | 011010111111 721 | 101011000001 722 | 010001000001 723 | 001101000101 724 | 010110110100 725 | 100011101110 726 | 111011111100 727 | 011000100101 728 | 000100111001 729 | 100111101101 730 | 111001110000 731 | 001000011111 732 | 111110000101 733 | 100000000110 734 | 011000001110 735 | 010010010100 736 | 000000000011 737 | 110100100111 738 | 000100110100 739 | 011000011010 740 | 101001110110 741 | 100011001000 742 | 100000110000 743 | 101010001111 744 | 010010010111 745 | 100011111011 746 | 100001011100 747 | 100010000111 748 | 100111011111 749 | 010111110101 750 | 100010001110 751 | 100010100100 752 | 000100101010 753 | 111011010000 754 | 000001100111 755 | 010011011110 756 | 001001110001 757 | 111011011010 758 | 000110001101 759 | 110110101011 760 | 011011111010 761 | 111101111000 762 | 100111100100 763 | 111001101001 764 | 001110000110 765 | 101010100111 766 | 001001111011 767 | 011101000000 768 | 000101100100 769 | 000111110000 770 | 111010011100 771 | 110101111101 772 | 101010101101 773 | 000100011011 774 | 000001001101 775 | 011001000111 776 | 110011100001 777 | 000100010000 778 | 011101011010 779 | 000000010100 780 | 110000100101 781 | 110001101110 782 | 010111111010 783 | 000110000111 784 | 001010101001 785 | 001100000101 786 | 001101001001 787 | 000011100110 788 | 111100110000 789 | 000111001010 790 | 011101010100 791 | 111001111001 792 | 111000001110 793 | 111001101101 794 | 001111011101 795 | 110101100111 796 | 101100101111 797 | 101110100110 798 | 011000001010 799 | 001101000110 800 | 000010010100 801 | 001000100101 802 | 000101101000 803 | 111010100001 804 | 101101101010 805 | 011101110010 806 | 100101010010 807 | 100101110010 808 | 010111001101 809 | 001101110101 810 | 011101000010 811 | 100001111100 812 | 101100000100 813 | 111111101010 814 | 011001110011 815 | 101010100010 816 | 010000011010 817 | 111010010110 818 | 010100011111 819 | 110000011001 820 | 110001011110 821 | 010010111000 822 | 000011011011 823 | 100110010100 824 | 011111110011 825 | 010111101001 826 | 111100101111 827 | 111111011100 828 | 001011110011 829 | 011001010000 830 | 110010000011 831 | 000000100110 832 | 011001001011 833 | 111010111100 834 | 001110010000 835 | 101010000001 836 | 011010111110 837 | 111011011110 838 | 111101101111 839 | 100100010010 840 | 100000001010 841 | 011000011101 842 | 100110111010 843 | 010001101010 844 | 101100111000 845 | 010000000101 846 | 111101011101 847 | 000110111101 848 | 111110110101 849 | 101010101100 850 | 000110001001 851 | 010100111000 852 | 001111000011 853 | 100111011101 854 | 101000111001 855 | 011110110000 856 | 011011011101 857 | 111100000010 858 | 110001111001 859 | 001100010110 860 | 100111110011 861 | 010011100100 862 | 110100101010 863 | 011001101001 864 | 111101011100 865 | 101110011011 866 | 101010110001 867 | 111101010100 868 | 001111101111 869 | 010110101111 870 | 000111000011 871 | 110000001001 872 | 110001001011 873 | 000001111010 874 | 010101110010 875 | 101100000110 876 | 011101100110 877 | 111100000100 878 | 100110000111 879 | 100110111101 880 | 111010111000 881 | 110001010110 882 | 110100111111 883 | 010010001001 884 | 110001011100 885 | 011011001101 886 | 111001010110 887 | 110100111100 888 | 101110100100 889 | 100010010100 890 | 000100011000 891 | 001101001111 892 | 001101010011 893 | 101101011101 894 | 111100001101 895 | 001010001010 896 | 001011010010 897 | 010100001110 898 | 111100001010 899 | 010101001111 900 | 100100100110 901 | 010100010101 902 | 111000010000 903 | 000111001101 904 | 110011111110 905 | 001011111000 906 | 110101100101 907 | 011100011101 908 | 101010011100 909 | 110001100010 910 | 101100110111 911 | 111001000110 912 | 000110110001 913 | 110011011010 914 | 000000001110 915 | 111001000000 916 | 001001000011 917 | 110111100000 918 | 110000010010 919 | 000100001000 920 | 010011111110 921 | 010111111100 922 | 101100111001 923 | 111010001111 924 | 010011111000 925 | 111100100100 926 | 000110100100 927 | 000000000111 928 | 011101100101 929 | 011111110100 930 | 100011111001 931 | 101001110001 932 | 010011010101 933 | 010001011011 934 | 000010011110 935 | 011011010000 936 | 110011110000 937 | 000101001101 938 | 111001110010 939 | 001100000100 940 | 000111110100 941 | 001100111011 942 | 011110000100 943 | 000001100011 944 | 111100110100 945 | 101100111110 946 | 110010001111 947 | 001010000100 948 | 001100100011 949 | 010000100110 950 | 110100100011 951 | 010111001100 952 | 111000110100 953 | 011100111011 954 | 010000111000 955 | 110101011100 956 | 110111010000 957 | 001100110010 958 | 111011001001 959 | 100011010100 960 | 111111011000 961 | 111100011111 962 | 000010111010 963 | 100110101100 964 | 110001010011 965 | 111111010010 966 | 100010100010 967 | 000010100110 968 | 011001000011 969 | 000110000110 970 | 001110110101 971 | 100001100001 972 | 111100111011 973 | 111110011110 974 | 001100111000 975 | 000101000101 976 | 001011000001 977 | 011001100110 978 | 010000010100 979 | 000010101000 980 | 111000000000 981 | 110111010110 982 | 111100001110 983 | 010000001010 984 | 110000000100 985 | 111101010010 986 | 000000100111 987 | 110110111110 988 | 101100011110 989 | 100110010110 990 | 000111101100 991 | 101111000111 992 | 000011011101 993 | 010001001011 994 | 111001001111 995 | 111001100000 996 | 110000111010 997 | 001110111000 998 | 110111100111 999 | 001000000101 1000 | 100101101111 --------------------------------------------------------------------------------