28 lines
895 B
C#
28 lines
895 B
C#
namespace AdventOfCodeLibrary._2022
|
|
{
|
|
using AdventOfCodeLibrary.Shared;
|
|
|
|
public class Day04Part2 : Answerable
|
|
{
|
|
public override int Year { get; set; } = 2022;
|
|
public override int Day { get; set; } = 4;
|
|
public override int Part { get; set; } = 2;
|
|
|
|
public override string GetAnswer(byte[] data)
|
|
{
|
|
return GetAsStringArray(data)
|
|
.Where(line => !string.IsNullOrWhiteSpace(line))
|
|
.Select(line =>
|
|
line.Split(',')
|
|
.Select(s => s.Trim())
|
|
.Select(s => s.Split('-')
|
|
.Select(s => Convert.ToInt32(s))
|
|
.ToArray())
|
|
.OrderBy(s => s[0])
|
|
.ToArray())
|
|
.Count(sections => sections[0][1] >= sections[1][0])
|
|
.ToString();
|
|
}
|
|
}
|
|
}
|