-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task10Tests.cs
32 lines (29 loc) · 1000 Bytes
/
Task10Tests.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
using adventofcode_2021.Task10;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
namespace adventofcode_2021.Tests
{
public class Task10Tests
{
[Fact]
public void Task10_RealExample_Correct()
{
Assert.Equal(12, Solution.Function(ReadFileAsync(Path.Combine("Task10", "Data.txt"))));
}
private List<(Point, Point)> ReadFileAsync(string fileName)
{
var lines = File.ReadAllLines(fileName);
return lines
.Select(item =>
{
var temp = item.Split(" -> ").Select(x => x.Split(',')).ToList();
var start = new Point(int.Parse(temp[0][0]), int.Parse(temp[0][1]));
var end = new Point(int.Parse(temp[1][0]), int.Parse(temp[1][1]));
return (start.x < end.x || start.y < end.y) ? (start, end) : (end, start);
})
.ToList();
}
}
}