From cc58326f8c88ae3c96ec8f0a4a9966493ecf5424 Mon Sep 17 00:00:00 2001 From: RhiobeT Date: Thu, 15 Dec 2022 14:56:28 +0100 Subject: [PATCH] Fix tabs --- day04/common/section.go | 6 +++--- day05/common/crane.go | 6 +++--- day06/common/signal.go | 2 +- day07/common/filesystem.go | 6 +++--- day08/common/forest.go | 2 +- day10/ex2/main.go | 8 +++---- day11/common/monkey.go | 6 +++--- day11/ex1/main.go | 10 ++++----- day11/ex2/main.go | 10 ++++----- day12/common/heightmap.go | 4 ++-- day12/ex1/main.go | 8 +++---- day12/ex2/main.go | 8 +++---- day13/ex1/main.go | 20 ++++++++--------- day13/ex2/main.go | 28 ++++++++++++------------ day14/common/sand.go | 30 +++++++++++++------------- day14/ex1/main.go | 18 ++++++++-------- day14/ex2/main.go | 22 +++++++++---------- day15/common/beacon.go | 34 ++++++++++++++--------------- day15/ex1/main.go | 18 ++++++++-------- day15/ex2/main.go | 44 +++++++++++++++++++------------------- 20 files changed, 145 insertions(+), 145 deletions(-) diff --git a/day04/common/section.go b/day04/common/section.go index 796a8c1..125a4c4 100644 --- a/day04/common/section.go +++ b/day04/common/section.go @@ -1,9 +1,9 @@ package common import ( - "bufio" - "strconv" - "strings" + "bufio" + "strconv" + "strings" ) type Assignment struct { diff --git a/day05/common/crane.go b/day05/common/crane.go index 6b78482..03ca7ae 100644 --- a/day05/common/crane.go +++ b/day05/common/crane.go @@ -1,9 +1,9 @@ package common import ( - "bufio" - "strconv" - "strings" + "bufio" + "strconv" + "strings" ) type Stack []byte diff --git a/day06/common/signal.go b/day06/common/signal.go index 80801f7..2bdd66b 100644 --- a/day06/common/signal.go +++ b/day06/common/signal.go @@ -1,7 +1,7 @@ package common import ( - "bufio" + "bufio" ) type Signal string diff --git a/day07/common/filesystem.go b/day07/common/filesystem.go index e61fa44..fb09139 100644 --- a/day07/common/filesystem.go +++ b/day07/common/filesystem.go @@ -1,9 +1,9 @@ package common import ( - "bufio" - "strconv" - "strings" + "bufio" + "strconv" + "strings" ) type FileBase interface { diff --git a/day08/common/forest.go b/day08/common/forest.go index bf4f42d..a8b70ee 100644 --- a/day08/common/forest.go +++ b/day08/common/forest.go @@ -1,7 +1,7 @@ package common import ( - "bufio" + "bufio" ) type Tree int diff --git a/day10/ex2/main.go b/day10/ex2/main.go index 4282fb2..7674e37 100644 --- a/day10/ex2/main.go +++ b/day10/ex2/main.go @@ -1,10 +1,10 @@ package main import ( - "aoc2022/day10/common" - "bufio" - "fmt" - "os" + "aoc2022/day10/common" + "bufio" + "fmt" + "os" ) func main() { diff --git a/day11/common/monkey.go b/day11/common/monkey.go index 60a46d3..101395b 100644 --- a/day11/common/monkey.go +++ b/day11/common/monkey.go @@ -1,9 +1,9 @@ package common import ( - "bufio" - "strconv" - "strings" + "bufio" + "strconv" + "strings" ) diff --git a/day11/ex1/main.go b/day11/ex1/main.go index 134956a..e95fcdd 100644 --- a/day11/ex1/main.go +++ b/day11/ex1/main.go @@ -1,11 +1,11 @@ package main import ( - "aoc2022/day11/common" - "bufio" - "fmt" - "os" - "sort" + "aoc2022/day11/common" + "bufio" + "fmt" + "os" + "sort" ) func main() { diff --git a/day11/ex2/main.go b/day11/ex2/main.go index 455ddd3..68c3fe5 100644 --- a/day11/ex2/main.go +++ b/day11/ex2/main.go @@ -1,11 +1,11 @@ package main import ( - "aoc2022/day11/common" - "bufio" - "fmt" - "os" - "sort" + "aoc2022/day11/common" + "bufio" + "fmt" + "os" + "sort" ) func main() { diff --git a/day12/common/heightmap.go b/day12/common/heightmap.go index d6d22e2..961fd98 100644 --- a/day12/common/heightmap.go +++ b/day12/common/heightmap.go @@ -1,8 +1,8 @@ package common import ( - "bufio" - "math" + "bufio" + "math" ) diff --git a/day12/ex1/main.go b/day12/ex1/main.go index e26e34e..accc98f 100644 --- a/day12/ex1/main.go +++ b/day12/ex1/main.go @@ -1,10 +1,10 @@ package main import ( - "aoc2022/day12/common" - "bufio" - "fmt" - "os" + "aoc2022/day12/common" + "bufio" + "fmt" + "os" ) func main() { diff --git a/day12/ex2/main.go b/day12/ex2/main.go index 69c354f..7c354bc 100644 --- a/day12/ex2/main.go +++ b/day12/ex2/main.go @@ -1,10 +1,10 @@ package main import ( - "aoc2022/day12/common" - "bufio" - "fmt" - "os" + "aoc2022/day12/common" + "bufio" + "fmt" + "os" ) func main() { diff --git a/day13/ex1/main.go b/day13/ex1/main.go index 62ceb72..755223b 100644 --- a/day13/ex1/main.go +++ b/day13/ex1/main.go @@ -1,21 +1,21 @@ package main import ( - "aoc2022/day13/common" - "bufio" - "fmt" - "os" + "aoc2022/day13/common" + "bufio" + "fmt" + "os" ) func main() { pairs := common.ParsePairs(*bufio.NewScanner(os.Stdin)) - sum := 0 + sum := 0 - for i, pair := range pairs { - if pair.CheckOrder() { - sum += (i + 1) - } - } + for i, pair := range pairs { + if pair.CheckOrder() { + sum += (i + 1) + } + } fmt.Println(sum) } diff --git a/day13/ex2/main.go b/day13/ex2/main.go index 8b2f9c8..88df0af 100644 --- a/day13/ex2/main.go +++ b/day13/ex2/main.go @@ -1,26 +1,26 @@ package main import ( - "aoc2022/day13/common" - "bufio" - "fmt" - "os" - "sort" + "aoc2022/day13/common" + "bufio" + "fmt" + "os" + "sort" ) func main() { packets := common.ParsePackets(*bufio.NewScanner(os.Stdin), []string{"[[2]]", "[[6]]"}) - sort.Slice(packets, func(i int, j int) bool { - return packets[i].Compare(packets[j]) < 0 - }) + sort.Slice(packets, func(i int, j int) bool { + return packets[i].Compare(packets[j]) < 0 + }) - result := 1 - for i := 0; i < len(packets); i++ { - if packets[i].IsSeparator() { - result *= (i+1) - } - } + result := 1 + for i := 0; i < len(packets); i++ { + if packets[i].IsSeparator() { + result *= (i+1) + } + } fmt.Println(result) } diff --git a/day14/common/sand.go b/day14/common/sand.go index 466aba0..b9a9160 100644 --- a/day14/common/sand.go +++ b/day14/common/sand.go @@ -78,8 +78,8 @@ func (tileMap *Map) DropSand() bool { func (tileMap *Map) AddFloor() { currFloor := 0 - for i := 0; i < len(*tileMap); i++ { - for j := 0; j < len((*tileMap)[i]); j++ { + for i := 0; i < len(*tileMap); i++ { + for j := 0; j < len((*tileMap)[i]); j++ { if (*tileMap)[i][j] == Rock && i > currFloor { currFloor = i } @@ -97,19 +97,19 @@ func (tileMap *Map) IsSourceBlocked() bool { } func (tileMap *Map) Print(xMin, xMax, yMin, yMax int) { - for i := yMin; i <= yMax; i++ { - for j := xMin; j <= xMax; j++ { - switch (*tileMap)[i][j] { - case Air: - fmt.Print(".") - case Rock: - fmt.Print("#") - case Sand: - fmt.Print("o") - } - } - fmt.Println() - } + for i := yMin; i <= yMax; i++ { + for j := xMin; j <= xMax; j++ { + switch (*tileMap)[i][j] { + case Air: + fmt.Print(".") + case Rock: + fmt.Print("#") + case Sand: + fmt.Print("o") + } + } + fmt.Println() + } } type RockStructure struct { diff --git a/day14/ex1/main.go b/day14/ex1/main.go index 961202b..18cfd54 100644 --- a/day14/ex1/main.go +++ b/day14/ex1/main.go @@ -9,16 +9,16 @@ import ( func main() { rockStructures := common.Parse(*bufio.NewScanner(os.Stdin)) - tileMap := common.NewMap() + tileMap := common.NewMap() - for _, rockStructure := range rockStructures { - tileMap.AddRockStructure(rockStructure) - } + for _, rockStructure := range rockStructures { + tileMap.AddRockStructure(rockStructure) + } - units := 0 - for tileMap.DropSand() { - units++ - } + units := 0 + for tileMap.DropSand() { + units++ + } - fmt.Println(units) + fmt.Println(units) } diff --git a/day14/ex2/main.go b/day14/ex2/main.go index 92b6219..f1d26f6 100644 --- a/day14/ex2/main.go +++ b/day14/ex2/main.go @@ -9,18 +9,18 @@ import ( func main() { rockStructures := common.Parse(*bufio.NewScanner(os.Stdin)) - tileMap := common.NewMap() + tileMap := common.NewMap() - for _, rockStructure := range rockStructures { - tileMap.AddRockStructure(rockStructure) - } - tileMap.AddFloor() + for _, rockStructure := range rockStructures { + tileMap.AddRockStructure(rockStructure) + } + tileMap.AddFloor() - units := 0 - for !tileMap.IsSourceBlocked() { - tileMap.DropSand() - units++ - } + units := 0 + for !tileMap.IsSourceBlocked() { + tileMap.DropSand() + units++ + } - fmt.Println(units) + fmt.Println(units) } diff --git a/day15/common/beacon.go b/day15/common/beacon.go index 9545b4d..b0db6cf 100644 --- a/day15/common/beacon.go +++ b/day15/common/beacon.go @@ -1,10 +1,10 @@ package common import ( - "bufio" - "fmt" - "strconv" - "strings" + "bufio" + "fmt" + "strconv" + "strings" ) @@ -185,21 +185,21 @@ func (tileMap *Map) GetCoverageYInXInterval(xMin, xMax, y int) int { } func (tileMap *Map) Print(xMin, xMax, yMin, yMax int) { - for i := yMin; i <= yMax; i++ { - for j := xMin; j <= xMax; j++ { - switch tileMap.GetTile(j, i) { - case Beacon: - fmt.Print("B") - case Sensor: - fmt.Print("S") - case Covered: - fmt.Print("#") + for i := yMin; i <= yMax; i++ { + for j := xMin; j <= xMax; j++ { + switch tileMap.GetTile(j, i) { + case Beacon: + fmt.Print("B") + case Sensor: + fmt.Print("S") + case Covered: + fmt.Print("#") case Free: fmt.Print(".") - } - } - fmt.Println() - } + } + } + fmt.Println() + } } diff --git a/day15/ex1/main.go b/day15/ex1/main.go index 60bafb1..f405497 100644 --- a/day15/ex1/main.go +++ b/day15/ex1/main.go @@ -1,19 +1,19 @@ package main import ( - "aoc2022/day15/common" - "bufio" - "fmt" - "os" + "aoc2022/day15/common" + "bufio" + "fmt" + "os" ) func main() { sensors := common.Parse(*bufio.NewScanner(os.Stdin)) - tileMap := common.NewMap() + tileMap := common.NewMap() - for _, sensor := range sensors { - tileMap.SetSensor(sensor) - } + for _, sensor := range sensors { + tileMap.SetSensor(sensor) + } - fmt.Println(tileMap.GetCoverageY(2000000)) + fmt.Println(tileMap.GetCoverageY(2000000)) } diff --git a/day15/ex2/main.go b/day15/ex2/main.go index b9e9055..ffa4620 100644 --- a/day15/ex2/main.go +++ b/day15/ex2/main.go @@ -1,33 +1,33 @@ package main import ( - "aoc2022/day15/common" - "bufio" - "fmt" - "os" + "aoc2022/day15/common" + "bufio" + "fmt" + "os" ) func main() { sensors := common.Parse(*bufio.NewScanner(os.Stdin)) - tileMap := common.NewMap() + tileMap := common.NewMap() - for _, sensor := range sensors { - tileMap.SetSensor(sensor) - } + for _, sensor := range sensors { + tileMap.SetSensor(sensor) + } - var frequency int - found := false - for i := 0; i <= 4000000 && !found; i++ { - coverage := tileMap.GetCoverageYInXInterval(0, 4000000, i) - if coverage <= 4000000 { - for j := 0; j < 4000000 && !found; j++ { - if tileMap.GetTile(j, i) == common.Free { - frequency = j * 4000000 + i - found = true - } - } - } - } + var frequency int + found := false + for i := 0; i <= 4000000 && !found; i++ { + coverage := tileMap.GetCoverageYInXInterval(0, 4000000, i) + if coverage <= 4000000 { + for j := 0; j < 4000000 && !found; j++ { + if tileMap.GetTile(j, i) == common.Free { + frequency = j * 4000000 + i + found = true + } + } + } + } - fmt.Println(frequency) + fmt.Println(frequency) }