Skip to content

Instantly share code, notes, and snippets.

@itszero
Forked from josephcc/main.rb
Last active August 29, 2015 13:56
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 itszero/9176935 to your computer and use it in GitHub Desktop.
Save itszero/9176935 to your computer and use it in GitHub Desktop.
steps = 5
(1..steps)
.map { |x| (1..steps-1).map { |y| [x, y] } }
.flatten(1)
.select { |x, y| steps - x - y > 0 }
.group_by { |x, y| x }
.each do |x, sets|
sets.each do |x, y|
puts [x, y].inspect
end
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment