aboutsummaryrefslogtreecommitdiff
path: root/test/test_2016.cpp
blob: 092ad7adcaed3c02b311ae78121c140f66c35392 (plain)
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include "2016/day1/aoc.h"
#include "2016/day2/aoc.h"
#include "2016/day3/aoc.h"
#include "2016/day4/aoc.h"
#include "2016/day5/aoc.h"
#include "2016/day6/aoc.h"
#include "2016/day7/aoc.h"
#include "2016/day8/aoc.h"
#include "2016/day9/aoc.h"
#include "2016/day10/aoc.h"
#include "2016/day11/aoc.h"
#include "2016/day12/aoc.h"
#include "2016/day13/aoc.h"
#include "2016/day14/aoc.h"
#include "2016/day15/aoc.h"
#include "2016/day16/aoc.h"
#include "2016/day17/aoc.h"
#include "2016/day18/aoc.h"
#include "2016/day19/aoc.h"
#include "2016/day20/aoc.h"
#include "2016/day21/aoc.h"
#include "2016/day22/aoc.h"
#include "2016/day23/aoc.h"
#include "2016/day24/aoc.h"
#include "2016/day25/aoc.h"
#include "catch.hpp"
#include <stdio.h>
#include <string.h>

TEST_CASE("No Time for a Taxicab", "[2016]") {
  line_view lv = load_file("../src/2016/day1/input");
  auto p = aoc2016::day1(lv);
  REQUIRE(298 == p.first);
  REQUIRE(158 == p.second);
}

TEST_CASE("Bathroom Security", "[2016]") {
  line_view lv = load_file("../src/2016/day2/input");
  char codes[6] = {0};
  int code = aoc2016::day2(lv, codes);
  REQUIRE(82958 == code);
  REQUIRE(strcmp(codes, "B3DB8") == 0);
}

TEST_CASE("Squares With Three Sides", "[2016]") {
  line_view lv = load_file("../src/2016/day3/input");
  auto p = aoc2016::day3(lv);
  REQUIRE(862 == p.first);
  REQUIRE(1577 == p.second);
}

TEST_CASE("Security Through Obscurity", "[2016]") {
  line_view lv = load_file("../src/2016/day4/input");
  auto p = aoc2016::day4(lv);
  REQUIRE(185371 == p.first);
  REQUIRE(984 == p.second);
}

TEST_CASE("How About a Nice Game of Chess?", "[2016]") {
  // char pass1[9] = {0};
  // char pass2[9] = {0};
  // aoc2016::day5("abbhdwsy", 8, pass1, pass2);
  // printf("%s %s\n", pass1, pass2);
}

TEST_CASE("Signals and Noise", "[2016]") {
  line_view lv = load_file("../src/2016/day6/input");
  char msg1[9] = {0};
  char msg2[9] = {0};
  aoc2016::day6(lv, msg1, msg2);
  REQUIRE(strcmp("gebzfnbt", msg1) == 0);
  REQUIRE(strcmp("fykjtwyn", msg2) == 0);
}

TEST_CASE("Internet Protocol Version 7", "[2016]") {
  line_view lv = load_file("../src/2016/day7/input");
  auto p = aoc2016::day7(lv);
  REQUIRE(115 == p.first);
  REQUIRE(231 == p.second);
}

TEST_CASE("Two-Factor Authentication", "[2016]") {
  line_view lv = load_file("../src/2016/day8/input");
  auto p = aoc2016::day8(lv);
  REQUIRE(128 == p);
}

TEST_CASE("Explosives in Cyberspace", "[2016]") {
  line_view lv = load_file("../src/2016/day9/input");
  auto p = aoc2016::day9(lv);
  REQUIRE(112830 == p.first);
  REQUIRE(10931789799 == p.second);
  // const char* ps[] = {"ADVENT", "A(1x5)BC", "(3x3)XYZ", "A(2x2)BCD(2x2)EFG", "(6x1)(1x3)A", "X(8x2)(3x3)ABCY"};
  // const char* ps[] = {"(3x3)XYZ", "X(8x2)(3x3)ABCY", "(27x12)(20x12)(13x14)(7x10)(1x12)A",
  //                     "(25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN"};
  // for (auto p : ps) {
  //   auto x = aoc2016::day9(p);
  //   printf("%s -> (%d, %d)\n", p, x.first, x.second);
  // }
}

TEST_CASE("Balance Bots", "[2016]") {
  line_view lv = load_file("../src/2016/day10/input");
  auto p = aoc2016::day10(lv);
  REQUIRE(147 == p.first);
  REQUIRE(55637 == p.second);
}

TEST_CASE("Radioisotope Thermoelectric Generators", "[2016]") {
  line_view lv = load_file("../src/2016/day11/input");
  auto p = aoc2016::day11(lv);
  REQUIRE(0 == p.first);
  REQUIRE(0 == p.second);
}


TEST_CASE("Leonardo's Monorail", "[2016]") {
  line_view lv = load_file("../src/2016/day12/input");
  auto p = aoc2016::day12(lv);
  REQUIRE(318077 == p.first);
  REQUIRE(0 == p.second);
}


TEST_CASE("A Maze of Twisty Little Cubicles", "[2016]") {
  line_view lv = load_file("../src/2016/day13/input");
  auto p = aoc2016::day13(lv);
  REQUIRE(90 == p.first);
  REQUIRE(135 == p.second);
}


TEST_CASE("One-Time Pad", "[2016]") {
  line_view lv = load_file("../src/2016/day14/input");
  auto p = aoc2016::day14(lv);
  REQUIRE(35186 == p.first);
  REQUIRE(0 == p.second);
}


TEST_CASE("Timing is Everything", "[2016]") {
  line_view lv = load_file("../src/2016/day15/input");
  auto p = aoc2016::day15(lv);
  REQUIRE(317371 == p.first);
  REQUIRE(2080951 == p.second);
}


TEST_CASE("Dragon Checksum", "[2016]") {
  line_view lv = load_file("../src/2016/day16/input");
  auto p = aoc2016::day16(lv);
  REQUIRE("01110011101111011" == p.first);
  REQUIRE("11001111011000111" == p.second);
}


TEST_CASE("Two Steps Forward", "[2016]") {
  line_view lv = load_file("../src/2016/day17/input");
  auto p = aoc2016::day17(lv);
  REQUIRE("DDURRLRRDD" == p.first);
  REQUIRE(436 == p.second);
}


TEST_CASE("Like a Rogue", "[2016]") {
  line_view lv = load_file("../src/2016/day18/input");
  auto p = aoc2016::day18(lv);
  REQUIRE(2035 == p.first);
  REQUIRE(20000577 == p.second);
}


TEST_CASE("An Elephant Named Joseph", "[2016]") {
  line_view lv = load_file("../src/2016/day19/input");
  auto p = aoc2016::day19(lv);
  REQUIRE(1816277 == p.first);
  REQUIRE(1410967 == p.second);
}


TEST_CASE("Firewall Rules", "[2016]") {
  line_view lv = load_file("../src/2016/day20/input");
  auto p = aoc2016::day20(lv);
  REQUIRE(0 == p.first);
  REQUIRE(104 == p.second);
}


TEST_CASE("Scrambled Letters and Hash", "[2016]") {
  line_view lv = load_file("../src/2016/day21/input");
  char cs[8] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
  char xs[8] = {'f', 'b', 'g', 'd', 'c', 'e', 'a', 'h'};
  aoc2016::day21(lv,cs, xs);
  REQUIRE(memcmp(cs, "bdfhgeca", 8) == 0);
  REQUIRE(memcmp(xs, "gdfcabeh", 8) == 0);
}


TEST_CASE("Grid Computing", "[2016]") {
  line_view lv = load_file("../src/2016/day22/input");
  auto p = aoc2016::day22(lv);
  REQUIRE(990 == p.first);
  REQUIRE(0 == p.second);
}


TEST_CASE("", "[2016]") {
  line_view lv = load_file("../src/2016/day23/input");
  auto p = aoc2016::day23(lv);
  REQUIRE(0 == p.first);
  REQUIRE(0 == p.second);
}


TEST_CASE("", "[2016]") {
  line_view lv = load_file("../src/2016/day24/input");
  auto p = aoc2016::day24(lv);
  REQUIRE(0 == p.first);
  REQUIRE(0 == p.second);
}


TEST_CASE("", "[2016]") {
  line_view lv = load_file("../src/2016/day25/input");
  auto p = aoc2016::day25(lv);
  REQUIRE(0 == p.first);
  REQUIRE(0 == p.second);
}