-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-1.linq
44 lines (37 loc) · 788 Bytes
/
4-1.linq
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
<Query Kind="Program" />
#load ".\shared"
void Main()
{
var strings = Utils.ParseStrings("4.txt");
int counter = 0;
List<string> fields = new List<string>();
foreach (var s in strings)
{
if (s == null || s.Length == 0)
{
if (Contains("byr") &&
Contains("iyr") &&
Contains("eyr") &&
Contains("hgt") &&
Contains("hcl") &&
Contains("ecl") &&
Contains("pid"))
counter++;
fields = new List<string>();
}
else
{
string[] split = s.Split(' ', StringSplitOptions.RemoveEmptyEntries);
foreach (var sp in split)
{
string[] split2 = sp.Split(':', StringSplitOptions.RemoveEmptyEntries);
fields.Add(split2[0]);
}
}
}
$"P1: {counter}".Dump();
bool Contains(string field)
{
return fields.Contains(field);
}
}