Here is a little program to that implements RTM’s series for Cliff Stoll.
package main import "fmt" func count(s []int) int { i := 1 x := s[0] for ; i < len(s); i++ { if s[i] != x { break } } return i } func next(s []int) []int { res := []int{} for len(s) > 0 { n := count(s) res = append(res, n, s[0]) if n == len(s) { break } s = s[n:] } return res } func max(s []int) (m int) { for _, x := range s { if x > m { m = x } } return } func main() { s := []int{1} for i := 0; i < 200; i++ { s = next(s) fmt.Println(len(s), max(s)) } }
Leave a Reply