removing input from git

This commit is contained in:
Daniel Cortés
2020-12-06 03:31:53 -03:00
parent 1c830164a9
commit ee832719cd
3 changed files with 456 additions and 2 deletions

View File

@@ -15,6 +15,11 @@ std::vector<std::string> read_input_file() {
return data;
}
template <typename T>
T peek_back(T it) {
return --it;
}
int parse_id(std::string ticket) {
std::replace(ticket.begin(), ticket.end(), 'F', '0');
std::replace(ticket.begin(), ticket.end(), 'L', '0');
@@ -28,8 +33,7 @@ int solve_a(const std::set<int> &ids) { return *ids.rbegin(); }
int solve_b(const std::set<int> &ids) {
for(auto it = ++ids.begin(); it != ids.end(); it++){
auto prev = it; --prev;
if(*prev + 2 == *it) return *it - 1;
if(*peek_back(it) + 2 == *it) return *it - 1;
}
return 0;
}