Minor day 5 cleanup

master
Nick Krichevsky 2020-12-05 01:40:37 -05:00
parent d8c1297bf3
commit 6a081412a9
2 changed files with 1 additions and 6 deletions

View File

@ -1,7 +1,7 @@
CC=g++ CC=g++
BIN_NAME=day5 BIN_NAME=day5
CCFLAGS=-o $(BIN_NAME) -g CCFLAGS=-o $(BIN_NAME) -g
LDFLAGS=-lfolly -std=c++17 LDFLAGS=-std=c++17
.PHONY: all, clean .PHONY: all, clean

View File

@ -36,17 +36,12 @@ std::vector<std::string> read_input(const std::string &filename) {
int getPosFromSpec(std::string_view spec, char bottomHalfChar, char topHalfChar, int initMax) { int getPosFromSpec(std::string_view spec, char bottomHalfChar, char topHalfChar, int initMax) {
int max = initMax; int max = initMax;
int min = 0; int min = 0;
int stringCursor = 0;
for (char candidate : spec) { for (char candidate : spec) {
// std::cout << min << " " << max << std::endl;
// std::cout << candidate << std::endl;
if (candidate == topHalfChar) { if (candidate == topHalfChar) {
max = (max + min) / 2; max = (max + min) / 2;
} else if (candidate == bottomHalfChar) { } else if (candidate == bottomHalfChar) {
min += (max - min) / 2 + 1; min += (max - min) / 2 + 1;
} }
stringCursor++;
} }
return min; return min;