-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task30Tests.cs
53 lines (47 loc) · 1.45 KB
/
Task30Tests.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
51
52
53
using adventofcode_2021.Task30;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;
namespace adventofcode_2021.Tests
{
public class Task30Tests
{
[Fact]
public void Task30_RealExample_Correct()
{
Assert.Equal(315, Solution.Function(ReadFileAsync(Path.Combine("Task30", "Data.txt"))));
}
private List<List<int>> ReadFileAsync(string file)
{
var lines = File.ReadLines(file);
var count = lines.Count();
var result = new List<List<int>>();
foreach (var line in lines)
{
var subRes = new List<int>();
var item = line.ToCharArray().Select(ch => ch - '0').ToList();
for (int i = 0; i < 5; i++)
{
subRes.AddRange(item);
}
result.Add(subRes);
}
var items = result;
var a = (4 * lines.Count());
for (int i = 0; i < a; i++)
{
result.Add(new List<int>(items[i]));
}
for (int i = 0; i < result.Count; i++)
{
for (int j = 0; j < result.Count; j++)
{
var number = (result[i][j] + i / count + j / count);
result[i][j] = number > 9 ? number % 9 : number;
}
}
return result;
}
}
}