-
Notifications
You must be signed in to change notification settings - Fork 0
/
AoCUtils.h
65 lines (52 loc) · 1.33 KB
/
AoCUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef AOCUTIL
#define AOCUTIL
#define varName(v) (#v)
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <typeinfo>
#include <unordered_set>
using namespace std;
// Basic Read Lines, modify type whenever
vector<string> readLines(string filename)
{
ifstream file(filename);
string line;
vector<string> result;
while (getline(file, line)) {result.push_back(line);}
return result;
}
template <typename T>
void print1Dcontainer(T input)
{
cout << "\n=======================\n";
cout << "Printing " << typeid(input).name() << "\n\n";
cout << varName(input) << ": ";
for (auto i : input) {cout << i << " ";}
cout << "\n=======================\n";
}
template <typename T>
void print2Dcontainer(T input)
{
cout << "\n=======================\n";
cout << "Printing " << typeid(input).name() << "\n\n";
cout << varName(input) << ": \n";
for (auto i : input) {for (auto j : i) {cout << j << " ";} cout << "\n";}
cout << "\n=======================\n";
}
template <typename T>
vector<T> readLinewithComma(string input)
{
istringstream iss(input);
string line;
vector<T> result;
while (getline(iss, line, ',')) {result.push_back(line);}
return result;
}
#endif