Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Created September 5, 2008 06:41
Show Gist options
  • Select an option

  • Save tarcieri/8931 to your computer and use it in GitHub Desktop.

Select an option

Save tarcieri/8931 to your computer and use it in GitHub Desktop.
>> [x.to_s() | x in 1..10]
=> ["1","2","3","4","5","6","7","8","9","10"]
# Find Pythagorean triples
>> n = 50
=> 50
>> [(a,b,c) | a in 1..n, b in 1..n, c in 1..n, a+b+c <= n, a**2 + b**2 == c**2]
=> [(3,4,5),(4,3,5),(5,12,13),(6,8,10),(8,6,10),(8,15,17),(9,12,15),(12,5,13),(12,9,15),(12,16,20),(15,8,17),(16,12,20)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment