-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewDay.py
More file actions
121 lines (95 loc) · 2.56 KB
/
newDay.py
File metadata and controls
121 lines (95 loc) · 2.56 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
# Generate a new day as required
import os
import sys
import shutil
# Get year & day number
year = input("Year: ")
day = str(input("Day: ")).zfill(2)
dayPath = year + '/' + 'Day_' + day
# Check the year exists, create a new one if required
if not os.path.exists(year):
os.makedirs(year)
# Check if the Day exists, check if we want to overwrite or cancel
if not os.path.exists(dayPath):
os.makedirs(dayPath)
else:
# Check if we want to overwrite
clear = input(dayPath + " already exists, overwrite it? y/n: ")
if (clear == "y"):
shutil.rmtree(dayPath)
os.makedirs(dayPath)
else:
print("Exiting, day generation aborted")
sys.exit()
# Assume we have a year & day directory, populate it
# Empty input files
open(dayPath + "/input.txt", "x")
open(dayPath + "/test-01.txt", "x")
open(dayPath + "/Day_" + day + "_Problem.txt", "x")
# Write a basic CMakeLists
cmakeFile = open(dayPath + "/CMakeLists.txt", "w")
cmakeFile.write("""
cmake_minimum_required(VERSION 3.21)
project(Day_%s)
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.0-preview3
)
FetchContent_MakeAvailable(Catch2)
set(CMAKE_CXX_STANDARD 14)
add_executable(Day_%s Day_%s.cpp)
target_link_libraries(Day_%s PRIVATE Catch2::Catch2WithMain)
""" % (day, day, day, day))
cmakeFile.close()
cppFile = open(dayPath + "/Day_" + day + ".cpp", "w")
cppFile.write("""/* Day_%s - %s */
#define CATCH_CONFIG_MAIN
#include <catch2/catch_test_macros.hpp>
#include <fstream>
#include <iterator>
#include <vector>
std::vector<std::string> parseInput(std::string filepath)
{
std::ifstream in(filepath);
std::vector<std::string> fileData;
for (std::string line; std::getline(in, line); /* */)
{
fileData.push_back(line);
}
return fileData;
}
// TBD
int solvePartOne(std::vector<std::string> &data)
{
return 0;
}
// TBD
int solvePartTwo(std::vector<std::string> &data)
{
return 0;
}
// Tests
TEST_CASE("P1_TestData")
{
std::vector<std::string> data = parseInput("../test-01.txt");
REQUIRE(solvePartOne(data) == 999);
}
TEST_CASE("P1_InputData")
{
std::vector<std::string> data = parseInput("../input.txt");
REQUIRE(solvePartOne(data) == 999);
}
TEST_CASE("P2_TestData")
{
std::vector<std::string> data = parseInput("../test-01.txt");
REQUIRE(solvePartTwo(data) == 999);
}
TEST_CASE("P2_InputData")
{
std::vector<int> data = parseInput("../input.txt");
REQUIRE(solvePartTwo(data) == 999);
}
""" % (day, year))
cppFile.close()