2023 day 11: disgusting cheese solution

This commit is contained in:
eriedaberrie 2023-12-10 22:04:30 -08:00
parent 813bf64be5
commit 40eba96264
2 changed files with 21 additions and 1 deletions

View file

@ -1,14 +1,18 @@
#include <bits/stdc++.h> #include <bits/stdc++.h>
using namespace std; using namespace std;
int main() { int main(int argc, char* argv[]) {
ios::sync_with_stdio(0); ios::sync_with_stdio(0);
cin.tie(0); cin.tie(0);
bool dontwork = argc == 2 && !strcmp(argv[1], "DONTWORK");
vector<string> lines; vector<string> lines;
string line; string line;
while (getline(cin, line) && !line.empty()) { while (getline(cin, line) && !line.empty()) {
lines.push_back(line); lines.push_back(line);
if (dontwork)
goto next1;
for (char c : line) { for (char c : line) {
if (c != '.') { if (c != '.') {
goto next1; goto next1;
@ -18,6 +22,8 @@ int main() {
next1:; next1:;
} }
if (dontwork)
goto next3;
for (unsigned int col = 0; col < lines[0].size(); col++) { for (unsigned int col = 0; col < lines[0].size(); col++) {
for (auto& r : lines) { for (auto& r : lines) {
if (r[col] != '.') { if (r[col] != '.') {
@ -30,6 +36,7 @@ int main() {
col++; col++;
next2:; next2:;
} }
next3:
vector<pair<int, int>> gs; vector<pair<int, int>> gs;
for (unsigned int row = 0; row < lines.size(); row++) { for (unsigned int row = 0; row < lines.size(); row++) {

13
2023/11/main-2.rb Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
# decidedly mozzarella flavored
`make main-1`
file_name = "data.txt"
base = Integer(`./main-1 DONTWORK < #{file_name}`)
plus1 = Integer(`./main-1 < #{file_name}`)
puts base + (plus1 - base) * 999_999