update to .net 6
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
- global usings - file-scope namespaces - update drone image tag
This commit is contained in:
parent
f1c329ddaa
commit
811c0f5d74
|
@ -4,7 +4,7 @@ name: run
|
|||
|
||||
steps:
|
||||
- name: run
|
||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||
commands:
|
||||
- dotnet test
|
||||
- dotnet run --project aoc2020/aoc2020.csproj
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
MIT License Copyright (c) <year> <copyright holders>
|
||||
MIT License Copyright (c) 2020 Ben Harris
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace aoc2020.test
|
||||
{
|
||||
namespace aoc2020.test;
|
||||
|
||||
[TestClass]
|
||||
public class DayTests
|
||||
{
|
||||
|
@ -37,7 +36,7 @@ namespace aoc2020.test
|
|||
{
|
||||
// create day instance
|
||||
var s = Stopwatch.StartNew();
|
||||
var day = (Day) Activator.CreateInstance(dayType);
|
||||
var day = Activator.CreateInstance(dayType) as Day;
|
||||
s.Stop();
|
||||
Assert.IsNotNull(day, "failed to create day object");
|
||||
Console.WriteLine($"{s.ScaleMilliseconds()}ms elapsed in constructor");
|
||||
|
@ -59,4 +58,3 @@ namespace aoc2020.test
|
|||
Assert.AreEqual(part2, part2Actual, $"Incorrect answer for Day {day.DayNumber} Part2");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
public abstract class Day
|
||||
{
|
||||
protected Day(int dayNumber, string puzzleName)
|
||||
|
@ -45,4 +42,3 @@ namespace aoc2020
|
|||
Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 1: <see href="https://adventofcode.com/2020/day/1" />
|
||||
/// </summary>
|
||||
|
@ -32,4 +29,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 2: <see href="https://adventofcode.com/2020/day/1" />
|
||||
/// </summary>
|
||||
|
@ -53,4 +50,3 @@ namespace aoc2020
|
|||
private string Value { get; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 3: <see href="https://adventofcode.com/2020/day/3" />
|
||||
/// </summary>
|
||||
|
@ -37,9 +35,8 @@ namespace aoc2020
|
|||
var ySlopes = new[] { 1, 1, 1, 1, 2 };
|
||||
|
||||
return xSlopes.Zip(ySlopes)
|
||||
.Select(s => CountSlope(s.Item1, s.Item2))
|
||||
.Select(s => CountSlope(s.First, s.Second))
|
||||
.Aggregate((acc, i) => acc * i)
|
||||
.ToString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 4: <see href="https://adventofcode.com/2020/day/4" />
|
||||
/// </summary>
|
||||
|
@ -102,7 +97,7 @@ namespace aoc2020
|
|||
// height
|
||||
if (_hgt.EndsWith("cm"))
|
||||
{
|
||||
var h = _hgt.Substring(0, 3);
|
||||
var h = _hgt[..3];
|
||||
if (int.TryParse(h, out var hgt))
|
||||
{
|
||||
if (hgt < 150 || hgt > 193)
|
||||
|
@ -185,4 +180,3 @@ namespace aoc2020
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 5: <see href="https://adventofcode.com/2020/day/5" />
|
||||
/// </summary>
|
||||
|
@ -31,4 +27,3 @@ namespace aoc2020
|
|||
return $"{(_ids.Count + 1) * (_ids.First() + _ids.Last()) / 2 - _ids.Sum()}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 6: <see href="https://adventofcode.com/2020/day/6" />
|
||||
/// </summary>
|
||||
|
@ -51,4 +48,3 @@ namespace aoc2020
|
|||
return $"{_countPart2}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 7: <see href="https://adventofcode.com/2020/day/7" />
|
||||
/// </summary>
|
||||
|
@ -58,4 +55,3 @@ namespace aoc2020
|
|||
return $"{Weight("shiny gold") - 1}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 8: <see href="https://adventofcode.com/2020/day/8" />
|
||||
/// </summary>
|
||||
|
@ -74,4 +72,3 @@ namespace aoc2020
|
|||
return $"{_accumulator}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 9: <see href="https://adventofcode.com/2020/day/9" />
|
||||
/// </summary>
|
||||
|
@ -49,4 +47,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 10: <see href="https://adventofcode.com/2020/day/10" />
|
||||
/// </summary>
|
||||
|
@ -56,4 +53,3 @@ namespace aoc2020
|
|||
return $"{Connections(0)}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 11: <see href="https://adventofcode.com/2020/day/11" />
|
||||
/// </summary>
|
||||
|
@ -154,4 +150,3 @@ namespace aoc2020
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 12: <see href="https://adventofcode.com/2020/day/12" />
|
||||
/// </summary>
|
||||
|
@ -13,9 +11,7 @@ namespace aoc2020
|
|||
|
||||
private static void Swap(ref int x, ref int y)
|
||||
{
|
||||
var tmp = x;
|
||||
x = y;
|
||||
y = tmp;
|
||||
(y, x) = (x, y);
|
||||
}
|
||||
|
||||
private (int x, int y, int sx, int sy) ProcessInstructions()
|
||||
|
@ -91,4 +87,3 @@ namespace aoc2020
|
|||
return $"{Math.Abs(sx) + Math.Abs(sy)}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 13: <see href="https://adventofcode.com/2020/day/13" />
|
||||
/// </summary>
|
||||
|
@ -51,4 +49,3 @@ namespace aoc2020
|
|||
return $"{result}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 14: <see href="https://adventofcode.com/2020/day/14" />
|
||||
/// </summary>
|
||||
|
@ -108,4 +104,3 @@ namespace aoc2020
|
|||
return $"{memory.Aggregate<KeyValuePair<ulong, ulong>, ulong>(0, (current, w) => current + w.Value)}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 15: <see href="https://adventofcode.com/2020/day/15" />
|
||||
/// </summary>
|
||||
|
@ -45,4 +43,3 @@ namespace aoc2020
|
|||
return $"{_current}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 16: <see href="https://adventofcode.com/2020/day/16" />
|
||||
/// </summary>
|
||||
|
@ -14,8 +10,8 @@ namespace aoc2020
|
|||
|
||||
public Day16() : base(16, "Ticket Translation")
|
||||
{
|
||||
_tickets = new List<List<int>>();
|
||||
_rules = new Dictionary<string, List<Range>>();
|
||||
_tickets = new();
|
||||
_rules = new();
|
||||
|
||||
foreach (var line in Input)
|
||||
{
|
||||
|
@ -88,4 +84,3 @@ namespace aoc2020
|
|||
$"{departureFields.Aggregate(1L, (l, match) => l * _tickets.First()[match.Index])}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 17: <see href="https://adventofcode.com/2020/day/17" />
|
||||
/// </summary>
|
||||
|
@ -127,4 +124,3 @@ namespace aoc2020
|
|||
return $"{plane.Values.Count(v => v == '#')}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 18: <see href="https://adventofcode.com/2020/day/18" />
|
||||
/// </summary>
|
||||
|
@ -78,4 +73,3 @@ namespace aoc2020
|
|||
return $"{_expressions.Sum(expr => Calculate(expr, c => c switch { '+' => 2, '*' => 1, _ => 0 }))}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 19: <see href="https://adventofcode.com/2020/day/19" />
|
||||
/// </summary>
|
||||
|
@ -54,4 +49,3 @@ namespace aoc2020
|
|||
return $"{_messages.Count(m => exp.IsMatch(m))}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
/// <summary>
|
||||
/// Day 20: <see href="https://adventofcode.com/2020/day/20" />
|
||||
/// </summary>
|
||||
|
@ -180,4 +176,3 @@ namespace aoc2020
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
/// <summary>
|
||||
/// Day 21: <see href="https://adventofcode.com/2020/day/21" />
|
||||
/// </summary>
|
||||
|
@ -19,4 +19,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
/// <summary>
|
||||
/// Day 22: <see href="https://adventofcode.com/2020/day/22" />
|
||||
/// </summary>
|
||||
|
@ -19,4 +19,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
/// <summary>
|
||||
/// Day 23: <see href="https://adventofcode.com/2020/day/23" />
|
||||
/// </summary>
|
||||
|
@ -19,4 +19,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
/// <summary>
|
||||
/// Day 24: <see href="https://adventofcode.com/2020/day/24" />
|
||||
/// </summary>
|
||||
|
@ -19,4 +19,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
/// <summary>
|
||||
/// Day 25: <see href="https://adventofcode.com/2020/day/25" />
|
||||
/// </summary>
|
||||
|
@ -19,4 +19,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
/// <summary>
|
||||
/// Day X: <see href="https://adventofcode.com/2020/day/X" />
|
||||
/// </summary>
|
||||
|
@ -19,4 +19,3 @@ namespace aoc2020
|
|||
return "";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
namespace aoc2020;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -25,4 +24,3 @@ namespace aoc2020
|
|||
return i >= range.Start.Value && i <= range.End.Value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +1,19 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection;
|
||||
|
||||
namespace aoc2020;
|
||||
|
||||
namespace aoc2020
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
var days = Assembly.GetExecutingAssembly().GetTypes()
|
||||
.Where(t => t.BaseType == typeof(Day))
|
||||
.Select(t => (Day) Activator.CreateInstance(t))
|
||||
.OrderBy(d => d.DayNumber);
|
||||
.Select(t => Activator.CreateInstance(t) as Day)
|
||||
.OrderBy(d => d?.DayNumber);
|
||||
|
||||
if (args.Length == 1 && int.TryParse(args[0], out var dayNum))
|
||||
{
|
||||
var day = days.FirstOrDefault(d => d.DayNumber == dayNum);
|
||||
var day = days.FirstOrDefault(d => d?.DayNumber == dayNum);
|
||||
if (day != null)
|
||||
day.AllParts();
|
||||
else
|
||||
|
@ -23,8 +21,7 @@ namespace aoc2020
|
|||
}
|
||||
else
|
||||
{
|
||||
foreach (var d in days) d.AllParts();
|
||||
}
|
||||
foreach (var d in days) d?.AllParts();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -11,4 +13,11 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="System.Collections.Generic"/>
|
||||
<Using Include="System.Collections.Immutable"/>
|
||||
<Using Include="System.Text"/>
|
||||
<Using Include="System.Text.RegularExpressions"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue