{{ message }}

Instantly share code, notes, and snippets.

# ChristianSiegert/challenge-2012-03-16.go

Created Jun 16, 2012
Solution written in Go for challenge 2012-03-16 on ProgrammingPraxis.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 package main import ( "fmt" "math" ) func main() { fmt.Println("Exercise from: http://programmingpraxis.com/2012/03/16/sum-of-squares-of-two-largest-of-three-values/") fmt.Println("Exercise: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.") fmt.Println("sum_of_squares_of_largest_two_numbers(2, 3, 1):", sum_of_squares_of_largest_two_numbers(2, 3, 1)) } func sum_of_squares_of_largest_two_numbers(a, b, c float64) float64 { return math.Pow(math.Max(a, b), 2) + math.Pow(math.Max(math.Min(a, b), c), 2) }

### ChristianSiegert commented Jun 16, 2012

Console output:

``````\$ go run challenge-2012-03-16.go
Exercise from: http://programmingpraxis.com/2012/03/16/sum-of-squares-of-two-largest-of-three-values/
Exercise: Define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers.
sum_of_squares_of_largest_two_numbers(2, 3, 1): 13
``````