Guest User

Untitled

a guest
Oct 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "time"
  6. )
  7.  
  8. type ratio [2]int
  9.  
  10. func add(x, y ratio) (answer ratio) {
  11. answer[0] = x[0] + y[0]
  12. answer[1] = x[1] + y[1]
  13. return
  14. }
  15.  
  16. func solve(left, right ratio) (answer int) {
  17. next := add(left, right)
  18. if next[1] > 12000 {
  19. return 0
  20. }
  21. answer = 1 + solve(left, next) + solve(next, right)
  22. return
  23. }
  24.  
  25. func problem73() int {
  26. return solve(ratio{1, 3}, ratio{1, 2})
  27. }
  28.  
  29. func main() {
  30. start := time.Now()
  31. fmt.Println(problem73())
  32. end := time.Now()
  33. fmt.Println(end.Sub(start).Seconds())
  34. }
Add Comment
Please, Sign In to add comment