able to read the input and split input into two strings
This commit is contained in:
parent
acaa1d78be
commit
da436272dc
|
@ -4,8 +4,12 @@
|
|||
|
||||
#include "day01.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <ostream>
|
||||
#include <bits/fs_fwd.h>
|
||||
#include <bits/fs_path.h>
|
||||
|
||||
/*
|
||||
--- Day 1: Historian Hysteria ---
|
||||
|
@ -71,5 +75,28 @@ Your actual left and right lists contain many location IDs. What is the total di
|
|||
|
||||
void day01::Run()
|
||||
{
|
||||
std::cout << "Day 01" << std::endl;
|
||||
std::list<int> col1;
|
||||
std::list<int> col2;
|
||||
|
||||
// std::ifstream input("input/day01.txt");
|
||||
std::ifstream input("input/day01short.txt");
|
||||
|
||||
if (!input)
|
||||
{
|
||||
std::cerr << "Failed to open input file." << std::endl;
|
||||
std::cout << "Current path is " << std::filesystem::current_path() << '\n';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::string delimiter = " ";
|
||||
auto delimiterLength = delimiter.length();
|
||||
|
||||
std::string line;
|
||||
while (std::getline(input, line))
|
||||
{
|
||||
auto delimiterPos = line.find(delimiter);
|
||||
std::string firstNumber = line.substr(0, delimiterPos);
|
||||
std::string secondNumber = line.substr(delimiterPos + delimiterLength, line.length());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
66845 37619
|
||||
94793 99076
|
||||
76946 36179
|
||||
27374 48777
|
||||
47847 92154
|
||||
83270 97857
|
||||
19354 94331
|
||||
69716 58559
|
||||
16902 36957
|
||||
51817 88003
|
||||
40758 64262
|
||||
39074 90635
|
||||
34632 79874
|
||||
64980 96787
|
||||
96137 94559
|
||||
55489 98589
|
||||
95130 76776
|
||||
50275 50416
|
||||
46438 49722
|
||||
34182 49722
|
Loading…
Reference in New Issue