Enable nullability
I thought this was the old way. Apparently it's the new way.
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>aoc2021</RootNamespace>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<Nullable>enable</Nullable>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
|
||||
</PropertyGroup>
|
||||
|
@ -15,7 +15,7 @@ namespace aoc2021
|
||||
|
||||
public bool Equals(Point other) => X == other.X && Y == other.Y;
|
||||
|
||||
public override bool Equals(object obj) => obj is Point point && Equals(point);
|
||||
public override bool Equals(object? obj) => obj is Point point && Equals(point);
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(X, Y);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@
|
||||
{
|
||||
var min = nums.Min();
|
||||
var max = nums.Max();
|
||||
long minDist = 0;
|
||||
int? minNum = null;
|
||||
long minDist = long.MaxValue;
|
||||
int minNum = 0;
|
||||
for (int i = min; i <= max; i++)
|
||||
{
|
||||
long dist = 0;
|
||||
@ -26,14 +26,14 @@
|
||||
dist += formula(Math.Abs(num - i));
|
||||
}
|
||||
|
||||
if (minNum == null || dist < minDist)
|
||||
if (dist < minDist)
|
||||
{
|
||||
minDist = dist;
|
||||
minNum = i;
|
||||
}
|
||||
}
|
||||
|
||||
return (minDist, minNum.Value);
|
||||
return (minDist, minNum);
|
||||
}
|
||||
|
||||
private static void Part1(IEnumerable<int> nums)
|
||||
|
Reference in New Issue
Block a user