Skip to content

Commit 03e6411

Browse files
authored
Merge pull request #30 from bitlux/dev
Add solution for GCAQQ0A
2 parents 9c6c268 + d0d075a commit 03e6411

File tree

1 file changed

+45
-0
lines changed
  • gcaqq0a_penguin_coding_5_family_squares

1 file changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package main
2+
3+
import "fmt"
4+
5+
const (
6+
n = 18457
7+
m = 59209
8+
)
9+
10+
var dir = "sw"
11+
12+
func getNextStep(x, y int) (int, int) {
13+
if dir == "sw" {
14+
if y == 0 {
15+
dir = "ne"
16+
return x + 1, y
17+
}
18+
return x + 1, y - 1
19+
}
20+
if x == 0 {
21+
dir = "sw"
22+
return x, y + 1
23+
}
24+
return x - 1, y + 1
25+
}
26+
27+
func main() {
28+
id := 10001
29+
x := 0
30+
y := 0
31+
for {
32+
// fmt.Printf("(%d, %d) = %d\n", x, y, id)
33+
34+
if x == 37 && y == 0 {
35+
fmt.Printf("(%d, %d) = %d\n", x, y, id)
36+
}
37+
if x == 0 && y == 122 {
38+
fmt.Printf("(%d, %d) = %d\n", x, y, id)
39+
break
40+
}
41+
42+
id = (id + n) % m
43+
x, y = getNextStep(x, y)
44+
}
45+
}

0 commit comments

Comments
 (0)