-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdayEleven.cpp
More file actions
136 lines (136 loc) · 4.04 KB
/
dayEleven.cpp
File metadata and controls
136 lines (136 loc) · 4.04 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// COMMENTED OUT CODE DISCLAIMER
// To ensure compilation for the other files with the BigInt.hpp or any other external header files, this entire file is commented out.
// In the current structure that only uses one file at a time, header files are not perfectly organised.
// Having many files in a project you have no intention of using is not a normal use case, therefore organising this perfectly is not a priority.
// To test this file, get the BigInt hpp file from github and add it to the Header Files, in my case in a "libs" filter.
// Comment out any other cpp files using it. Only the .cpp files should need to be edited.
// /COMMENTED OUT CODE DISCLAIMER
//#include <cstdlib>
//#include <iostream>
//#include <fstream>
//#include <string>
//#include <vector>
//#include "BigInt.hpp"
//
///** GENERAL NOTE:
//*
//* Several methods used in this project would be a good fit for extension methods.
//* Given the structure of the project this could lead do dependency issues.
//* The scope for every file is also small enough to not need it.
//*
//*/
//
//
//namespace DayEleven
//{
// namespace {
// void coutVectorContents(const std::string prefix, const std::vector<BigInt>& vector);
// void createStonesStartState(std::string& line);
//
// const bool toLog = true; // true false
// const char kDelim = ' ';
// const int maxLoops = 25;
// const int kMultiplier = 2024;
//
// std::vector<BigInt> stones;
//
// void iterateStones()
// {
// size_t size = stones.size();
// std::vector<BigInt> newStoneState;
// for (const auto& stone : stones)
// {
// if (stone == 0) {
// newStoneState.push_back(1);
// continue;
// }
// std::string stoneStr = stone.to_string();
// size_t len = stoneStr.length();
// if (len % 2 == 0) {
// newStoneState.push_back(BigInt(stoneStr.substr(0, len / 2)));
// newStoneState.push_back(BigInt(stoneStr.substr(len / 2)));
// }
// else {
// newStoneState.push_back(stone * kMultiplier);
// }
// }
// stones = newStoneState;
// }
//
// size_t getAmountOfStonesFromLine(std::string& line)
// {
// createStonesStartState(line);
// if (toLog) coutVectorContents("Start state: ", stones);
//
// for (size_t i = 0; i < maxLoops; i++)
// {
// iterateStones();
// std::string str = "State " + std::to_string(i) + ":\n";
// if (toLog) std::cout << str << stones.size() << '\n';
// }
//
// return 0;
// }
//
// void handleFile(std::ifstream& inputFile)
// {
// std::pair<int, int> startingGuardCoord;
// if (inputFile.is_open()) {
// std::string line;
// size_t stoneTotal = 0;;
// while (getline(inputFile, line)) { // single line
// stoneTotal = getAmountOfStonesFromLine(line);
// }
//
// std::cout << "Finished reading file\n";
//
// inputFile.close(); // automatically happens when going out of scope but no longer needed. More about explicitness.
//
// std::cout << "# of stones: " << stoneTotal << '\n';
//
// std::cout << "\nFinished running program";
// }
// else {
// std::cout << "Unable to open file\n";
// }
// }
//
// void createStonesStartState(std::string& line)
// {
// size_t pos = 0;
// while ((pos = line.find(kDelim)) != std::string::npos) {
// stones.emplace_back(line.substr(0, pos));
// line.erase(0, pos + 1);
// }
// if (!line.empty()) {
// stones.emplace_back(line);
// }
// }
//
// void coutVectorContents(const std::string prefix, const std::vector<BigInt>& vector)
// {
// std::cout << prefix;
// std::cout << "[";
// for (const auto& num : vector) {
// std::cout << num << ",";
// }
// std::cout << "]\n";
// }
// }
// void dayEleven() {
// std::system("cls"); // clear terminal pre-boot
// std::cout << "Running program DayEleven" << '\n';
// const bool isFullFile = true; // true false
//
// std::string line;
// std::ifstream inputFile;
// if (isFullFile) {
// std::cout << "Using full file\n\n";
// }
// else {
// std::cout << "Using test file\n\n";
// }
// (isFullFile) ? inputFile.open("dayElevenFull.txt") : inputFile.open("dayElevenTest.txt");
// handleFile(inputFile);
// }
//}