-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task37Tests.cs
42 lines (39 loc) · 1.22 KB
/
Task37Tests.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
using adventofcode_2021.Task37;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
namespace adventofcode_2021.Tests
{
public class Task37Tests
{
[Fact]
public void Task37_RealExample_Correct()
{
Assert.Equal(79, Solution.Function(ReadFileAsync(Path.Combine("Task37", "Data.txt"))));
}
private List<HashSet<Point>> ReadFileAsync(string fileName)
{
var result = new List<HashSet<Point>>();
var currentPoints = new HashSet<Point>();
foreach (var line in File.ReadLines(fileName))
{
if (line.StartsWith("--- scanner"))
{
if (currentPoints.Count > 0)
{
result.Add(currentPoints);
currentPoints = new();
}
}
else if (!string.IsNullOrEmpty(line))
{
var n = line.Split(',').Select(x => int.Parse(x)).ToList();
currentPoints.Add(new Point(n[0], n[1], n[2]));
}
}
result.Add(currentPoints);
return result;
}
}
}