package day03 import ( "tools" ) func Part1(puzzle tools.AoCPuzzle) interface{} { x, y := 0, 0 houses := make(map[int]map[int]bool) for _, c := range puzzle.GetInputArray()[0] { switch c { case '^': x-- case '<': y-- case '>': y++ case 'v': x++ } if _, ok := houses[x]; !ok { houses[x] = make(map[int]bool) } houses[x][y] = true } houseCount := 0 for x := range houses { houseCount += len(houses[x]) } return houseCount } func Part2(puzzle tools.AoCPuzzle) interface{} { x, y := [2]int{0, 0}, [2]int{0, 0} turn := 0 houses := make(map[int]map[int]bool) for _, c := range puzzle.GetInputArray()[0] { switch c { case '^': x[turn]-- case '<': y[turn]-- case '>': y[turn]++ case 'v': x[turn]++ } if _, ok := houses[x[turn]]; !ok { houses[x[turn]] = make(map[int]bool) } houses[x[turn]][y[turn]] = true if turn == 0 { turn = 1 } else { turn = 0 } } houseCount := 0 for x := range houses { houseCount += len(houses[x]) } return houseCount }