day7 1 and 2 done

This commit is contained in:
2024-12-15 12:57:12 +01:00
parent ff0b63dbdd
commit 97cb3b6639
5 changed files with 231 additions and 21 deletions
+17
View File
@@ -0,0 +1,17 @@
#define RESET "\033[0m"
#define BLACK "\033[30m" /* Black */
#define RED "\033[31m" /* Red */
#define GREEN "\033[32m" /* Green */
#define YELLOW "\033[33m" /* Yellow */
#define BLUE "\033[34m" /* Blue */
#define MAGENTA "\033[35m" /* Magenta */
#define CYAN "\033[36m" /* Cyan */
#define WHITE "\033[37m" /* White */
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
+31 -9
View File
@@ -1,8 +1,9 @@
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
inline std::vector<std::string> splitString(const std::string &str) {
std::vector<std::string> splitString(const std::string &str) {
std::istringstream iss(str);
std::vector<std::string> words;
std::string word;
@@ -14,15 +15,13 @@ inline std::vector<std::string> splitString(const std::string &str) {
return words;
}
inline void
ConvertStringVectorToIntVector(const std::vector<std::string> &strVec,
std::vector<int> &intVec) {
void ConvertStringVectorToIntVector(const std::vector<std::string> &strVec,
std::vector<int> &intVec) {
std::transform(strVec.begin(), strVec.end(), std::back_inserter(intVec),
[](const std::string &s) { return std::stoi(s); });
}
inline bool AreWeInBounds(int x, int y,
std::vector<std::vector<char>> &TwoDCharVec) {
bool AreWeInBounds(int x, int y, std::vector<std::vector<char>> &TwoDCharVec) {
if (x < 0 || y < 0) {
return false;
}
@@ -32,19 +31,42 @@ inline bool AreWeInBounds(int x, int y,
return true;
}
inline int conditional_operation(int a, int b, char op) {
int conditional_operation(int a, int b, char op) {
switch (op) {
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
case 'c':
return std::stoi(std::to_string(a) + std::to_string(b));
default:
return a;
}
}
inline std::vector<std::string> splitStringByChar(const std::string &str,
char c) {
unsigned long long conditional_operation_ull(unsigned long long a,
unsigned long long b, char op) {
switch (op) {
case '+':
return a + b;
case '-':
return a - b;
case '*':
return a * b;
case '/':
return a / b;
case 'c':
return std::stoull(std::to_string(a) + std::to_string(b));
default:
return a;
}
}
std::vector<std::string> splitStringByChar(const std::string &str, char c) {
std::vector<std::string> words;
std::string word;
std::istringstream iss(str);