#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 #include 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/input0"); auto p = aoc2016::day22(lv); // REQUIRE(990 == p.first); REQUIRE(0 == p.second); } TEST_CASE("Safe Cracking", "[2016]") { line_view lv = load_file("../src/2016/day23/input"); auto p = aoc2016::day23(lv); REQUIRE(13140 == 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); }