From 501ef0a5c7236491c67d9a78acca5edd1bf5ebd3 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 5 Dec 2019 01:44:55 -0500 Subject: [PATCH] make some stuff non-static --- Day1.cs | 2 +- Day2.cs | 2 +- Day4.cs | 12 ++++++------ Day5.cs | 9 ++++----- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Day1.cs b/Day1.cs index b5d8612..dd57645 100644 --- a/Day1.cs +++ b/Day1.cs @@ -8,7 +8,7 @@ namespace aoc2019 { public override int DayNumber => 1; - private static readonly IEnumerable masses = + private readonly IEnumerable masses = File.ReadLines("input/day1.in").Select(int.Parse); private static int FuelCost(int weight) => weight / 3 - 2; diff --git a/Day2.cs b/Day2.cs index e469bcc..095b454 100644 --- a/Day2.cs +++ b/Day2.cs @@ -8,7 +8,7 @@ namespace aoc2019 { public override int DayNumber => 2; - private static readonly IEnumerable input = + private readonly IEnumerable input = File.ReadLines("input/day2.in").First().Split(',').Select(int.Parse); public static List RunIntCode(int noun, int verb, List v) diff --git a/Day4.cs b/Day4.cs index 7394f3d..1a7ece7 100644 --- a/Day4.cs +++ b/Day4.cs @@ -32,20 +32,20 @@ namespace aoc2019 return i >= start && i <= end && hasDup; } - public override string Part1() - { - return $"{Enumerable.Range(start, end).Count(IsValid)}"; - } - private bool HasOnePair(int i) { var s = i.ToString(); return IsValid(i) && s.Select(c => s.Count(j => j == c)).Any(c => c == 2); } + public override string Part1() + { + return $"{Enumerable.Range(start, end).Count(IsValid)}"; + } + public override string Part2() { - return $"{Enumerable.Range(start,end).Count(HasOnePair)}"; + return $"{Enumerable.Range(start, end).Count(HasOnePair)}"; } } } diff --git a/Day5.cs b/Day5.cs index 3bbaa4c..ca9a08f 100644 --- a/Day5.cs +++ b/Day5.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; @@ -9,11 +8,11 @@ namespace aoc2019 { public override int DayNumber => 5; - private static readonly IEnumerable tape = + private readonly IEnumerable tape = File.ReadLines("input/day5.in").First().Split(',').Select(int.Parse); - private static int output; - public static void RunIntCode(List v, int input) + private int output; + public void RunIntCode(List v, int input) { var i = 0; while (i < v.Count && v[i] != 99)