From 50315595295176fd79b0a236f7446dd7c7d6acc2 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Mon, 13 Dec 2021 20:53:55 +0000 Subject: [PATCH] day 13 setup (incomplete) Sorry, literally have no energy! Will attempt tomorrow --- day13/day 13a/go.mod | 3 +++ day13/day 13a/main.go | 40 ++++++++++++++++++++++++++++++++++++++++ day13/day 13a/testInput | 21 +++++++++++++++++++++ day13/day 13b/go.mod | 3 +++ day13/day 13b/main.go | 40 ++++++++++++++++++++++++++++++++++++++++ day13/day 13b/testInput | 21 +++++++++++++++++++++ day13/input | 10 ++++++++++ 7 files changed, 138 insertions(+) create mode 100644 day13/day 13a/go.mod create mode 100644 day13/day 13a/main.go create mode 100644 day13/day 13a/testInput create mode 100644 day13/day 13b/go.mod create mode 100644 day13/day 13b/main.go create mode 100644 day13/day 13b/testInput create mode 100644 day13/input diff --git a/day13/day 13a/go.mod b/day13/day 13a/go.mod new file mode 100644 index 0000000..e938e2e --- /dev/null +++ b/day13/day 13a/go.mod @@ -0,0 +1,3 @@ +module PWD + +go 1.17 diff --git a/day13/day 13a/main.go b/day13/day 13a/main.go new file mode 100644 index 0000000..2c4f028 --- /dev/null +++ b/day13/day 13a/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" +) + +func main() { + content := returnContent("../input") + //content := returnContent("testInput") + +} + +func returnContent(path string) *[][]int { + //read file and return it as an array of integers + + file, err := os.Open(path) + var content [][]int + + if err != nil { + fmt.Println("Unlucky, the file didn't open") + return &content + } + defer file.Close() + + scanner := bufio.NewScanner(file) + + for scanner.Scan() { + nums := []int{} + for _, char := range scanner.Text() { + num, _ := strconv.Atoi(string(char)) + nums = append(nums, num) + } + content = append(content, nums) + } + + return &content +} diff --git a/day13/day 13a/testInput b/day13/day 13a/testInput new file mode 100644 index 0000000..32a8563 --- /dev/null +++ b/day13/day 13a/testInput @@ -0,0 +1,21 @@ +6,10 +0,14 +9,10 +0,3 +10,4 +4,11 +6,0 +6,12 +4,1 +0,13 +10,12 +3,4 +3,0 +8,4 +1,10 +2,14 +8,10 +9,0 + +fold along y=7 +fold along x=5 \ No newline at end of file diff --git a/day13/day 13b/go.mod b/day13/day 13b/go.mod new file mode 100644 index 0000000..e938e2e --- /dev/null +++ b/day13/day 13b/go.mod @@ -0,0 +1,3 @@ +module PWD + +go 1.17 diff --git a/day13/day 13b/main.go b/day13/day 13b/main.go new file mode 100644 index 0000000..2c4f028 --- /dev/null +++ b/day13/day 13b/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strconv" +) + +func main() { + content := returnContent("../input") + //content := returnContent("testInput") + +} + +func returnContent(path string) *[][]int { + //read file and return it as an array of integers + + file, err := os.Open(path) + var content [][]int + + if err != nil { + fmt.Println("Unlucky, the file didn't open") + return &content + } + defer file.Close() + + scanner := bufio.NewScanner(file) + + for scanner.Scan() { + nums := []int{} + for _, char := range scanner.Text() { + num, _ := strconv.Atoi(string(char)) + nums = append(nums, num) + } + content = append(content, nums) + } + + return &content +} diff --git a/day13/day 13b/testInput b/day13/day 13b/testInput new file mode 100644 index 0000000..32a8563 --- /dev/null +++ b/day13/day 13b/testInput @@ -0,0 +1,21 @@ +6,10 +0,14 +9,10 +0,3 +10,4 +4,11 +6,0 +6,12 +4,1 +0,13 +10,12 +3,4 +3,0 +8,4 +1,10 +2,14 +8,10 +9,0 + +fold along y=7 +fold along x=5 \ No newline at end of file diff --git a/day13/input b/day13/input new file mode 100644 index 0000000..67b8a5a --- /dev/null +++ b/day13/input @@ -0,0 +1,10 @@ +5421451741 +3877321568 +7583273864 +3451717778 +2651615156 +6377167526 +5182852831 +4766856676 +3437187583 +3633371586 \ No newline at end of file