Compare commits
19 Commits
6bd452a4ec
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b989b8d68 | |||
| 4fa993c840 | |||
| 43fcaef247 | |||
| 65eafb1d56 | |||
| c27b981663 | |||
| 0c1fc940b3 | |||
| bc168219f3 | |||
| 9b098af432 | |||
| 62342c7aa9 | |||
| 86dc7fcebe | |||
| 6da7eb85a0 | |||
| e331b926eb | |||
| afa56835c4 | |||
| 07621181b0 | |||
| b1816dcbf8 | |||
| c82ee691a1 | |||
| a9801cc262 | |||
| edfc914c7b | |||
| 324a593c99 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
**/input*.txt
|
**/input*.txt
|
||||||
.DS_Store
|
**/test*.txt
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
0
2023/.gitkeep
Normal file
0
2023/.gitkeep
Normal file
3
2023/01/go.mod
Normal file
3
2023/01/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.21.4
|
||||||
44
2023/01/main.go
Normal file
44
2023/01/main.go
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines := parse()
|
||||||
|
|
||||||
|
var first = 0
|
||||||
|
var last = 0
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
fmt.Println(line)
|
||||||
|
for i := 0; i < len(line); i++ {
|
||||||
|
//fmt.Println(int(line[i]))
|
||||||
|
x := strconv.Atoi(line[i])
|
||||||
|
if x {
|
||||||
|
first = x
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := 0; i < len(line); i++ {
|
||||||
|
//fmt.Println(int(line[i]))
|
||||||
|
x, err := strconv.Atoi(line[i])
|
||||||
|
if err == nil {
|
||||||
|
last = x
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() []string {
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, _ := os.ReadFile(filePath)
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
return chunks
|
||||||
|
}
|
||||||
5
2023/go.work
Normal file
5
2023/go.work
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
go 1.23.3
|
||||||
|
|
||||||
|
use (
|
||||||
|
./01
|
||||||
|
)
|
||||||
3
2024/01/go.mod
Normal file
3
2024/01/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.23.3
|
||||||
69
2024/01/main.go
Normal file
69
2024/01/main.go
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines := parse()
|
||||||
|
|
||||||
|
var left = []int{}
|
||||||
|
var right = []int{}
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
nums := strings.Fields(line)
|
||||||
|
|
||||||
|
l, _ := strconv.Atoi(nums[0])
|
||||||
|
r, _ := strconv.Atoi(nums[1])
|
||||||
|
left = append(left, l)
|
||||||
|
right = append(right, r)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Ints(left)
|
||||||
|
sort.Ints(right)
|
||||||
|
|
||||||
|
var sum = 0
|
||||||
|
|
||||||
|
for i := 0; i < len(left); i++ {
|
||||||
|
var diff = right[i] - left[i]
|
||||||
|
if diff < 0 {
|
||||||
|
diff *= -1
|
||||||
|
}
|
||||||
|
sum += diff
|
||||||
|
}
|
||||||
|
|
||||||
|
var similarity = 0
|
||||||
|
|
||||||
|
for i := 0; i < len(left); i++ {
|
||||||
|
var count = 0
|
||||||
|
for j := 0; j < len(right); j++ {
|
||||||
|
if left[i] == right[j] {
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
similarity += count * left[i]
|
||||||
|
}
|
||||||
|
fmt.Println(sum)
|
||||||
|
fmt.Println(similarity)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() []string {
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, _ := os.ReadFile(filePath)
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
var nonEmpthyChunks = []string{}
|
||||||
|
|
||||||
|
for _, chunk := range chunks {
|
||||||
|
if chunk != "" {
|
||||||
|
nonEmpthyChunks = append(nonEmpthyChunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nonEmpthyChunks
|
||||||
|
}
|
||||||
3
2024/02/go.mod
Normal file
3
2024/02/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.23.3
|
||||||
115
2024/02/main.go
Normal file
115
2024/02/main.go
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Increasing = 1
|
||||||
|
Decreasing = -1
|
||||||
|
)
|
||||||
|
|
||||||
|
func absInt(x int) int {
|
||||||
|
return absDiffInt(x, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func absDiffInt(x, y int) int {
|
||||||
|
if x < y {
|
||||||
|
return y - x
|
||||||
|
}
|
||||||
|
return x - y
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkDirection(x int) int {
|
||||||
|
switch {
|
||||||
|
case x < 0:
|
||||||
|
return Increasing
|
||||||
|
case x > 0:
|
||||||
|
return Decreasing
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func checklevel(report []int) bool {
|
||||||
|
dir := checkDirection(report[0] - report[1])
|
||||||
|
for i := 0; i < len(report)-1; i++ {
|
||||||
|
zero := report[i]
|
||||||
|
one := report[i+1]
|
||||||
|
diff := zero - one
|
||||||
|
if newDir := checkDirection(diff); newDir != dir {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
absDiff := absInt(diff)
|
||||||
|
if absDiff < 1 || absDiff > 3 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines, err := parse()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var safes = 0
|
||||||
|
var safes2 = 0
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
numbers := strings.Fields(line)
|
||||||
|
report := make([]int, len(numbers))
|
||||||
|
for i, num := range numbers {
|
||||||
|
x, err := strconv.Atoi(num)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
report[i] = x
|
||||||
|
}
|
||||||
|
if checklevel(report) {
|
||||||
|
safes++
|
||||||
|
safes2++
|
||||||
|
} else {
|
||||||
|
var checks = 0
|
||||||
|
for j := 0; j < len(report); j++ {
|
||||||
|
copyArray := make([]int, len(report))
|
||||||
|
copy(copyArray, report)
|
||||||
|
report2 := append(copyArray[:j], copyArray[j+1:]...)
|
||||||
|
if checklevel(report2) {
|
||||||
|
checks++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if checks >= 1 {
|
||||||
|
safes2++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("p1: ", safes)
|
||||||
|
fmt.Println("p2: ", safes2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() ([]string, error) {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
return nil, fmt.Errorf("no file provided")
|
||||||
|
}
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error opening file: %v", err)
|
||||||
|
}
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
var nonEmpthyChunks = []string{}
|
||||||
|
|
||||||
|
for _, chunk := range chunks {
|
||||||
|
if chunk != "" {
|
||||||
|
nonEmpthyChunks = append(nonEmpthyChunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nonEmpthyChunks, nil
|
||||||
|
}
|
||||||
3
2024/03/go.mod
Normal file
3
2024/03/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.23.3
|
||||||
75
2024/03/main.go
Normal file
75
2024/03/main.go
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func calculate(x string) int {
|
||||||
|
|
||||||
|
clean1 := strings.Replace(x, "mul(", "", -1)
|
||||||
|
clean2 := strings.Replace(clean1, ")", "", -1)
|
||||||
|
splat := strings.Split(clean2, ",")
|
||||||
|
|
||||||
|
l, err := strconv.Atoi(splat[0])
|
||||||
|
if err != nil {
|
||||||
|
}
|
||||||
|
r, err := strconv.Atoi(splat[1])
|
||||||
|
if err != nil {
|
||||||
|
}
|
||||||
|
|
||||||
|
return l * r
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines, err := parse()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
}
|
||||||
|
oneline := strings.Join(lines, "")
|
||||||
|
|
||||||
|
var p1 int = 0
|
||||||
|
var p2 int = 0
|
||||||
|
|
||||||
|
re := regexp.MustCompile(`mul\(\d+,\d+\)`)
|
||||||
|
matches := re.FindAllString(oneline, -1)
|
||||||
|
for i := 0; i < len(matches); i++ {
|
||||||
|
p1 += calculate(matches[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
onecleanre := regexp.MustCompile(`(?s)don\'t\(\).*?do\(\)|$`)
|
||||||
|
oneclean := onecleanre.ReplaceAllString(oneline, "")
|
||||||
|
|
||||||
|
re2 := regexp.MustCompile(`mul\(\d+,\d+\)`)
|
||||||
|
matches2 := re2.FindAllString(oneclean, -1)
|
||||||
|
for i := 0; i < len(matches2); i++ {
|
||||||
|
p2 += calculate(matches2[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("p1: ", p1)
|
||||||
|
fmt.Println("p2: ", p2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() ([]string, error) {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
return nil, fmt.Errorf("no file provided")
|
||||||
|
}
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error opening file: %v", err)
|
||||||
|
}
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
var nonEmpthyChunks = []string{}
|
||||||
|
|
||||||
|
for _, chunk := range chunks {
|
||||||
|
if chunk != "" {
|
||||||
|
nonEmpthyChunks = append(nonEmpthyChunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nonEmpthyChunks, nil
|
||||||
|
}
|
||||||
3
2024/04/go.mod
Normal file
3
2024/04/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.23.3
|
||||||
126
2024/04/main.go
Normal file
126
2024/04/main.go
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines, err := parse()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var p1 int = 0
|
||||||
|
var p2 int = 0
|
||||||
|
|
||||||
|
h := len(lines)
|
||||||
|
w := len(lines[0])
|
||||||
|
|
||||||
|
for y := 0; y < h; y++ {
|
||||||
|
for x := 0; x < w; x++ {
|
||||||
|
|
||||||
|
if lines[y][x] == 'X' {
|
||||||
|
// check right
|
||||||
|
if x <= len(lines[y])-4 {
|
||||||
|
r := string([]byte{lines[y][x+1], lines[y][x+2], lines[y][x+3]})
|
||||||
|
if r == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check left
|
||||||
|
if x >= 3 {
|
||||||
|
l := string([]byte{lines[y][x-1], lines[y][x-2], lines[y][x-3]})
|
||||||
|
if l == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if up possible
|
||||||
|
if y >= 3 {
|
||||||
|
u := string([]byte{lines[y-1][x], lines[y-2][x], lines[y-3][x]})
|
||||||
|
if u == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
if x >= 3 {
|
||||||
|
ul := string([]byte{lines[y-1][x-1], lines[y-2][x-2], lines[y-3][x-3]})
|
||||||
|
if ul == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if x < w-3 {
|
||||||
|
ur := string([]byte{lines[y-1][x+1], lines[y-2][x+2], lines[y-3][x+3]})
|
||||||
|
if ur == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// check down
|
||||||
|
if y <= h-4 {
|
||||||
|
d := string([]byte{lines[y+1][x], lines[y+2][x], lines[y+3][x]})
|
||||||
|
if d == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
if x >= 3 {
|
||||||
|
dl := string([]byte{lines[y+1][x-1], lines[y+2][x-2], lines[y+3][x-3]})
|
||||||
|
if dl == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if x < w-3 {
|
||||||
|
dr := string([]byte{lines[y+1][x+1], lines[y+2][x+2], lines[y+3][x+3]})
|
||||||
|
if dr == "MAS" {
|
||||||
|
p1++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if lines[y][x] == 'A' {
|
||||||
|
if y >= 1 && y < h-1 && x >= 1 && x < w-1 {
|
||||||
|
check := string([]byte{lines[y-1][x-1], lines[y-1][x+1], lines[y+1][x-1], lines[y+1][x+1]})
|
||||||
|
if check == "MSMS" {
|
||||||
|
p2++
|
||||||
|
}
|
||||||
|
if check == "SMSM" {
|
||||||
|
p2++
|
||||||
|
}
|
||||||
|
if check == "MMSS" {
|
||||||
|
p2++
|
||||||
|
}
|
||||||
|
if check == "SSMM" {
|
||||||
|
p2++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("p1: ", p1)
|
||||||
|
fmt.Println("p2: ", p2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() ([]string, error) {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
return nil, fmt.Errorf("no file provided")
|
||||||
|
}
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error opening file: %v", err)
|
||||||
|
}
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
var nonEmpthyChunks = []string{}
|
||||||
|
|
||||||
|
for _, chunk := range chunks {
|
||||||
|
if chunk != "" {
|
||||||
|
nonEmpthyChunks = append(nonEmpthyChunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nonEmpthyChunks, nil
|
||||||
|
}
|
||||||
3
2024/05/go.mod
Normal file
3
2024/05/go.mod
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
go 1.23.3
|
||||||
102
2024/05/main.go
Normal file
102
2024/05/main.go
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func contains(s []int, e int) bool {
|
||||||
|
for _, a := range s {
|
||||||
|
if a == e {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func check(nums []int, maps map[int][]int) bool {
|
||||||
|
correct := true
|
||||||
|
for i := 0; i < len(nums); i++ {
|
||||||
|
var checking = nums[i]
|
||||||
|
for j := 0; j < len(nums); j++ {
|
||||||
|
|
||||||
|
if !contains(maps[checking], nums[j]) {
|
||||||
|
if i < j {
|
||||||
|
correct = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return correct
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines, err := parse()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var p1 int = 0
|
||||||
|
var p2 int = 0
|
||||||
|
|
||||||
|
maps := make(map[int][]int)
|
||||||
|
|
||||||
|
for y := 0; y < len(lines); y++ {
|
||||||
|
if lines[y] != "" && lines[y][2] == '|' {
|
||||||
|
split := strings.Split(lines[y], "|")
|
||||||
|
l, err := strconv.Atoi(split[0])
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
r, err := strconv.Atoi(split[1])
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
maps[l] = append(maps[l], r)
|
||||||
|
}
|
||||||
|
|
||||||
|
if lines[y] != "" && lines[y][2] == ',' {
|
||||||
|
numsstr := strings.Split(lines[y], ",")
|
||||||
|
var nums []int
|
||||||
|
|
||||||
|
for i := 0; i < len(numsstr); i++ {
|
||||||
|
x, err := strconv.Atoi(numsstr[i])
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
nums = append(nums, x)
|
||||||
|
}
|
||||||
|
|
||||||
|
if check(nums, maps) {
|
||||||
|
p1 += nums[len(nums)/2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("p1: ", p1)
|
||||||
|
fmt.Println("p2: ", p2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() ([]string, error) {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
return nil, fmt.Errorf("no file provided")
|
||||||
|
}
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, err := os.ReadFile(filePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error opening file: %v", err)
|
||||||
|
}
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
var nonEmpthyChunks = []string{}
|
||||||
|
|
||||||
|
for _, chunk := range chunks {
|
||||||
|
if chunk != "" {
|
||||||
|
nonEmpthyChunks = append(nonEmpthyChunks, chunk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nonEmpthyChunks, nil
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
# Advent of Code 2022
|
# Advent of Code
|
||||||
|
|
||||||
https://adventofcode.com/
|
https://adventofcode.com/
|
||||||
|
|||||||
24
testing/test.go
Normal file
24
testing/test.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
|
||||||
|
lines := parse()
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
fmt.Println(line)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func parse() []string {
|
||||||
|
filePath := os.Args[1]
|
||||||
|
data, _ := os.ReadFile(filePath)
|
||||||
|
chunks := strings.Split(string(data), "\n")
|
||||||
|
return chunks
|
||||||
|
}
|
||||||
4
testing/test.txt
Normal file
4
testing/test.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
3425 423
|
||||||
9
utils/getpuzzle.sh
Executable file
9
utils/getpuzzle.sh
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source "$(dirname "$0")/../.env"
|
||||||
|
|
||||||
|
year=$1
|
||||||
|
day=$2
|
||||||
|
|
||||||
|
echo "Getting input for $year day $day"
|
||||||
|
|
||||||
|
curl -s -S --cookie "$COOKIE" --output ./input.txt https://adventofcode.com/$year/day/$day/input
|
||||||
Reference in New Issue
Block a user