Add .clang-format and apply it

This commit is contained in:
2021-12-02 07:18:16 +00:00
parent e58dede1b6
commit cd5e2538df
103 changed files with 2714 additions and 2132 deletions

View File

@@ -9,7 +9,8 @@
using Array = std::vector<std::string>;
char next_state(Array const &a, std::size_t row, std::size_t col) {
char next_state(Array const& a, std::size_t row, std::size_t col)
{
unsigned occupied = 0;
if (row > 0) {
if (col > 0) {
@@ -38,16 +39,19 @@ char next_state(Array const &a, std::size_t row, std::size_t col) {
if (a[row][col] == 'L' && occupied == 0) {
return '#';
} else if (a[row][col] == '#' && occupied >= 4) {
}
else if (a[row][col] == '#' && occupied >= 4) {
return 'L';
} else {
}
else {
return a[row][col];
}
}
unsigned long count_occupied(Array const &a) {
unsigned long count_occupied(Array const& a)
{
unsigned long count = 0;
for (auto const &row : a) {
for (auto const& row : a) {
for (auto col : row) {
count += (col == '#');
}
@@ -56,7 +60,8 @@ unsigned long count_occupied(Array const &a) {
return count;
}
unsigned long run_to_steady_state(Array const &a) {
unsigned long run_to_steady_state(Array const& a)
{
Array current = a;
bool changed = true;
unsigned i = 0;
@@ -81,7 +86,8 @@ unsigned long run_to_steady_state(Array const &a) {
return count_occupied(current);
}
int main(int argc, char **argv) {
int main(int argc, char** argv)
{
Array array;
for (std::string line; std::getline(std::cin, line);) {