Fix tabs
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user