challenges

my solutions to various "programming challenge" problems
git clone https://wehaveforgeathome.hates.computer/challenges.git
Log | Files | Refs | LICENSE

026.go (313B)


      1 package main
      2 
      3 import "fmt"
      4 
      5 func main() {
      6 	l := 0
      7 	d := 2
      8 	for i := 2; i < 1000; i++ {
      9 		cL := 0
     10 		s := make(map[int]bool)
     11 		for j := 10; !s[j]; j = (j % i) * 10 {
     12 			if j == 0 {
     13 				// Doesn't repeat.
     14 				cL = 0
     15 				break
     16 			}
     17 			cL++
     18 			s[j] = true
     19 		}
     20 		if cL > l {
     21 			l = cL
     22 			d = i
     23 		}
     24 	}
     25 	fmt.Println(d)
     26 }