Compare commits
1 Commits
a3b2c6603e
...
08f7db87ad
Author | SHA1 | Date | |
---|---|---|---|
08f7db87ad |
@ -7,7 +7,6 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
// directions
|
||||
W = iota
|
||||
N
|
||||
E
|
||||
@ -15,14 +14,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// current value
|
||||
cur int
|
||||
// current position
|
||||
x, y int
|
||||
// current direction
|
||||
x int
|
||||
y int
|
||||
dir int
|
||||
// grid bounds
|
||||
xmax, xmin, ymax, ymin int
|
||||
xmax int
|
||||
xmin int
|
||||
ymax int
|
||||
ymin int
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -30,13 +29,15 @@ func main() {
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
// move current position in grid and compute change direction, expand grid
|
||||
fmt.Println(n)
|
||||
|
||||
// create cell and compute change direction, expand grid
|
||||
for cur < n {
|
||||
nextMove()
|
||||
// fmt.Println(cur, x, y)
|
||||
fmt.Println(cur, x, y)
|
||||
}
|
||||
// distance to position
|
||||
fmt.Println(Abs(x) + Abs(y))
|
||||
|
||||
fmt.Println("\n", Abs(x)+Abs(y))
|
||||
}
|
||||
|
||||
func nextMove() {
|
||||
|
Loading…
Reference in New Issue
Block a user