-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.cs
50 lines (44 loc) · 1.46 KB
/
Solution.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using AdventOfCode.Common;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AdventOfCode2020.Day04
{
internal class Solution
{
private readonly IReadOnlyCollection<Passport> _passports;
public Solution(string input)
{
_passports = input
.Split(Environment.NewLine + Environment.NewLine)
.Select(PassportParser.Parse)
.WhereNotNull()
.ToList();
}
public int PartOne() => _passports.Count;
public int PartTwo() => _passports.Count(PassportValidator.IsValid);
}
internal class Passport
{
public string BirthYear { get; }
public string IssueYear { get; }
public string ExpirationYear { get; }
public string Height { get; }
public string HairColor { get; }
public string EyeColor { get; }
public string PassportId { get; }
public string? CountryId { get; }
public Passport(string birthYear, string issueYear, string expirationYear, string height, string hairColor,
string eyeColor, string passportId, string? countryId)
{
BirthYear = birthYear;
IssueYear = issueYear;
ExpirationYear = expirationYear;
Height = height;
HairColor = hairColor;
EyeColor = eyeColor;
PassportId = passportId;
CountryId = countryId;
}
}
}