Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- type State [10]int
- func (s *State) isPrime() bool {
- for i := range s {
- if i > 0 && s[i] > 0 {
- return false
- }
- }
- return true
- }
- func (s *State) isBlank() int {
- t := s[0]
- s[0] = 0
- s[2] += t + 1
- u := s[3]
- s[3] = t - 1
- return u + 1 + 3*t + 2
- }
- func (s *State) iteration() int {
- if s[6] == 0 {
- s[6] = 1
- return s.isBlank()
- }
- if s[2] > 0 && s[3] > 0 {
- t := s[3] + 1
- q := s[2] / t
- u := s[0] + s[2]
- s[0] += q * t
- s[2] -= q * t
- if s[2] == 0 {
- return q*(4*t+2) + s.isBlank() + 1
- }
- v := s[2]
- s[0] = 0
- s[2] = u
- s[3]--
- return q*(4*t+2) + 4*v + 2*u + 2
- }
- t := s[2]
- s[0] += t
- s[2] = 0
- s[6] = 0
- return 6*t + 1
- }
- func fun(n int) string {
- if n == 0 {
- return "⚪"
- } else if n == 1 {
- return "⚫"
- }
- panic(n)
- }
- func main() {
- var s State = [10]int{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- index := 0
- for iter := 0; iter < 100000; {
- iter += s.iteration()
- fmt.Printf("%4d: %3d, %3d, %3d, %3d %s%s%s%s%s%s\n", iter, s[0], s[1], s[2], s[3], fun(s[4]), fun(s[5]), fun(s[6]), fun(s[7]), fun(s[8]), fun(s[9]))
- if s.isPrime() {
- index++
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement