-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay13Test.php
163 lines (139 loc) · 2.14 KB
/
Day13Test.php
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
declare(strict_types=1);
namespace XonneX\AdventOfCode\Y2021\Solutions\Day13;
use PHPUnit\Framework\TestCase;
class Day13Test extends TestCase
{
public function testSolvePartOneExample(): void
{
$day13 = new Day13();
$day13->setDebugInput(<<<TXT
6,10
0,14
9,10
0,3
10,4
4,11
6,0
6,12
4,1
0,13
10,12
3,4
3,0
8,4
1,10
2,14
8,10
9,0
fold along y=7
fold along x=5
TXT
);
self::assertSame('17', $day13->solvePartOne());
}
public function testSolvePartOneTooHigh(): void
{
$day13 = new Day13();
self::assertLessThan('815', $day13->solvePartOne());
}
public function testSolvePartOne(): void
{
$day13 = new Day13();
self::assertSame('693', $day13->solvePartOne());
}
public function testSolvePartTwoExample(): void
{
$day13 = new Day13();
$day13->setDebugInput(<<<TXT
6,10
0,14
9,10
0,3
10,4
4,11
6,0
6,12
4,1
0,13
10,12
3,4
3,0
8,4
1,10
2,14
8,10
9,0
fold along y=7
fold along x=5
fold along x=2
fold along y=3
TXT
);
$expected = '
#####
#...#
#...#
#...#
#####
.....
.....
';
self::assertSame($expected, $day13->solvePartTwo());
}
public function testSolvePartTwoExampleTwo(): void
{
$day13 = new Day13();
$day13->setDebugInput(<<<TXT
1049,1721
2686,1404
3385,2284
1380,2354
3134,2238
1413,563
2053,1247
2430,163
2334,1208
1221,798
444,1884
2656,2241
798,1473
3873,2314
318,1952
537,1032
2848,2551
3461,313
2053,248
3555,524
761,76
446,1596
fold along y=1279
fold along y=639
fold along y=319
fold along x=2047
fold along x=1023
fold along x=511
fold along x=255
fold along x=127
fold along y=159
fold along y=79
fold along x=63
fold along y=39
fold along x=31
fold along x=15
fold along y=19
TXT
);
self::assertSame('HELP', $day13->solvePartTwo());
}
public function testSolvePartTwoNot(): void
{
$day13 = new Day13();
self::assertNotSame('UGLORAPU', $day13->solvePartTwo());
}
public function testSolvePartTwo(): void
{
$day13 = new Day13();
self::assertSame('NO_SOLUTION_INITIALIZED', $day13->solvePartTwo());
}
}