From 36bb28af87e81a9b3cab1abd79d11106cd610f6c Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 2 Dec 2020 00:36:24 -0500 Subject: update gitignore and run resharper cleanup --- Day5.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Day5.cs') diff --git a/Day5.cs b/Day5.cs index fc360aa..88465db 100644 --- a/Day5.cs +++ b/Day5.cs @@ -5,22 +5,26 @@ namespace aoc2019 { internal sealed class Day5 : Day { - public override int DayNumber => 5; - private readonly IEnumerable tape; + + private int output; + public Day5() { tape = Input.First().Split(',').Select(int.Parse); } - private int output; + public override int DayNumber => 5; + public void RunIntCode(List v, int input) { var i = 0; while (i < v.Count && v[i] != 99) { - int Val(int mode, int val) => - mode != 0 ? val : v[val]; + int Val(int mode, int val) + { + return mode != 0 ? val : v[val]; + } var mode1 = v[i] / 100 % 10; var mode2 = v[i] / 1000; @@ -60,6 +64,7 @@ namespace aoc2019 } } } + public override string Part1() { RunIntCode(tape.ToList(), 1); @@ -72,4 +77,4 @@ namespace aoc2019 return $"{output}"; } } -} +} \ No newline at end of file -- cgit 1.4.1