diff --git a/day10/main.go b/day10/main.go index 555e441..af14239 100644 --- a/day10/main.go +++ b/day10/main.go @@ -127,6 +127,92 @@ func CountAsteroidsFromPosition(field [][]int, posX, posY int) (sum int) { return } +func Vaporized(field [][]int, posX, posY int) { + destroyed := make([]Position, 0) + degree := 0.0 + // 0 bis 180 Grad positives steps X + // 180 bis 0 Grad negatives steps X + // 90 bis 270 Grad positives steps Y + // 270 bi 90 Grad negatives steps Y + + for true { + + // Handle fixed Values + if degree == 270 { + currentX := posX + for true { + currentX-- + if currentX < 0 { + break + } + + if field[posY][currentX] > 0 { + field[posY][currentX] = -1 + destroyed = append(destroyed, Position{Y: posY, X: currentX}) + break + } + } + degree++ + } else if degree == 90 { + currentX := posX + for true { + currentX++ + if len(field[posY]) <= currentX { + break + } + + if field[posY][currentX] > 0 { + field[posY][currentX] = -1 + destroyed = append(destroyed, Position{Y: posY, X: currentX}) + break + } + } + degree++ + } else if degree == 0 { + currentY := posY + for true { + currentY-- + if currentY < 0 { + break + } + + if field[currentY][posX] > 0 { + field[currentY][posX] = -1 + destroyed = append(destroyed, Position{Y: currentY, X: posX}) + break + } + } + degree++ + } else if degree == 180 { + currentY := posY + for true { + currentY++ + if len(field) <= currentY { + break + } + + if field[currentY][posX] > 0 { + field[currentY][posX] = -1 + destroyed = append(destroyed, Position{Y: currentY, X: posX}) + break + } + } + degree++ + } + + if degree > 0 && degree < 90 { + currentX := posX + + for ; currentX < len(field[0]); currentX++ { + for y := 0; y < len(field)-posY; y++ { + + } + } + } + + } +} + func Copy2DSlice(matrix [][]int) (duplicate [][]int) { duplicate = make([][]int, len(matrix)) for i := range matrix {