summaryrefslogtreecommitdiff
path: root/aoc22/new
diff options
context:
space:
mode:
authormathiasmagnusson <mathiasmagnussons@gmail.com>2022-12-09 18:00:02 +0100
committermathiasmagnusson <mathiasmagnussons@gmail.com>2022-12-09 18:00:02 +0100
commite41e6c8bc72e3300a0fa137f198454341bc315b1 (patch)
treea26e34327b7e68adf9b1dc802a897b9b0626de86 /aoc22/new
parent444d543b1af11ff8718cf07c690944ddacb29105 (diff)
downloadprogramming-problem-solving-e41e6c8bc72e3300a0fa137f198454341bc315b1.tar.gz
Add aoc
Diffstat (limited to 'aoc22/new')
-rwxr-xr-xaoc22/new55
1 files changed, 55 insertions, 0 deletions
diff --git a/aoc22/new b/aoc22/new
new file mode 100755
index 0000000..b6c234f
--- /dev/null
+++ b/aoc22/new
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+
+from sys import argv
+from os import mkdir, chdir
+
+def main():
+ day = int(argv[1])
+ with open("Cargo.toml", "r") as f:
+ cargo_toml = f.read()
+ new_cargo_toml = []
+ for line in cargo_toml.splitlines():
+ if line == "]":
+ new_cargo_toml.append(f" \"day{day}\",")
+ new_cargo_toml.append(line)
+ with open("Cargo.toml", "w") as f:
+ for line in new_cargo_toml:
+ f.write(line)
+ f.write("\n")
+
+ mkdir(f"day{day}")
+ chdir(f"day{day}")
+
+ with open("Cargo.toml", "w") as f:
+ f.write(f"""
+[package]
+name = "day{day}"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+lib = {{ path = "../lib" }}
+ """.strip())
+ f.write("\n")
+
+ mkdir("src")
+
+ with open("src/main.rs", "w") as f:
+ f.write(f"""
+fn main() {{
+ let input = lib::read_input({day});
+
+ part1(&input);
+ part2(&input);
+}}
+
+fn part1(input: &str) {{
+}}
+
+fn part2(input: &str) {{
+}}
+ """.strip())
+ f.write("\n")
+
+if __name__ == "__main__":
+ main()