Initial commit

Signed-off-by: not manx <boku@plum.moe>
main
not manx 4 years ago
commit 86c172cb2f
Signed by: C-xC-c
GPG Key ID: F52ED472284EF2F4

11
.gitignore vendored

@ -0,0 +1,11 @@
bin
obj
AdventOfCode/Input/2015
AdventOfCode/Input/2016
AdventOfCode/Input/2017
AdventOfCode/Input/2018
AdventOfCode/Input/2019
TwentyFifteen
TwentySixteen
TwentyNineteen
.vs

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AoC", "AdventOfCode\AoC.csproj", "{8511470D-BE2D-46EF-8DEF-6446A109E2AD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8511470D-BE2D-46EF-8DEF-6446A109E2AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8511470D-BE2D-46EF-8DEF-6446A109E2AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8511470D-BE2D-46EF-8DEF-6446A109E2AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8511470D-BE2D-46EF-8DEF-6446A109E2AD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3D5C89C-5551-41B3-95B5-9B98D3AE8C6B}
EndGlobalSection
EndGlobal

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Options" Version="5.3.0.1" />
<PackageReference Include="NeinMath" Version="1.3.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Input\2016\" />
<Folder Include="Input\2015\" />
</ItemGroup>
</Project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup>
<ActiveDebugProfile>AdventOfCode</ActiveDebugProfile>
</PropertyGroup>
</Project>

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
namespace AdventOfCode.Contracts
{
public abstract class Day
{
public abstract int Year { get; }
public abstract int DayNumber { get; }
private List<string> Output { get; set; } = new List<string>();
protected void Print(string part, object output) =>
Output.Add($"{Year} Day {DayNumber} Part {part}: {output}");
protected void Print(string part, long elapsed, object output) =>
Output.Add($"{Year} Day {DayNumber} Part {part}: {output} {Environment.NewLine}Time: {elapsed}");
public void Write() =>
Console.WriteLine(string.Join(Environment.NewLine, Output));
public void Execute(bool bigBoi)
{
string[] input = File.ReadAllLines($"../../../Input/{Year}/day{DayNumber}.txt");
Part1(input);
Part2(input);
if (bigBoi)
{
BigBoi(File.ReadAllLines($"../../../Input/{Year}/BigBoi/day{DayNumber}.txt"));
}
}
public abstract void Part1(string[] input);
public abstract void Part2(string[] input);
public abstract void BigBoi(string[] input);
}
}

@ -0,0 +1,761 @@
BFBBBFBLRR
BBFFFFFLRR
BFBFBFFRLR
FBBBBFFLLL
BFBBBBFRRL
FFBFFBFRLR
FFFBFBBRRL
FBFBBFBLRL
FBFFFBFLLR
FFBBFBBLLL
FBFBBFFRLL
FFBFFBFLRL
FFBFBFFRRR
BFFFFBBLRR
FFBFFBFRRL
FFBFBFFLRL
BBFFFFFRLL
FFFBFBBRRR
FBFBFBBLLR
FBFBFBFLLR
BFBFBFFRLL
FFFBFFBRLL
BBFFFBFLRL
BFBF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1462
1783
1644
1901
1791
1506
2005
1338
1383
1420
1631
1784
1897
1771
1588
1955
1937
1392
1396
1803
1429
1407
1698
1562
1913
1678
1198
1398
1703
1831
1489
1782
1864
1708
1397
1915
1953
1395
1610
1549
1564
1973
1931
2009
1980
1800
1443
1993
1900
1964
1581
1904
1665
1567
1057
1805
1402
1878
1729
1825
1682
1719
1469
1004
1591
1594
811
1523
1424
1756
373
1442
1718
1411
1892
1820
1977
1871
1890
1653
1372
1475
1476
1422
2004
1755
1676
639
1425
1853
1712
1525
1514
1455
1658
1963
1579
1861
1458
1474
1613
1681
1586
1441
1499
1865
1735
1989
1952
792
1669
1509
1481
1893
1445
1834
1779
1732
1826
1595
1829
449
1920
1707
1780
1935
1867
1769
1107
919
1382
1604
1875
1453
1496
1946
1659
1570
1692
1630
1638
1922
1691
1580
1880
1482
1762
1775
1376
1434
1856
1971
1646
1951
1416
1889
1773
1814
1471
1488
1736
1743
1459
1389
1498
1663
1611
1727
1699
1624
1511
1767
1754
1785
1491
1235
1510
1500
1485

File diff suppressed because it is too large Load Diff

@ -0,0 +1,323 @@
.#..#.....#....##..............
...#.#...#...#.#..........#....
#...###...#.#.....#.##.#.#...#.
#.....#.#...##....#...#...#....
##.......##.#.....#........##.#
#..#....#......#..#......#...#.
#..#......#.......#............
##...#.#..#...#........#....##.
#.#.#...#...#..#........#....#.
.......#...........##......#...
##.##.##......#..#............#
..#.###..#..............#......
.##..#.....#......#.#..........
........#.........#....#....###
#..........#........#.#.#......
...##.....#..####.###..#.##....
....#...###............#..#....
...#.#...#.#...#..#.#........##
.....#...#.............#..#....
....#.#.#.##.....##.##....#....
..#....#............#.##.##..#.
.#..#..#................#...###
#..###.#..##..#............#...
.......#.#....#.##.#.##........
##...###.#....#...........###.#
...#.#....#..####.........#....
....##........#.#.#.###........
#...#..#.....#....##..#.##...#.
##....................##..#....
.#....##...........##...##...#.
.#.#..#.........#.........#.#.#
#.#..#.....#.#..#..#..#.#......
...#.............#......#....##
....#.#.......#....#...#.##...#
#.#.#..###..........#...#......
......#.....#..#..#.......##..#
.#......#......#.....#...#.....
......#..#......#.#............
..#............#..#....#.#.....
.....#..##.......#...##.###.#.#
.....#........##....#.#...##..#
..........##.#..#.#...#..#....#
#.#.#.#.##...................#.
.....#....##.....#..#...#..#...
...#....#.............#....#.#.
.........#.##..##..............
#...#.#....#..#...#.......#....
.#...#......#.##.#...#.#..###..
..#.#.#......#..#...##..##.##..
.........#.....#......##....##.
...###.......#..#........#.....
...#....#...#.#.#......##....#.
.#.....#......#...##.##..#.....
..#.##...#....####...##........
..#.#.###....#..##.......##....
.....#....##...#......#.......#
.#....#......#..............#..
.......#.#......#..#....#.#.#..
.......#.#.........###....#....
.#...#.......#.#..#..####....#.
..#...#.#......#..#.##.###..#..
..##.........#............#.#.#
#.........##.##.........#.###..
...#....#.......#..#..##.......
.#....##........##.......#..#..
...#.....#.#.##.#.#.....##.....
.#.#........#.......#.#..#..#..
.....####..##.##.#.#....#......
..#.##.#.#.#....###..#....#.#..
..##..#.#......##.#..#.........
....#..#.#.##.......#...##.....
....###.....#..###...#....###.#
..#....#.......#......#...##..#
..#..##......#....#.###..#..##.
..#..#...............#.#.#.....
...##...#.#..#.#...#......#....
#....#...#.#.#.#.#....#....#...
....##...#....#.....##..#.....#
......##.....#...##..#.......#.
......###......#....#.##..#....
.....#........#........#...#..#
.#..##.....##....#.#......#.#..
#..#.#.....#........#......#.#.
.#..#.##.....#####.#....#.#....
....##........#..........#.#...
.......#.....#.......#...#.#...
.#....#...##.###....#.#......#.
#...#...........##.#...........
#...##.......#..#........#.#..#
.....#..##..###....#.#.#....#..
..#..#.....#............#.#....
............#......#.....#.....
.#..#.....##.........#....###.#
#.........#....#....#.#..#...#.
##.#...##....#..#...#.#...#....
....###..##...................#
....##...#......#...#.#...#...#
#....#....###..........#...#..#
.....##.#....###.###....#..###.
#.....#...........#...........#
##..###.##........#..#.#..#.#..
.##...#..#.......#.#....#.....#
......##..#..#.......#.#...##..
......#..#..#.#...###..#.#....#
#.##.#..#......#...##........##
.....#..........##.....#...#...
........#....##......#......#.#
..#..#.#...#.#.#.......#......#
.#....#........#............#..
......##.....#...#.............
#......##..#.......##....##.#..
.....#..#..#...#.......#..#....
...#..##.#..#.#....##.....#..##
......#...#.#...#.#......###.#.
.#.#...#.....#..###.....#......
#..####.#....#.......##...#....
.##.......#.....#.........#....
#......##.#...............#....
.######.#...##...#...#...#..##.
....#...####....##.#..#...##...
.#...................#.#..#..#.
.#.#....##...#...#.#..#.#.#.#..
......#......#........##.#...#.
##..#...#..#.............##.#..
#.............#..........#.#...
...##.....#.............#......
......###.....#................
#.#.#....#..##.#.....#.........
.#.#........#.........#.#.##.#.
......#...##...#.#.....#....#..
#...#.........##.##.#..........
#..............#..#.......##...
#...#......#.#......#...#....#.
...#...#........#.#......#.###.
##.....#...#.#..#..#..#.......#
..#.##..##.........#...##.##...
#....#....#.....#..........#...
#.####..#..###.....#..#..#.....
..#.....#.##.##..####....#.#.#.
...#.#....#...#.......#..#.....
......###...#.#..#..#..........
.........#..#.....#.#.##......#
.......#.#....##.....##.#..#.#.
.#..#.#..#......##.###...##..#.
....###...........#.....#....#.
.#.##.....#..#.....#......##...
#..##....#..........#.##.##..#.
.###.#.#..#.#.....#..##....#.#.
..##.#....#.....##..#..........
##........#...#..#........###.#
#...#...........##.......#.#...
...###.....##.#....#...#...#...
......#....#.#.......###....#..
...#...#.......##.......###.#..
..............#.#..........##..
#.#....###..#..#.........#.....
.###.#.......#.....#....#.#....
.....###...#.#..#.#.......#....
.........#.##.#......#.#..#....
.......#....#....#.#....#..##.#
...............#...##.#..#.#..#
.....##........#..##...........
.##.#..#....#..#.#...#.........
.#.#..##.#..#......#....#.#...#
##....#.......##...........#...
..#...#.............#.#....#..#
..#......#..#.....#...##.....#.
....##...#.#...##...#..##......
.....#..#..........#...........
..##....#..#.#....#..#........#
.###....#.....#.#....#..##.....
#.......##.......#..#..#....#.#
.##..#...........#..##..##..#..
.#.................#...#....#..
.######.......#............##..
.#.........#......##.#.#.#.#.#.
.#.......#...#...#....###....#.
....#...##.#.#...#.....#.#..#..
.#..#..#...#.....###....#......
...#.##.###........#.....##....
..#....#.#.#..........#..#..#..
......#.....#...#..#..##..#.#..
#.#.......##.......#....#.....#
..#...#..#.#....#.##.##........
..#....#..##..#..##......#.....
#....#..##.....#....###........
##...#......#..###.#.....#.....
#..###....#...#...#...#......##
.....###....#......#..#..#...#.
.##......#.......##...#........
....#.#.....##.....#.....#.....
...##.#.....#..##...#...##.#...
..#...#.#....#....#...##.......
......#....#..#....#.#.........
..........#.#.#...##....#......
...#....................#..#...
...#....###....#..#.....#.....#
..#....#....#..#.#..##.#...#...
..#.##....##.....#.#........#..
#.....###..#.#.#...#..#....#...
........#..#.#..#........##....
.##....#................##.#.##
..##...#.#.#.....##..#....#....
....#..#....#..#........#..##..
...#...##....#....#..##......#.
##........#...#.....#.....#...#
.#......#....##...#.........##.
##........#...#.....#..#...#.#.
...##..#..#.....#..###.#..#....
....#..#..............#.......#
.......#.##...#......#.###.....
#........##..##....#.#.#.......
#.#..##.#.......#..##.....###..
.....##...#..#.....#...........
...#..#..#......#...#.#........
.#....#....#.#.....#.....#....#
...#..#...#..#.##.#......#.#.#.
..##....#..#..#.....#....#....#
...#....#.##.#..#.###......#...
.......#..#.....#.......#..#...
..###.#####..#..##.#.........#.
...#.......##...#.#..#.#......#
....#...#.###..#..........#....
...........#...#..##........#..
.......#...#....#....#.#..#....
.........#..........#...#....##
.##.........##..#.......##.#...
........#......###...##...#.#.#
#.#...##.##...........#...#.#..
.....###...#..##......#..#.....
#.#.....#.#....##..........#..#
#..#.......#.#.........####....
#.#...#.....#........#.....#..#
.....#..#.#.###.....#.#.###....
.###..#......##..#..#..........
#....#.#......#...#.##......#..
..#.........##.#.....#.........
...#....#.....##.#..#..##.#..#.
##.....#.#..#.#....#......#....
....###.#.....#.......#..#.#...
#.....##.....##...........#....
..........#..#......#.##...#...
#...#.###....##....#.###..###..
##........#.#...#..#.........#.
##........##.......#.....###...
.##....###........#..##...#...#
......#..##....##.....#..#.#...
.....#..##..#.......#.......#..
......#....#.......##.#........
.#.####.#..#......#..#.........
.##..#....#...##.#....#....#...
..#..#..#####.........#...#....
....#.....#.#.#.#...#.#......#.
....#...#.#..#.##...#...#......
..#...#...#...#...#..#.#.##..#.
..#......#.#.#.##.##.##..#.....
#..###......#.##...#....#.##.#.
.#.#.......##..##....##...##.#.
.##......##....##.#.......#...#
..#...#...................#....
.#...#.......######.....#.#..##
......#.##.....#.#.............
...........##.#........#..#....
#.............#.#.....#....##..
#...........#...#..###.....#...
....#.......#.#..#..#.#........
......#...##.......#..##....#..
......#.##.##..#........#.#...#
.#..#...##...................#.
.#.............#...#.#.#.#...#.
.........#.....#........#.#....
#..#...#.............##.#.....#
...#.#....#...##............#..
..#...#.##.###.#.....#......##.
...#.#..###...#.#............#.
...#....#........#.#...........
.#......#.#.#.........#.#....#.
....#..#......#.##.....#.#.....
..#..###....#....#.........###.
#..#.#....##.#....#.##..#......
#..#.....#.#.....##..#.##......
......#...#.#.............#..#.
#.#....#.#..#...#......#.#.....
..#.........#.#....#...#.......
.#..#.#...#....#...#......#...#
.......#........#.#..#..#...#..
..##.#......#..##.##.#..#..#...
.##...#....##.....#.....#...##.
#.....##.#....#.#......##..#...
.......#.#..#...#.......#.#...#
..#...#.......#...#..##........
#....##..#...#..#.#......#..#.#
##.#....#....#....#...#..#.##..
###........#.#..#..#......#....
.#......#.....#....#.#..#...#..
.#.....#.....#...##.......#..##
#..##.#..#..........#..........
...#.##.........#.#.##.#.......
.#..#...............#...#.#.#..
.....#.#.....#...####..#.....#.
.#....#.##..##...#...##.#...#.#
....#......##...#.#.#.....#.##.
#...#..#.#...#.#.....##...#....
..#..#....##..###......#..#....
.........#......##.....##....#.
.......#....#...#........###...
.....#..#..#...#...#......#....
..#..#...#.....#.....###..#.###
............#.#..#..#....#.....
...#..#...###.......#.......#..
#.........#........#.....##....
.#.#........#.....#........###.
....#.##.#...#.#.#.....#....#..
.##...#..#.......#.#...........
##...#.##...#...........#.....#
##....#.#.....##..#.......#....
##....#...#....#..#.......####.
......#...#..#.....#.#....#...#
.......#.....#..###............
#.#.#..#.....#.............#..#
.#..#.....##.....#...#.......##
..#.##........##...........#.#.
....##.#..###.#.........#...##.

File diff suppressed because it is too large Load Diff

@ -0,0 +1,149 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace AdventOfCode
{
public static class IntcodeComputer
{
public static (int[] opcodes, List<int> output) Run(int[] opcodes, int? noun = null, int? verb = null, int[]? input = null)
{
opcodes[1] = noun ?? opcodes[1];
opcodes[2] = verb ?? opcodes[2];
List<int> output = new List<int>();
int ptr = 0;
int inputPtr = 0;
while (opcodes[ptr] != 99)
{
int GetOpcode(int opcode, Mode mode) =>
mode switch
{
Mode.Position => opcodes[opcode],
Mode.Immediate => opcode,
_ => throw new Exception()
};
bool jumped = false;
Mode paramOne = opcodes[ptr] / 100 % 10 == 0 ? Mode.Position : Mode.Immediate;
Mode paramTwo = opcodes[ptr] / 1000 == 0 ? Mode.Position : Mode.Immediate;
int code = opcodes[ptr] % 100;
switch (code)
{
case 1: // Add
{
int x = GetOpcode(opcodes[ptr + 1], paramOne);
int y = GetOpcode(opcodes[ptr + 2], paramTwo);
opcodes[opcodes[ptr + 3]] = x + y;
break;
}
case 2: // Multiply
{
int x = GetOpcode(opcodes[ptr + 1], paramOne);
int y = GetOpcode(opcodes[ptr + 2], paramTwo);
opcodes[opcodes[ptr + 3]] = x * y;
break;
}
case 3: // Read input
if (input != null)
{
opcodes[opcodes[ptr + 1]] = inputPtr < input.Length ? input[inputPtr] : int.Parse(Console.ReadLine());
inputPtr++;
break;
}
opcodes[opcodes[ptr + 1]] = int.Parse(Console.ReadLine());
break;
case 4: // Output
{
output.Add(GetOpcode(opcodes[ptr + 1], paramOne));
break;
}
case 5: // Jump if true
{
int x = GetOpcode(opcodes[ptr + 1], paramOne);
int y = GetOpcode(opcodes[ptr + 2], paramTwo);
if (x != 0)
{
ptr = y;
jumped = true;
};
break;
}
case 6: // Jump if false
{
int x = GetOpcode(opcodes[ptr + 1], paramOne);
int y = GetOpcode(opcodes[ptr + 2], paramTwo);
if (x == 0)
{
ptr = y;
jumped = true;
};
break;
}
case 7: // Less than
{
int x = GetOpcode(opcodes[ptr + 1], paramOne);
int y = GetOpcode(opcodes[ptr + 2], paramTwo);
opcodes[opcodes[ptr + 3]] = x < y ? 1 : 0;
break;
}
case 8: // Equal to
{
int x = GetOpcode(opcodes[ptr + 1], paramOne);
int y = GetOpcode(opcodes[ptr + 2], paramTwo);
opcodes[opcodes[ptr + 3]] = x == y ? 1 : 0;
break;
}
case 99:
throw new Exception("Skipped an exit code");
default:
throw new Exception("Unknown opcode encountered");
}
if (!jumped)
{
ptr += InstructionLength[code];
}
}
return (opcodes, output);
}
private static readonly Dictionary<int, int> InstructionLength = new Dictionary<int, int>()
{
// Instruction number, How far to move the ptr
{1, 4 },
{2, 4 },
{3, 2 },
{4, 2 },
{5, 3 },
{6, 3 },
{7, 4 },
{8, 4 },
};
private enum Mode
{
Position = 0,
Immediate = 1
}
}
}

@ -0,0 +1,98 @@
using AdventOfCode.Contracts;
using Mono.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace AdventOfCode
{
class Program
{
private static bool Help { get; set; }
private static bool BigBoi { get; set; }
private static List<int> Year { get; set; } = new List<int>();
private static List<int> Day { get; set; } = new List<int>();
private static void Main(string[] args)
{
OptionSet options = new OptionSet()
{
{ "h|?|help", "Prints this help message and exits", s => Help = s != null },
{ "y|year=", "The year of the challenge", (int s) => Year.Add(s) },
{ "d|day=", "The day(s) of the challenge. Accepts multiple (-d 1, -day=2)", (int s) => Day.Add(s) },
{ "b|BigBoi", "Tells the program if it should run the BigBoi input", s => BigBoi = s != null}
};
try
{
options.Parse(args);
}
catch (OptionException e)
{
Error(e.Message);
Exit();
return;
}
if (Help)
{
Console.WriteLine("Usage: dotnet ./AoC.dll [OPTIONS]");
Console.WriteLine("If no options are provided, all years and days will be run.");
Console.WriteLine("If only a year is provided, all days from that year will be run.");
Console.WriteLine("If only a day is provided, the provided day from all years will be run.");
options.WriteOptionDescriptions(Console.Out);
return;
}
if (!Day.Any() && (Day.Min() < 0 || Day.Max() > 25))
{
Error("Days must be between 1 and 25.");
return;
}
var days = GetDays();
if (Day.Any())
{
days = days.Where(d => Day.Contains(d.DayNumber));
}
if (Year.Any())
{
days = days.Where(d => Year.Contains(d.Year));
}
foreach (Day d in days)
{
d.Execute(BigBoi);
d.Write();
}
Exit();
}
private static void Error(string e)
{
Console.Write("Advent of Code:");
Console.WriteLine(e);
Console.WriteLine("Try AdventOfCode --help for more information");
}
private static void Exit()
{
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
private static IEnumerable<Day> GetDays() =>
Assembly.GetExecutingAssembly()
.GetTypes()
.Where(t => t.BaseType == typeof(Day))
.Select(t => (Day)Activator.CreateInstance(t))
.OrderBy(t => t.Year)
.ThenBy(t => t.DayNumber);
}
}

@ -0,0 +1,8 @@
{
"profiles": {
"AdventOfCode": {
"commandName": "Project",
"commandLineArgs": "-y 2020 -d 5 -b"
}
}
}

@ -0,0 +1,165 @@
using AdventOfCode.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AoC.TwentyTwenty
{
class Five : Day
{
public override int Year => 2020;
public override int DayNumber => 5;
public override void BigBoi(string[] input)
{
int grandTotal = 0;
HashSet<int> seats = new HashSet<int>();
foreach (string s in input)
{
int upper = 127;
int lower = 0;
int left = 0;
int right = 7;
int row = 64;
int col = 4;
foreach (char c in s)
{
_ = c switch
{
'F' => upper -= row,
'B' => lower += row,
'L' => right -= col,
'R' => left += col,
_ => throw new Exception("AAAAAAAAAAA")
};
if (c == 'F' || c == 'B')
{
row /= 2;
}
else
{
col /= 2;
}
}
int total = (upper * 8) + left;
if (total > grandTotal)
{
grandTotal = total;
}
seats.Add(total);
}
Print("BigBoi 1", grandTotal);
for (int i = 0; i < int.MaxValue; i++)
{
if (!seats.Contains(i) && seats.Contains(i + 1) && seats.Contains(i - 1))
{
Print("BigBoi 2", i);
break;
}
}
}
public override void Part1(string[] input)
{
int grandTotal = 0;
foreach (string s in input)
{
int upper = 127;
int lower = 0;
int left = 0;
int right = 7;
int row = 64;
int col = 4;
foreach (char c in s)
{
_ = c switch
{
'F' => upper -= row,
'B' => lower += row,
'L' => right -= col,
'R' => left += col,
_ => throw new Exception("AAAAAAAAAAA")
};
if (c == 'F' || c == 'B')
{
row /= 2;
}
else
{
col /= 2;
}
}
int total = (upper * 8) + left;
if (total > grandTotal)
{
grandTotal = total;
}
}
Print("1", grandTotal);
}
public override void Part2(string[] input)
{
HashSet<int> seats = new HashSet<int>();
foreach (string s in input)
{
int upper = 127;
int lower = 0;
int left = 0;
int right = 7;
int row = 64;
int col = 4;
foreach (char c in s)
{
_ = c switch
{
'F' => upper -= row,
'B' => lower += row,
'L' => right -= col,
'R' => left += col,
_ => throw new Exception("AAAAAAAAAAA")
};
if (c == 'F' || c == 'B')
{
row /= 2;
}
else
{
col /= 2;
}
}
seats.Add((upper * 8) + left);
}
for (int i = 0; i < 1028; i++)
{
if (!seats.Contains(i) && seats.Contains(i + 1) && seats.Contains(i - 1))
{
Print("2", i);
break;
}
}
}
}
}

@ -0,0 +1,106 @@
using AdventOfCode.Contracts;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace AoC.TwentyTwenty
{
namespace AoC.TwentyTwenty
{
class Four : Day
{
public override int Year => 2020;
public override int DayNumber => 4;
public override void BigBoi(string[] input)
{
throw new NotImplementedException();
}
public override void Part1(string[] input)
{
IEnumerable<string> inputbutforreal = input.ToList();
inputbutforreal = inputbutforreal.Append("");
HashSet<string> keys = new HashSet<string>();
int valid = 0;
foreach (string s in inputbutforreal)
{
if (s == string.Empty)
{
if (keys.Count == 7 && !keys.Contains("cid") || keys.Count > 7)
{
valid += 1;
}
keys = new HashSet<string>();
continue;
}
keys.Add(s.Split(":")[0]);
}
Print("1", valid);
}
public override void Part2(string[] input)
{
IEnumerable<string> inputbutforreal = input.ToList();
inputbutforreal = inputbutforreal.Append("");
HashSet<string> keys = new HashSet<string>();
int valid = 0;
bool isValid = true;
foreach (string s in inputbutforreal)
{
if (s == string.Empty)
{
if (isValid && (keys.Count == 7 && !keys.Contains("cid") || keys.Count > 7))
{
valid += 1;
}
isValid = true;
keys = new HashSet<string>();
continue;
}
if (!isValid)
{
continue;
}
string key = s.Split(":")[0];
string value = s.Split(":")[1];
isValid = key switch
{
"byr" => Regex.IsMatch(value, "19([2-9][0-9])|200[0-2]"),
"iyr" => Regex.IsMatch(value, "20(1[0-9]|20)"),
"eyr" => Regex.IsMatch(value, "20(2[0-9]|30)"),
"hgt" => Regex.IsMatch(value, "^(1([5-8][0-9]|9[0-3])cm|(59|6[0-9]|7[0-3])in)$"),
"hcl" => Regex.IsMatch(value, "#[0-9a-f]{6}"),
"ecl" => Regex.IsMatch(value, "amb|blu|brn|gry|grn|hzl|oth"),
"pid" => Regex.IsMatch(value, "^\\d{9}$"),
"cid" => true,
_ => throw new Exception("NIGGERS")
};
if (key == "pid" && !Regex.IsMatch(value, "^\\d{9}$") && Regex.IsMatch(value, "\\d{9}"))
{
Console.WriteLine(value);
}
keys.Add(key);
}
Print("2", valid);
}
}
}
}

@ -0,0 +1,57 @@
using AdventOfCode.Contracts;
using AoC.Utils;
using System;
using System.Diagnostics;
namespace AoC.TwentyTwenty
{
class One : Day
{
public override int Year => 2020;
public override int DayNumber => 1;
public override void BigBoi(string[] input)
{
throw new NotImplementedException();
}
public override void Part1(string[] input)
{
int[] nums = input.ToIntArray();
for (int i = 0; i < nums.Length; i++)
{
for (int j = 0; j < nums.Length; j++)
{
if (nums[i] + nums[j] == 2020) {
Print("1", nums[i] * nums[j]);
return;
}
}
}
}
public override void Part2(string[] input)
{
Stopwatch sw = Stopwatch.StartNew();
int[] nums = input.ToIntArray();
for (int i = 0; i < nums.Length; i++)
{
for (int j = 0; j < nums.Length; j++)
{
for (int k = 0; k < nums.Length; k++)
{
if (nums[i] + nums[j] + nums[k] == 2020)
{
Print("2", nums[i] * nums[j] * nums[k]);
Console.WriteLine(sw.Elapsed);
return;
}
}
}
}
}
}
}

@ -0,0 +1,54 @@
using AdventOfCode.Contracts;
using System;
namespace AoC.TwentyTwenty
{
namespace AoC.TwentyTwenty
{
class Three : Day
{
public override int Year => 2020;
public override int DayNumber => 3;
public override void BigBoi(string[] input)
{
throw new NotImplementedException();
}
public override void Part1(string[] input)
{
Print("1", Numbers(input, 1, 3));
}
public override void Part2(string[] input)
{
var thing =
Numbers(input, 1, 1) *
Numbers(input, 1, 3) *
Numbers(input, 1, 5) *
Numbers(input, 1, 7) *
Numbers(input, 2, 1);
Print("2", thing);
}
public static long Numbers(string[] input, int rows, int columns)
{
int cursor = 0;
long trees = 0;
for (int i = 0; i < input.Length; i += rows)
{
if (input[i][cursor % input[i].Length] == '#')
{
trees += 1;
}
cursor += columns;
}
return trees;
}
}
}
}

@ -0,0 +1,80 @@
using AdventOfCode.Contracts;
using AoC.Utils;
using System;
using System.Diagnostics;
namespace AoC.TwentyTwenty
{
namespace AoC.TwentyTwenty
{
class Two : Day
{
public override int Year => 2020;
public override int DayNumber => 2;
public override void BigBoi(string[] input)
{
throw new NotImplementedException();
}
public override void Part1(string[] input)
{
int total = 0;
foreach (string s in input)
{
int occurences = 0;
string[] split = s.Split(" ");
string[] startEnd = split[0].Split("-");
int start = int.Parse(startEnd[0]);
int end = int.Parse(startEnd[1]);
char c = split[1][0];
foreach (char letter in split[2])
{
if (letter == c)
{
occurences += 1;
}
}
if (occurences >= start && occurences <= end)
{
total += 1;
}
}
Print("1", total);
}
public override void Part2(string[] input)
{
int total = 0;
foreach (string s in input)
{
string[] split = s.Split(" ");
string[] startEnd = split[0].Split("-");
string password = split[2];
char start = password[int.Parse(startEnd[0]) - 1];
char end = password[int.Parse(startEnd[1]) - 1];
char c = split[1][0];
bool thing = (start, end) switch
{
_ when start == end => false,
_ when start == c || end == c => true,
_ => false
};
if (thing)
{
total += 1;
}
}
Print("2", total);
}
}
}
}

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace AdventOfCode
{
public static class Utility
{
public static Array DeepClone(this Array arr)
{
Array temp = Array.CreateInstance(arr.GetValue(0).GetType(), arr.Length);
arr.CopyTo(temp, 0);
return temp;
}
public static int ManhattenDistance(int x, int y)
{
return Math.Abs(x) + Math.Abs(y);
}
public static int[] ToDigitArray(int n)
{
var result = new int[NumberOfDigits(n)];
for (int i = result.Length - 1; i >= 0; i--)
{
result[i] = n % 10;
n /= 10;
}
return result;
}
private static int NumberOfDigits(int n)
{
if (n < 0)
{
n = (n == int.MinValue) ? int.MaxValue : -n;
}
return n switch
{
< 10 => 1,
< 100 => 2,
< 1000 => 3,
< 10000 => 4,
< 100000 => 5,
< 1000000 => 6,
< 10000000 => 7,
< 100000000 => 8,
< 1000000000 => 9,
_ => 10
};
}
public static int[] GetOpcodes(string[] input) =>
input.First()
.Split(',')
.Select(x => int.Parse(x))
.ToArray();
}
}

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AoC.Utils
{
public static class Collections
{
public static int[] ToIntArray(this string[] input)
{
int[] output = new int[input.Length];
for (int i = 0; i < input.Length; i++)
{
output[i] = int.Parse(input[i]);
}
return output;
}
}
}
Loading…
Cancel
Save