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