remove bad using
This commit is contained in:
parent
eb0dbc61b7
commit
4aca0f39cb
18
src/day1.cpp
18
src/day1.cpp
@ -4,23 +4,21 @@
|
|||||||
|
|
||||||
struct Data{ char dir; int64_t cnt; };
|
struct Data{ char dir; int64_t cnt; };
|
||||||
|
|
||||||
using std::cout, std::endl, std::vector, std::ifstream;
|
int64_t part_1(const std::vector<Data>&);
|
||||||
|
int64_t part_2(const std::vector<Data>&);
|
||||||
int64_t part_1(const vector<Data>&);
|
|
||||||
int64_t part_2(const vector<Data>&);
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
ifstream file{"input/2025-1.txt"};
|
std::ifstream file{"input/2025-1.txt"};
|
||||||
Data line;
|
Data line;
|
||||||
vector<Data> v;
|
std::vector<Data> v;
|
||||||
while (file >> line.dir >> line.cnt) {
|
while (file >> line.dir >> line.cnt) {
|
||||||
v.push_back(line);
|
v.push_back(line);
|
||||||
}
|
}
|
||||||
cout << "Part 1: " << part_1(v) << endl;
|
std::cout << "Part 1: " << part_1(v) << std::endl;
|
||||||
cout << "Part 1: " << part_2(v) << endl;
|
std::cout << "Part 1: " << part_2(v) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t part_1(const vector<Data>& v) {
|
int64_t part_1(const std::vector<Data>& v) {
|
||||||
int64_t loc{50}, presses{0};
|
int64_t loc{50}, presses{0};
|
||||||
for (auto data : v) {
|
for (auto data : v) {
|
||||||
if (data.dir == 'L') {
|
if (data.dir == 'L') {
|
||||||
@ -40,7 +38,7 @@ int64_t part_1(const vector<Data>& v) {
|
|||||||
return presses;
|
return presses;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t part_2(const vector<Data>& v) {
|
int64_t part_2(const std::vector<Data>& v) {
|
||||||
int64_t loc{50}, presses{0};
|
int64_t loc{50}, presses{0};
|
||||||
for (auto data : v) {
|
for (auto data : v) {
|
||||||
auto last_loc = loc;
|
auto last_loc = loc;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user