Skip to content

Instantly share code, notes, and snippets.

@krono
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krono/6e2a6ed6de6b63f8840d to your computer and use it in GitHub Desktop.
Save krono/6e2a6ed6de6b63f8840d to your computer and use it in GitHub Desktop.
(Array streamContents: [:s |
(1 to: 998) do: [:x |
(1 to: 998) do: [ :y |
(1 to: 998) do: [:z |
((x+y+z) = 1000 and: [(x * x)+ (y*y) = (z*z)])
ifTrue: [s nextPut: {x.y.z}]]]]])
collect: [:a | [:x :y :z | x * y * z] valueWithArguments: a]
(((1 to: 99) gather: [:xs |
(1 to: 99) gather: [ :ys |
(1 to: 99) collect: [:zs |
{xs. ys. zs} ]]])
select: [:a |
[:x :y :z | (x+y+z)=1000 and: [(x * x)+ (y*y) = (z*z)]] valueWithArguments: a])
collect: [:a |
[:x :y :z | x * y * z] valueWithArguments: a]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment