Tweak output formatting
This commit is contained in:
11
src/02.cs
11
src/02.cs
@ -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}");
|
||||
}
|
||||
|
@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user