Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created May 10, 2010 11:15
Show Gist options
  • Save swannodette/395933 to your computer and use it in GitHub Desktop.
Save swannodette/395933 to your computer and use it in GitHub Desktop.
; from Learn You A Haskell Real Good
; rightTriangles' = [ (a,b,c) | c <- [1..10], b <- [1..c], a <- [1..b], a^2 + b^2 == c^2, a+b+c == 24 ]
(def right-triangles
(let [r (range 1 11)]
(for [c r
b r :when (< b c)
a r :when (< a b)
:when (and (= (+ (* a a) (* b b)) (* c c))
(= (+ a b c) 24))]
[a b c]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment