-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare_codes.py
More file actions
72 lines (57 loc) · 1.54 KB
/
prepare_codes.py
File metadata and controls
72 lines (57 loc) · 1.54 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
import argparse
from pathlib import Path
from typing import List
template_code = """
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T> bool chmax(T &a, const T &b) {
if (a >= b)
return false;
a = b;
return true;
}
template <class T> bool chmin(T &a, const T &b) {
if (a <= b)
return false;
a = b;
return true;
}
void solve() {}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
"""
def main(args: argparse.Namespace):
output_dir: Path = args.dir
problems: List[str] = args.problems
output_dir.mkdir(parents=True, exist_ok=True)
for problem in problems:
problem_path: Path = output_dir / problem
if problem_path.with_suffix(".cpp").exists():
print(f"{problem} already exists")
continue
problem_path.with_suffix(".cpp").write_text(template_code.lstrip("\n"), encoding="utf-8")
list_files = [str(file) for file in output_dir.glob("*.cpp")]
print(f"Created files: {list_files}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Prepare code for the contest")
parser.add_argument(
"--dir",
type=Path,
default=Path().cwd(),
help="Directory to store the codes",
)
parser.add_argument(
"--problems",
nargs="+",
default=["a", "b", "c", "d", "e", "f"],
help="List of problems to prepare",
)
args = parser.parse_args()
main(args)