Last active
September 21, 2015 20:39
-
-
Save jahan-paisley/574e40f421bc8010dec3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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