-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.jl
45 lines (35 loc) · 1017 Bytes
/
run.jl
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
using ArgParse
using HTTP
using Dates
function parse_arguments()
s = ArgParseSettings()
@add_arg_table s begin
"--year", "-y"
help = "Year of AoC contest"
arg_type = Int
default = year(now())
"--day", "-d"
help = "Day of AoC problem"
arg_type = Int
end
parse_args(s)
end
function load_aoc_file(year, day)
filename = "$(year)/$(day).in"
if !isfile(filename)
cookie = Dict("session" => read("cookie", String))
content = HTTP.request(:GET, "https://adventofcode.com/$(year)/day/$(day)/input", cookies=cookie).body |> String
open(filename, "w") do io
print(io, content)
end
end
end
function main()
args = parse_arguments()
load_aoc_file(args["year"], args["day"])
prgrm_file = """$(args["year"])/$(args["day"]).jl"""
input_file = """$(args["year"])/$(args["day"]).in"""
cmd = `julia --project -t 12 $prgrm_file`
run(pipeline(cmd, stdin=input_file))
end
main()