make some stuff non-static

This commit is contained in:
Ben Harris 2019-12-05 01:44:55 -05:00
parent 4331492fe0
commit 501ef0a5c7
Signed by: ben
GPG Key ID: 4E0AF802FFF7960C
4 changed files with 12 additions and 13 deletions

View File

@ -8,7 +8,7 @@ namespace aoc2019
{
public override int DayNumber => 1;
private static readonly IEnumerable<int> masses =
private readonly IEnumerable<int> masses =
File.ReadLines("input/day1.in").Select(int.Parse);
private static int FuelCost(int weight) => weight / 3 - 2;

View File

@ -8,7 +8,7 @@ namespace aoc2019
{
public override int DayNumber => 2;
private static readonly IEnumerable<int> input =
private readonly IEnumerable<int> input =
File.ReadLines("input/day2.in").First().Split(',').Select(int.Parse);
public static List<int> RunIntCode(int noun, int verb, List<int> v)

12
Day4.cs
View File

@ -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)}";
}
}
}

View File

@ -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<int> tape =
private readonly IEnumerable<int> tape =
File.ReadLines("input/day5.in").First().Split(',').Select(int.Parse);
private static int output;
public static void RunIntCode(List<int> v, int input)
private int output;
public void RunIntCode(List<int> v, int input)
{
var i = 0;
while (i < v.Count && v[i] != 99)