--------Part 1-------- --------Part 2--------
Day Time Rank Score Time Rank Score
14 00:37:33 4315 0 01:11:46 3445 0
sight what a fuckup.
unwashed part2.
xmax := 101
ymax := 103
secs := 10000
for step := range secs + 1 {
newpos := make(map[xy]int, 0)
nlist := make([]pv, 0, len(rlist))
fmt.Println("step", step)
for _, rob := range rlist {
nx := rob.p.x + (rob.v.x)
nx = nx % xmax
if nx < 0 {
nx = xmax + nx
}
ny := rob.p.y + (rob.v.y)
ny = ny % ymax
if ny < 0 {
ny = ymax + ny
}
npos := xy{nx, ny}
newpos[npos]++
nlist = append(nlist, pv{npos, rob.v})
}
prints := false
for y := range ymax {
for x := 0; x <= xmax; x++ {
oks := 0
if _, ok := newpos[xy{x, y}]; ok {
oks++
for xi := x + 1; xi <= xmax; xi++ {
if _, ok := newpos[xy{xi, y}]; ok {
oks++
} else {
break
}
}
}
if oks > 20 {
prints = true
}
oks = 0
}
}
if prints {
for y := range ymax {
for x := range xmax {
if l, ok := newpos[xy{x, y}]; ok {
fmt.Printf("%d", l)
} else {
fmt.Print(".")
}
}
fmt.Print("\n")
}
time.Sleep(time.Millisecond * 3000)
}
rlist = nlist
}
// c1, c2, c3, c4 := 0, 0, 0, 0
// midx := (xmax) / 2
// midy := (ymax) / 2
// fmt.Println("midx,midy", midx, midy)
// for pos, count := range newpos {
//
// if pos.x < midx && pos.y < midy {
// c1 += count
// }
// if pos.x > midx && pos.y < midy {
// c2 += count
// }
// if pos.x < midx && pos.y > midy {
// c3 += count
// }
// if pos.x > midx && pos.y > midy {
// c4 += count
// }
//
// }
// fmt.Println(c1, c2, c3, c4)
//
// sum := c1 * c2 * c3 * c4
// fmt.Println("sum", sum)
part1 at the bottom.