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 --- Day2.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'Day2.cs') diff --git a/Day2.cs b/Day2.cs index 580571f..f4b11e6 100644 --- a/Day2.cs +++ b/Day2.cs @@ -5,18 +5,20 @@ namespace aoc2019 { internal sealed class Day2 : Day { - public override int DayNumber => 2; - private readonly IEnumerable input; + public Day2() { input = Input.First().Split(',').Select(int.Parse); } + public override int DayNumber => 2; + public int RunIntCode(int noun, int verb) { var v = input.ToList(); - v[1] = noun; v[2] = verb; + v[1] = noun; + v[2] = verb; for (var i = 0; v[i] != 99; i += 4) v[v[i + 3]] = v[i] switch @@ -36,12 +38,11 @@ namespace aoc2019 public override string Part2() { for (var i = 0; i < 100; i++) - for (var j = 0; j < 100; j++) - if (RunIntCode(i, j) == 19690720) - return $"{100 * i + j}"; + for (var j = 0; j < 100; j++) + if (RunIntCode(i, j) == 19690720) + return $"{100 * i + j}"; return string.Empty; } } -} - +} \ No newline at end of file -- cgit 1.4.1