Minor day 5 cleanup
parent
d8c1297bf3
commit
6a081412a9
|
@ -1,7 +1,7 @@
|
|||
CC=g++
|
||||
BIN_NAME=day5
|
||||
CCFLAGS=-o $(BIN_NAME) -g
|
||||
LDFLAGS=-lfolly -std=c++17
|
||||
LDFLAGS=-std=c++17
|
||||
|
||||
.PHONY: all, clean
|
||||
|
||||
|
|
|
@ -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 max = initMax;
|
||||
int min = 0;
|
||||
int stringCursor = 0;
|
||||
for (char candidate : spec) {
|
||||
// std::cout << min << " " << max << std::endl;
|
||||
// std::cout << candidate << std::endl;
|
||||
if (candidate == topHalfChar) {
|
||||
max = (max + min) / 2;
|
||||
} else if (candidate == bottomHalfChar) {
|
||||
min += (max - min) / 2 + 1;
|
||||
}
|
||||
|
||||
stringCursor++;
|
||||
}
|
||||
|
||||
return min;
|
||||
|
|
Loading…
Reference in New Issue