Add solution for 2016 Day 6
This commit is contained in:
+48
-13
@@ -2,30 +2,65 @@
|
||||
|
||||
namespace y2016::day06
|
||||
{
|
||||
REGISTER_DAY(2016, Day06, std::vector<int>, int);
|
||||
REGISTER_DAY(2016, Day06, Array2D<char>, std::string);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2016, Day06, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2016, Day06, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2016, Day06, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2016, Day06, Input, 2, 0);
|
||||
REGISTER_TEST_EXAMPLE(2016, Day06, ExampleInput, 1, "easter");
|
||||
REGISTER_TEST(2016, Day06, Input, 1, "xhnqpqql");
|
||||
REGISTER_TEST_EXAMPLE(2016, Day06, ExampleInput, 2, "advent");
|
||||
REGISTER_TEST(2016, Day06, Input, 2, "brhailro");
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (getline(input, str))
|
||||
{
|
||||
}
|
||||
return vec;
|
||||
return Input::ReadArray2D(input);
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
std::string result;
|
||||
for (int x = 0; x < input.width; x++)
|
||||
{
|
||||
std::map<char, int> map;
|
||||
for (int y = 0; y < input.height; y++)
|
||||
{
|
||||
map[input.Get(x, y)]++;
|
||||
}
|
||||
int max = 0;
|
||||
char maxChar;
|
||||
for (const auto& [c, count] : map)
|
||||
{
|
||||
if (count > max)
|
||||
{
|
||||
maxChar = c;
|
||||
max = count;
|
||||
}
|
||||
}
|
||||
result.push_back(maxChar);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
std::string result;
|
||||
for (int x = 0; x < input.width; x++)
|
||||
{
|
||||
std::map<char, int> map;
|
||||
for (int y = 0; y < input.height; y++)
|
||||
{
|
||||
map[input.Get(x, y)]++;
|
||||
}
|
||||
int min = std::numeric_limits<int>::max();
|
||||
char minChar;
|
||||
for (const auto& [c, count] : map)
|
||||
{
|
||||
if (count < min)
|
||||
{
|
||||
minChar = c;
|
||||
min = count;
|
||||
}
|
||||
}
|
||||
result.push_back(minChar);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user