Tweak output formatting

This commit is contained in:
2021-12-03 10:09:11 -06:00
parent 12b004c724
commit a0e5125a23
2 changed files with 33 additions and 31 deletions

View File

@ -4,6 +4,8 @@ namespace aoc2021
{
internal static void Go()
{
Logger.Log("Day 2");
Logger.Log("-----");
var lines = File.ReadAllLines("inputs/02.txt");
var instructions = new List<Instruction>();
foreach (var instruction in lines)
@ -18,6 +20,7 @@ namespace aoc2021
Part1(instructions);
Part2(instructions);
Logger.Log("");
}
struct Instruction
@ -34,9 +37,8 @@ namespace aoc2021
private static void Part1(IEnumerable<Instruction> instructions)
{
using var t = new Timer();
Position pos = new();
using (var t = new Timer())
{
foreach (var instruction in instructions)
{
switch (instruction.Direction)
@ -54,16 +56,14 @@ namespace aoc2021
break;
}
}
}
Logger.Log($"part1: h: {pos.h}, d: {pos.d}, result: {pos.h * pos.d}");
}
private static void Part2(IEnumerable<Instruction> instructions)
{
using var t = new Timer();
Position pos = new();
using (var t = new Timer())
{
long aim = 0;
foreach (var instruction in instructions)
{
@ -83,7 +83,6 @@ namespace aoc2021
break;
}
}
}
Logger.Log($"part2: h: {pos.h}, d: {pos.d}, result: {pos.h * pos.d}");
}

View File

@ -4,9 +4,12 @@
{
internal static void Go()
{
Logger.Log("Day 3");
Logger.Log("-----");
var lines = File.ReadAllLines("inputs/03.txt");
Part1(lines);
Part2(lines);
Logger.Log("");
}
private static void Part1(IEnumerable<string> lines)
@ -123,7 +126,7 @@
}
}
Logger.Log($"o2*co2 = {o2} * {co2} = {o2 * co2}");
Logger.Log($"part2: o2*co2 = {o2} * {co2} = {o2 * co2}");
}
}
}