Add old 2017 puzzle 3.

This commit is contained in:
2020-12-01 19:45:38 -08:00
parent d65e9d1fce
commit de3fdf2e01
3 changed files with 121 additions and 0 deletions

29
2017/3/3.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
"fmt"
"log"
"math"
)
// spiralIndex computes the x, y offsets for a counter-clockwise spiral. It
// assumes a cartesian coordinate system centered at 0,0 with an index of 1.
func spiralIndex(addr int) (xoff, yoff int) {
r := math.Sqrt(float64(addr))
i, f := math.Modf(r)
log.Printf("addr = %d r = %f i = %f f = %f", addr, r, i, f)
if f == 0 {
i := int(i)
// Bottom right corner.
return (i - 1) / 2, -(i - 1) / 2
}
return 0, 0
}
func stepCount(cell int) int {
cnt := 0
return cnt
}
func main() {
fmt.Println(stepCount(265149))
}