Sha256: 5499d10345d514793ad4bcbcd09aefd4c7ad59d57f1e3d0ca21e27a6e1068b38
Contents?: true
Size: 556 Bytes
Versions: 158
Compression:
Stored size: 556 Bytes
Contents
package pythagorean const testVersion = 1 type Triplet [3]int func pyth(a, b, c int) bool { return a*a+b*b == c*c } func Range(min, max int) (ts []Triplet) { for a := min; a <= max; a++ { for b := a; b <= max; b++ { for c := b; c <= max; c++ { if pyth(a, b, c) { ts = append(ts, Triplet{a, b, c}) } } } } return } func Sum(sum int) (ts []Triplet) { max := sum / 2 for a := 1; a <= max; a++ { for b := a; b <= max; b++ { if c := sum - a - b; pyth(a, b, c) { ts = append(ts, Triplet{a, b, c}) } } } return }
Version data entries
158 entries across 158 versions & 1 rubygems