Skip to content

Instantly share code, notes, and snippets.

@jahan-paisley
Last active September 21, 2015 20:39
Show Gist options
  • Save jahan-paisley/574e40f421bc8010dec3 to your computer and use it in GitHub Desktop.
Save jahan-paisley/574e40f421bc8010dec3 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
def test(e,f)
(0..e.length-2).all?{|i| (e[i]-e[i+1]).abs==f[i]}
end
k= ARGV[0].to_i
a= (1..2*k-1).to_a
a.permutation(k).each do |e|
(a-e).permutation(k-1).each do |f|
puts e.to_s, f.to_s if test(e,f.to_a)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment