Created
December 21, 2022 11:38
-
-
Save BruJu/1c27c7c31ea530d6083323b7ca15daf1 to your computer and use it in GitHub Desktop.
idk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../advent_of_code.hpp" | |
#include <algorithm> | |
#include <vector> | |
#include <array> | |
void print_line(const std::vector<bool> & values) { | |
for (const auto b : values) { | |
std::cout << (b ? 'X' : ' '); | |
} | |
std::cout << std::endl; | |
} | |
int to_int(bool b) { | |
return b ? 1 : 0; | |
} | |
Output day_2022_22(const std::vector<std::string> &, const DayExtraInfo &) { | |
int xmax = 101; | |
int ymax = 50; | |
// std::array<bool, 8> patterns { false, true, true, true, true, true, true, false }; | |
// std::array<bool, 8> patterns { false, true, true, true, true, false, false, false }; | |
std::array<bool, 8> patterns { false, true, false, false, true, false, false, false }; | |
std::vector<bool> values; | |
for (int i = 0; i != xmax; ++i) { | |
values.emplace_back(false); | |
} | |
values[xmax / 2 ] = true; | |
print_line(values); | |
for (int i = 0; i != ymax; ++i) { | |
const std::vector<bool> backup = values; | |
for (int x = 0; x != xmax; ++x) { | |
int l = x == 0 ? 0 : to_int(backup[x - 1]); | |
int m = to_int(backup[x]); | |
int r = x + 1 == xmax ? 0 : to_int(backup[x + 1]); | |
values[x] = patterns[(l << 2) + (m << 1) + r]; | |
} | |
print_line(values); | |
} | |
return Output(0,0); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment