10 func GenInputFile(day int) string {
13 d = fmt.Sprintf("0%d", day)
15 d = fmt.Sprintf("%d", day)
19 path := fmt.Sprintf("%s\\day%s\\input.txt", pwd, d)
20 fi, _ := os.Stat(path)
25 fmt.Println("Creating new input file...")
26 f, _ := os.OpenFile(path, os.O_CREATE, 0700)
27 f.WriteString(readHttp(2022, day))
31 func readHttp(year, day int) string {
32 fmt.Println("Fetching data into file...")
34 url := fmt.Sprintf("https://adventofcode.com/%d/day/%d/input", year, day)
35 session := os.Getenv("sessionAoC")
37 req, err := http.NewRequest("GET", url, nil)
42 req.AddCookie(&http.Cookie{Name: "session", Value: session})
43 client := &http.Client{}
44 resp, err := client.Do(req)
49 body, err := io.ReadAll(resp.Body)