Ver código fonte

Skip over lots of things for more speed.

master
Chris Smith 4 anos atrás
pai
commit
2bdf0cfbb0
Acessado por: Chris Smith <chris@chameth.com> ID da chave GPG: 3A2D4BBDC4A3C9A9
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6
    0
      19/main.go

+ 6
- 0
19/main.go Ver arquivo

@@ -17,6 +17,7 @@ func main() {
17 17
 
18 18
 	sum := 0
19 19
 	lastStart := 0
20
+	lastWidth := 0
20 21
 	for y := 0; ; y++ {
21 22
 		first := 0
22 23
 
@@ -25,6 +26,9 @@ func main() {
25 26
 			if *vm.RunForInput(x, y) == 1 {
26 27
 				if first == 0 {
27 28
 					first = x
29
+					if y > 50 {
30
+						x += lastWidth
31
+					}
28 32
 				}
29 33
 				if x < 50 && y < 50 {
30 34
 					sum++
@@ -45,6 +49,8 @@ func main() {
45 49
 					endPositions[endIndex] = x
46 50
 					endIndex = (endIndex + 1) % shipSize
47 51
 				}
52
+
53
+				lastWidth = x - first - 1
48 54
 				break
49 55
 			}
50 56
 		}

Carregando…
Cancelar
Salvar