Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solution for GCAQQ0A #30

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions gcaqq0a_penguin_coding_5_family_squares/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package main

import "fmt"

const (
n = 18457
m = 59209
)

var dir = "sw"

func getNextStep(x, y int) (int, int) {
if dir == "sw" {
if y == 0 {
dir = "ne"
return x + 1, y
}
return x + 1, y - 1
}
if x == 0 {
dir = "sw"
return x, y + 1
}
return x - 1, y + 1
}

func main() {
id := 10001
x := 0
y := 0
for {
// fmt.Printf("(%d, %d) = %d\n", x, y, id)

if x == 37 && y == 0 {
fmt.Printf("(%d, %d) = %d\n", x, y, id)
}
if x == 0 && y == 122 {
fmt.Printf("(%d, %d) = %d\n", x, y, id)
break
}

id = (id + n) % m
x, y = getNextStep(x, y)
}
}