day 13 setup (incomplete)

Sorry, literally have no energy! Will attempt tomorrow
This commit is contained in:
Luke Else 2021-12-13 20:53:55 +00:00
parent 32e42d1f51
commit 5031559529
7 changed files with 138 additions and 0 deletions

3
day13/day 13a/go.mod Normal file
View File

@ -0,0 +1,3 @@
module PWD
go 1.17

40
day13/day 13a/main.go Normal file
View File

@ -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
}

21
day13/day 13a/testInput Normal file
View File

@ -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

3
day13/day 13b/go.mod Normal file
View File

@ -0,0 +1,3 @@
module PWD
go 1.17

40
day13/day 13b/main.go Normal file
View File

@ -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
}

21
day13/day 13b/testInput Normal file
View File

@ -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

10
day13/input Normal file
View File

@ -0,0 +1,10 @@
5421451741
3877321568
7583273864
3451717778
2651615156
6377167526
5182852831
4766856676
3437187583
3633371586