Skip to content

Commit

Permalink
Added day15.go
Browse files Browse the repository at this point in the history
  • Loading branch information
djsheehy committed Dec 22, 2017
1 parent a288614 commit 01dbae7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 2017/day15/day15.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package main

import "fmt"

type pair struct{ x, y uint16 }

func (p *pair) generate() bool {
p.x *= 16807
p.y *= 48271
return p.x == p.y
}

func main() {
p := &pair{783, 325}
count := 0
var i uint64
for i = 0; i < 40000000; i++ {
g := p.generate()
if g {
count++
}
}
fmt.Println(count)
}

0 comments on commit 01dbae7

Please sign in to comment.