commit 2453331dde52f6afed6cb4d9512de39b7b3196af
parent 5d1f81a28d79bf586f3d77cc74e14cd081701260
Author: bsandro <email@bsandro.tech>
Date: Sat, 17 Dec 2022 18:11:15 +0000
Day 17 part 1
Diffstat:
3 files changed, 226 insertions(+), 0 deletions(-)
diff --git a/day17/input.txt b/day17/input.txt
@@ -0,0 +1 @@
+><<<<>>>><>>><<><<<<>>>><<>>><>>><<<<>>>><<>>>><<<>>>><<<>>>><<<>>><<<<>><>><<<<>>><><<<><><>>>><<<<><<<<>><<<>>>><<>><><>>>><<<>>><<<>>><<>>>><>>>><>><>>><<>><><<<<><>><<<>>>><<<>>><<<>><>><<<>>><<<<>>>><><<<>>><<<>>><<<<><<<<>>><<<<>>><<<>>><<<<>>><<>>><<><<<>><<<>>><<<<><<<<>>><<<><<>>>><<<>><>>><<>>><<<><<<<>>><<><<<<>>>><<>>>><<>>>><<<<>>><><<<<><>><<<>>>><<<<>><>>>><>><>><>><<<>><<<>>>><<<>><<>><<<<><<<<><<>>>><<<<><<<>>><>><<<>>><<<><<<><<<<><<><<<>>><<<<>>>><<<<><<>><<<<>>><>>><<<<><<<>>>><<><>><<<<>><<<<>>>><<<><<<<><<<<>>><<<><<>>><>>><<<<>>><<>><<<<>>><<<><<<>><<<<>>>><<<<><<><<<<>>>><>>>><<<<>>>><<<>>>><<<><<>>><>>><<<<>><<<<>>><><>><<<>>>><<<<>><<<>><<>><<<>>><<<>>>><<<<>>>><<>>>><<>>>><><<<<>><<<<>>>><<<<>>><<<<>><>><<<>>><>>>><><<>><<>>><<<>>>><>>><<>><<<>><>>><>>><><>><>><<<><<<>>>><>><<<><<<>>><<<<><<>>>><<<><<<>>>><>><<<>>>><<<>>>><>>><><>>>><>><<><<<>>>><<>>>><<<>>><<<<>>><<<>><>>>><<<<>>>><>><<>>><<<<>>>><<<<><>>>><<>><<>>>><>><<<<>>>><<<<>><<<>>>><<>><><>><<<<>><<<>>>><<<>>><<>><><<<>>>><<>><>><<>><>><<<<>><<<>>><<<<>>><<>>>><<>>><<<<>>><>><<><<<>><>>><<<>><<<<>>>><<<>>><<>>><<<>>><<<<>>>><<<<>>><<<>>><<>>>><<>>><<<>>><<><<>>>><<>>>><<><<>>><<><<<>>>><<<<><<<<>><<<>>>><>>><<<<>>><<<<>>>><<>><<<<>>>><<<><<<><<>>>><<<>>>><<<>>>><<<>><<>>><>>><<<<>>><<<<>><<<>>><<<>><<<<>>><<<<><<><>>><<<<>>><<<<>>>><>><<<<>><<<<>>>><<<<><<<>>>><>><<<<><<<<>>>><>><<><<<>>><<>>><<<<>><<<><<<><>><<>>>><<<><<<<><<<>>>><<<<>><<>><<<<>>>><><<<><<<>>>><<>>>><<>><<<<>>>><><><<<<><><<>>><<><<>>><>>><<>><><<><<>>>><<<<><<<>>>><<>><><<>>>><<<<><><<<>>>><<>>><<<><<<>>>><>><<<<>>>><>>><<><>>>><>>>><<<><>>><>>>><<<>><<<>>><<<<>>>><<>>>><<<<>>>><<><>><<<<>><<<<>>><<>>><>>>><<><<>>><>>>><<><<><<><><<<>><>><<<<>>><<<>>>><<<><<<<>><>><>>><<<<><<<>>>><<<>>><><<<<>>><<<<><<<<>>>><>><>>><<<><<>><<<><>>><<<<>><><<<<><>><<>><<>><>><<<<><<<>><>>>><<>><<<<>>><><<<>><<>><<>><>>><>>>><<><>><<<<>>><>>><<>>><<>>>><<>><<<<>>><>><<<>>><<<>>><<<<>>>><<<><<<<>><<><<<><<<>>><<><<>><>><>>><<<>>><<>><<>>><<>><<>><>><<<<>>>><<<<>>><<<>>>><<<<>>><<<>><<<>><<<<>>>><<>><<<<><<<<>><<>>><><<><<<<>>>><><>>>><<<<>>>><<<<>>>><<>><<<<>>>><<<><>><<>>>><<>>>><<<<>>>><<<>>><>><<>>>><<<>>>><<<<>>><<<<>><<<<>>>><<>>><<>>>><>>><>>>><><>><<<<>>>><<<>>>><<<>><<>>><<<<>>><>>>><<>>>><<<><>>><><<>>>><<>>>><<<>>>><<<<><<<<>>>><>>>><>><<<>>><<<>>>><<<>><<<>>><>><<>>><<><><<><<>>>><>>><<<<>><><>><>>><<<<><>>><<<>>><<<><<<<>>><<<>><<<>>><<>>><<<<><<<<><>><><<<<>>><<<>><<>><<<>><<<<>><>><>>>><<>>><<<>><<<>><<<<>><><<<<>>><<<>>>><<<<>>><<>><>><<>>><><<>>><<<>>><<<>><<>>>><<<<>><<<<>>>><<<><<><<<<>><<<<>><<<>>>><>><<<><>>>><<>>>><<><<<>>>><<<<>><<<>>>><<>>><>><<<<>>>><<<<>>><>>>><<<<><<><<>><>><>>><<<><<<<><<<<>><<<>>><<<<>><<><<<<>>>><<<>>>><<<>>>><<<<>>><<><<>><<><<<<>>>><<<><<<<>>>><<>>><<<<>><>>>><<<<>><<<>>>><<><<<<>>>><<<>><>>>><><<<>><<<><<<>>><>>>><>>><<<<><<<<>>><<>>><<<>>><<<<><<<<>>>><<>>><<<>><<>>><><<<>>>><<><>>><<>><<<>>>><<<><>><<<>>><<>>>><<<>>>><>><<><>><<>>>><<<>>>><<<<>>>><<<>>><<<>><<<<><<<<>><><<><<<>><>>><<<<>>><<<<>><<<>>><<>><<<<><<<><<<><<<>>><<<<>>><<<<>><<>>><<>><<<<>>>><<>>>><<>>>><<>><>>><>>>><<>>>><<<>>><<<<>>><>>><>>>><<<>><<>>><<>>>><<>>>><<<>>><<>>><<<><<<>><>>>><<<>><>>><<<>>><>>>><>><<>>><<<<>>><<<<>><>>><<<<>>><<<<><<<>>><><>>><<<>>><>><>>>><<>>>><<<>><<>>><<>><<<<>><<<<><>>><<>><<<<>>><<<>>><<>>>><>>>><<<><>>>><<><><>>><<>>>><<<>>>><><>><<<<>><<<>>>><<<<><<<<>>>><<<<>><>>>><<<>>>><<><<>>>><<<<>>>><<<<>>><>><>>>><>>>><>><<>>>><>>>><<>>><<<<>>>><<>>><><<>>>><<>><<<<><<><>>>><<<<>><<><<><<>><<<><<<>><<<<>>><<<<>><<>><>>><<<<>>>><<<<>>>><<<<>>><><<<<><<<<><><<<<><<<<>>>><<<<>>>><><>>><<<<><<<<><<<><><<<<>><><<<><<<<>><>>><><><<<><>>><<><<>><<<>><<<>>>><<<<>>><<>><<<<><>>><>>><<>>>><<<<>>><<<>>>><<<>>>><<<>><<<>><<<<>>><<<<>><>>><<<<><>>>><<<>><>>><<>>><<<<>><<><<<>><>>><<<>><<<<>>><<<>>>><>>><><<<><<<>>>><<>>><<><>>>><>>>><<<<>>><><><>>>><<<<>><<<<>>><<>>><<<><<<>>>><<><<<>><<<>>>><<<<>>>><>>><<<>>><><<<>><<<<>><<<>>>><>><<><><<>><<<>><<<>>><<<<>>>><<<><<<<>><<<<>>>><<<<>>>><<><<<<>>><<<<>><<<<>><<<>><<<<>>><<>>>><<>>><>><<>>>><>>><>>><<<><>>>><<<>>><<<<><<<<>>><<><><>>>><<>>>><<>>>><<<<>>>><<><<><<<>>><<<>>>><<><<<><<>>><<<><<<>>>><<<<>>><<>>>><<>><><<<><<>><<>>><<<<>><>><<<>><<<<>><<<<><<>>><<><<<<>>>><<<>><<<<>><<>>>><>>>><>>><>>>><<<>>><<<>>>><<>>>><>><>><<<>><<<>>><<>>><<<<>>><<<<>>><<>>>><>>><>><<<<>>>><<>>>><<>>>><<<<>>>><>>>><><>>><<>>>><<<<><<>>>><<<<>><<<<>>>><<>><<<<><<<<>>><<<<>><<>>>><<<>>>><<<><>><<<><<>>><<<<>><<<>>><><<<<>><<<<>><>>><<<<>>><<<<>>>><>>>><<>>>><<>>><>>>><<<<>>><<>><<<><<><<<>>>><<<>>>><<<<><<>>><>><<<<><<<>>><>><><<<><<>>>><>>>><>><<>>><<>>>><<>>>><<<<>><<>><><<>>><<>><<>><<>>><>><<<<>>>><<>>>><<<<>>><<>><><<<><>><<<>><>>><>><<>>><><>>><<>>>><<<>>><<<<>>><<<>><<>><<<<>>><<<><<<>><<<<><<>><>><<<<>><<>>>><<<>><<<>>>><<<<>>>><<<<>><<>>><<<>>><<<>>>><<<<>>><<<<>>>><>><<<<>>>><<>>><><<>>>><<<<>>>><<<<>>>><>><<>><<<<><<<<>>><><>>><<<<>>><<><>>>><<<<><<<>>>><>>>><<<>>>><<<>>>><<>>><<>>><<<<><<<>><>>><<<><<<>>><>><>><<>>><<<>>>><<><>>><><<>>><<<<>>>><>><>>><>><<>>><<<><<><<>>><<>>>><<>>>><<>>><<<>><<<<><<<><<<<>><<>><>>>><<>><>><<<>>>><<>>>><<><<<<>><>><>><>>>><>>>><<<>>><<>><>>>><<<<>><<>>>><<<<>>><<<>>>><<><<<>><<<<><<>>><<>>><<>>>><<>><>>><>>><<<>>><>>>><<><<><<<>><<><<<><<<>><<<<>>>><>>><<<>>>><<<>><<<<><<>>>><>><>><<<<>>><<<>>><><>>><>>><<<>>><<<<>>>><>>>><<<><>><<>><<<>>><>><><<<>>>><><>>>><<<><<<>><<<>>><<>>>><<<<><<<>>><>>>><<<<>><<<<>>>><<<>>><<<>><<<>><<<<>>><<<><<>><<<<>><<>><<><<<<>>>><<><<>>><<<<><<<<>>><<>>><<<>>><<><<<>>>><<<<>>>><>>><<><<>><<<>><<<>>><<<<>>>><>><<<<>><<<<>>><>>>><<<<>><<>>>><>>>><<<>><<<>>>><<<>>>><<>><<<<>><<<<><>>><<>>>><<><<<><<><<<<>>><<<<>><<>>><><>>><<<<>><<<<>>><<<>><><<<>><<<><><<><><<>>><><<<<>><<>>><<><<<>>><>>>><><<<<>>>><<<><><<>>>><<<>><<<>><<<<>><<>>>><<<<><<<<>>><>>><<><<<<><<<<>>><<>>><>><<<<>>>><<><<<>>>><>>>><<>>><>><<<<><>>>><<><<><>><<<<><<<><<<><<<><><<>>><<>>><<>>>><<>>>><<<<>><<<>>>><<<>>>><<<>><<>>><<<<><<<<><<><<<<><<<>>><<>><<>>>><<>>><>>><><><>><><<>>><<><<<<><<<<>>>><<<><<>>>><<><<<>><<<<>>><<<<><<>><>><<<>>><<<>>>><<<>>><<<<>>><<<>>><><<<>>><<<>><<<>><>>>><<<>><<>>>><<>>><><<><><><<<><<<>><><<<>>>><>><<>>><<>>><<<<>><>><>><<<<>><>>><><<<>>><>><<<<>>><>>><>>><<>>>><<<<><>><<<>>><<><<<><<<>><>>><<>>>><<>><<<><<<><<<<>>><<<<>>>><<>>>><<>><<>>><>>>><<>>><<<>>>><<<<>><<<<>>><<<>>>><<><<<>>><<<>>><<<<>>><>><<>>><<<>><<<<><<<<>>><<<>>>><<<<><<>>><>>>><<<<>>>><<>>>><<><<<><<>><<>>><<<>>><<>><>>><<<<>>><<<>><<<<><<<<>><<<<>>>><<<<>>><<<<>>>><<>><<>>>><<>><<<><<<<>>><<<><<<<>>>><<<<>>><<<<>><>>>><<<<>>>><<>>><>><<<>>><><<<<>><><<<<><>><<>>>><><<<><<<<><<<>><<<<><<<<><>>>><<<<><<<<>>><<<<>>><<<>><<><>>>><<<<><><<>>>><<<><><<>>><<<>>>><<<>>>><<<>>><><<<><<<<>>><<>>>><<>>>><><<<<>><<<>>>><<<>>>><<>>><><>>>><<<>><<><>><><<<>>>><<<<>>>><<<>>>><<><>>><<<<><<<<>>>><<>><<>>><<<<><><>>><<<<>>>><<<<><>>>><>>>><<<>>><><>>><<<>>>><<<>>>><<<>>><>><<>>><<>>>><<<>>><<<><>>><<>><<<>>><<<<>>>><<<>><<><<>>><>>>><<>><<<>><<><<>>><>><<<<>>><<<<><><<<>>>><<<>>>><<<>>><><<>><<>>>><><>>>><>>>><<<<><<>>><<<<>><<<<><><<<>>>><<<<>><<<>>>><<<><<>><<<<>>>><<<<>><>>>><>>>><<<>>><>>>><<>>>><<<>>><<>>><<<<><<<<>>>><><<>>><>><<<>>>><<<<><<<<><<<><><<<<>><<<>><<<>>><<<<>>><<<>>>><>><<>>><<>>>><<<>>><<>>>><<>>>><><><<<>><>>><<<<>><<<><<<<>><<<<>><<<<>><><>>>><<<<><<<>><<>>><<>>>><<<<>>>><<<<>>><<<>><>>>><<>>>><<>>><<<><<<<><<<<>><<>>><>><<<<><>><<<<>><<<><>><><<>><<>>>><<>>><>><<<>><<<<><<<<><<<>><>>><<>><<<>><<>>><<<<>>>><<<>><<>>>><>>><<>>><<<<>>>><><>>><<<>>>><<<<>>>><<<><<<>>><<>>>><><<<<><<<><>>>><><<<<>>><<<>><><<>>>><<<<><<<><<<<>><<>>>><<<<>>>><<<><<<<>><<<<>><<>><<<<>><<<>><><<<<>><>><><<>><<<<>>>><<<<>>>><>>><>>><<>><<<><<<<>><>>>><>><<<>>><<<>>><<<<><>><<<>>>><<>>>><<<><>>><<<>>>><>>><<<>>><<<><<<>>>><>>><><<<><<<>>>><<<>>><<<<><<<>>>><>>>><<><<<>>><<>>><<<<>>>><<>><>>>><>>><<>><<<<>><<>><<<<><<<<>>><<>>>><<><<<>>><<>>>><>>>><>><<<<>>>><>>><>><<<<>><<>>><<<<><<<<>>>><<<>><<>><<<<>>>><<><<<<>>><<<<>>><>>><<<<>>><<<>>><>><<<>>>><<<<>>>><<<<><<>><<<<>>><>>><<>>>><<>>>><<<>>><<<><<<>><<<<>>>><<<<><<<><>>>><<<<>>><<>>><<<>>><<<<>>><<<>>><<>><<<>>>><<<<><<>><<<<>><<<<>>><<<><<<>>>><<<<>>><>>>><<<>>>><<<<>>>><>>><<<<>>><<<><>>>><>><><<<><<<>>><<<>>><<<>>>><<><>><<><<<<>>>><<><<<<>>>><<>><<>>><<<<><<<><<<<>>>><>>><<<><<><>><<<<>>><<<<><<>>><<>>>><<<<><<<<>>>><<<><<<>>>><><<<>><<>>><<<<>>>><<<>>><<<<>>>><<<<>><<<<>>>><<<<>><<<<>>><<>><<<>>><<<<>><<>><<>>><<<>>><<<>>><><>><<>>>><>>>><<><>>><<<><<<>>>><<<<>><><<<<>>><<>>>><<<<>><<<<>>><<<>>><<>>>><>>>><>>><<<<>>><<><<>><<><>>><<<<><<<>>>><>><<<><<<<>>><<<>>><<<<>>><<<<>>>><<<><<<>>><>><<<><<>><<>>>><><<<<>>>><<<>>><<<>>>><<<<>>><<<<><<>><<<<>>><<<<><<><<>>>><>>>><<>>><<<<>>><>>>><<<>>>><<<><<><<<<>>>><>><>><>>><<>>><<>>>><<<<>><<>><>>>><<<>>><<<>>>><<<<><<><<<>>>><<<><<<<>>>><<<<>><<>>><>>><<>>>><<<>><<>>>><<>><<>>>><>><>><<<>>>><>>><<<>><<<>><<<><<<<>>><>>><>>>><<<><>><<<<>>>><<<>>><<<>>>><<>>><<<>><<<>>>><>>><><<<><>><>>><><<<>><<>>><<<>><<<<><<<<>>><<>><<<<>>>><<<<>><<>>>><<<>>><>><<>><<<<><<<<>><<<>><<<<>>>><>><<><<<>>>><<<<><<<<><<<>>><<<>>>><>>><<<>>><<<<>><>>><<<>>>><<<<><<<>>>><<>>>><<<>>><<<><>><<<<>>><<<><<<><<><<<<><<<<><>>>><<<<><<<>><>>><<<<>>><<><<<>><<<><<<<>>>><<<>>><>>>><<>>><<<>>>><<<<>>><<<<>><><>>>><<<<>><<>>><>>>><><<<<><<<>>><>>><<<>>><>><<<>>>><>>>><>><>>>><<<>>>><>>><>>><<><><<<>>><<<>><<<>>><<>><>>><<<>><<<<><>><<>><<><<<<>>><<>>><<>>>><<<<><>>>><<>><>>><<>>><<<<><>>>><<><<<>>>><<<<><<<><<<>>><<<>>><<<<>>><<>>><<<>><><<>>><<<>>><<<>><<<>><<<>>>><<<<>><<>>>><<<<>>><>><<<>>><><<><<<>>>><<>>><<>>>><>><<<<>><<>>><<<<><<<<>>><<<<>>><<<>><<<>><<<<>>><<>>>><<<><<<>><<><<>>>><<<<><<<<><<<<><<<>>>><>>><<<<>>><><<>>><><<>>>><>>>><>>>><<<>>>><><<<>><><>>><<<><<<>>>><<>>>><>>><>><>><<<<><<<<>>><>>>><<<<>><<<>>><<>>>><<>><<><<<>>>><<>>>><<>>>><><>>><<>>>><<>>>><>>><<>><><<>><>>><>>><<<>>><<<<>>><<>>>><<>>>><><<<<>>>><<>><>>><<>>>><<>>>><<<<>><<<<>><<<>>><<<<>><>>>><<><<<>>><<<<><<<<>>>><<<>>><<>><<<<>><<<<>><<>>><<<>>><>><<<<><<<<>>>><<>>><<>>>><<<>>>><<<>><<<>><>><<><<<>><>>><><<>>><<<>>><<<>>><<>>>><<<>>>><>><<<<><><>><<<<
diff --git a/day17/main.go b/day17/main.go
@@ -0,0 +1,224 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "os"
+)
+
+func main() {
+ if len(os.Args) > 1 {
+ day17(os.Args[1])
+ } else if len(os.Args) == 1 {
+ fmt.Printf("usage: %s inputfile.txt\n", os.Args[0])
+ } else {
+ fmt.Println("No input data")
+ }
+}
+
+func day17(input_file string) {
+ fmt.Printf("day 17 input filename: %s\n", input_file)
+ dirs, err := os.ReadFile(input_file)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ shapes := []Shape{
+ CreateLine(),
+ CreateCross(),
+ CreateL(),
+ CreateBeam(),
+ CreateBox(),
+ }
+
+ field := Field{width: 7, points: make(map[Pos]bool)}
+ di := 0
+ si := 0
+ i := 0
+ for {
+ if i == 2022 {
+ break
+ }
+ // spawning new block
+ p := Pos{x: 2, y: field.maxY + 3}
+ for {
+ // wind
+ d := dirs[di]
+ //fmt.Printf("%d(%v)\n", d,d)
+ //fmt.Printf("(%d)dir:%c %v\n",len(dirs),d,d)
+ if d == '<' && p.x > 0 {
+ p1 := Pos{x: p.x - 1, y: p.y}
+ occ := shapes[si].GetOccupied(p1)
+ if !field.Has(occ) {
+ p.x--
+ }
+ } else if d == '>' && p.x+shapes[si].width < field.width {
+ p1 := Pos{x: p.x + 1, y: p.y}
+ occ := shapes[si].GetOccupied(p1)
+ if !field.Has(occ) {
+ p.x++
+ }
+ } else {
+ //log.Fatal("wind direction is invalid:", d)
+ //fmt.Printf("can't move x:%d,mx:%d\n", p.x,p.x+shapes[si].width)
+ }
+ di++
+ if di >= len(dirs)-1 { // have to account for the newline at the end of the string
+ //fmt.Println("wrapping up wind direction")
+ di = 0
+ }
+ // try moving down
+ p1 := Pos{x: p.x, y: p.y - 1}
+ occ := shapes[si].GetOccupied(p1)
+ if p1.y < 0 || field.Has(occ) {
+ // can't move further, gotta stop
+ field.Add(shapes[si].GetOccupied(p))
+ my := p.y + shapes[si].height
+ if my > field.maxY {
+ field.maxY = my
+ }
+ //fmt.Println("max y:", field.maxY)
+ break
+ } else {
+ p = p1
+ //field.Render(occ)
+ }
+ }
+ i++
+ si++
+ if si >= len(shapes) {
+ si = 0
+ }
+ //field.Render(nil)
+ }
+
+ fmt.Println("max y:", field.maxY)
+}
+
+type Pos struct {
+ x, y int
+}
+type Points []Pos
+
+func (pts Points) Has(p Pos) bool {
+ for _, p1 := range pts {
+ if p1.x == p.x && p1.y == p.y {
+ return true
+ }
+ }
+ return false
+}
+
+type Field struct {
+ width int
+ points map[Pos]bool
+ maxY int
+}
+
+func (f Field) Has(pts Points) bool {
+ for _, p := range pts {
+ _, has := f.points[p]
+ if has {
+ return true
+ }
+ }
+ return false
+}
+func (f Field) Add(pts Points) {
+ for _, p := range pts {
+ f.points[p] = true
+ }
+}
+func (f Field) Render(occ Points) {
+ for y := f.maxY + 10; y >= 0; y-- {
+ fmt.Print("|")
+ for x := 0; x < f.width; x++ {
+ p := Pos{x: x, y: y}
+ if f.points[p] {
+ fmt.Print("#")
+ } else if occ.Has(p) {
+ fmt.Print("@")
+ } else {
+ fmt.Print(".")
+ }
+ }
+ fmt.Print("|\n")
+ }
+ fmt.Println("`-------'")
+}
+
+type Shape struct {
+ width, height int
+ occupied Points
+}
+
+func (s Shape) GetOccupied(p Pos) Points {
+ var res Points
+ for _, o := range s.occupied {
+ res = append(res, Pos{p.x + o.x, p.y + o.y})
+ }
+ return res
+}
+
+func CreateLine() Shape {
+ var s Shape
+ s.occupied = Points{
+ Pos{x: 0, y: 0},
+ Pos{x: 1, y: 0},
+ Pos{x: 2, y: 0},
+ Pos{x: 3, y: 0},
+ }
+ s.width = 4
+ s.height = 1
+ return s
+}
+func CreateCross() Shape {
+ var s Shape
+ s.occupied = Points{
+ Pos{x: 1, y: 0},
+ Pos{x: 0, y: 1},
+ Pos{x: 1, y: 1},
+ Pos{x: 2, y: 1},
+ Pos{x: 1, y: 2},
+ }
+ s.width = 3
+ s.height = 3
+ return s
+}
+func CreateL() Shape {
+ var s Shape
+ s.occupied = Points{
+ Pos{x: 0, y: 0},
+ Pos{x: 1, y: 0},
+ Pos{x: 2, y: 0},
+ Pos{x: 2, y: 1},
+ Pos{x: 2, y: 2},
+ }
+ s.width = 3
+ s.height = 3
+ return s
+}
+func CreateBeam() Shape {
+ var s Shape
+ s.occupied = Points{
+ Pos{x: 0, y: 0},
+ Pos{x: 0, y: 1},
+ Pos{x: 0, y: 2},
+ Pos{x: 0, y: 3},
+ }
+ s.width = 1
+ s.height = 4
+ return s
+}
+func CreateBox() Shape {
+ var s Shape
+ s.occupied = Points{
+ Pos{x: 0, y: 0},
+ Pos{x: 1, y: 0},
+ Pos{x: 0, y: 1},
+ Pos{x: 1, y: 1},
+ }
+ s.width = 2
+ s.height = 2
+ return s
+}
diff --git a/day17/sample.txt b/day17/sample.txt
@@ -0,0 +1 @@
+>>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>