make some stuff non-static
This commit is contained in:
parent
4331492fe0
commit
501ef0a5c7
2
Day1.cs
2
Day1.cs
|
@ -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;
|
||||
|
|
2
Day2.cs
2
Day2.cs
|
@ -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
12
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)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
9
Day5.cs
9
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<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)
|
||||
|
|
Loading…
Reference in New Issue