-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path39.go
47 lines (43 loc) · 829 Bytes
/
39.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
)
func pythagorean (one, two, three int) bool {
return (one*one) + (two*two) == three*three
}
func solutionsCount(perimeter int) int {
var count int
for i := 1; i < perimeter; i++ {
for j := 1; j < i; j ++ {
for k := 1; k < j; k++ {
if pythagorean(j, k, i) && (i + j + k) == perimeter {
count++
}
}
}
}
return count
}
func findMax(array []int) int{
var max int = array[0]
for _, value := range array {
if value > max {
max = value
}
}
return max
}
func main () {
var counts []int
for i := 1; i < 1000; i++ {
counts = append(counts, solutionsCount(i))
}
//largest is 8
//fmt.Println(findMax(counts))
for j := 0; j < len(counts); j++ {
if counts[j] == 8{
fmt.Println(j + 1)
//prints 840
}
}
}