Day 5
This commit is contained in:
24
day05/ex1/main.go
Normal file
24
day05/ex1/main.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"aoc2022/day05/common"
|
||||
)
|
||||
|
||||
func main() {
|
||||
stacks, movements := common.Parse(*bufio.NewScanner(os.Stdin))
|
||||
|
||||
for _, movement := range(movements) {
|
||||
for i := 0; i < movement.GetN(); i++ {
|
||||
top := stacks[movement.GetStart() - 1].Pop()
|
||||
stacks[movement.GetEnd() - 1].Push(top)
|
||||
}
|
||||
}
|
||||
|
||||
for _, stack := range(stacks) {
|
||||
fmt.Print(string(stack.Peek()))
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
Reference in New Issue
Block a user