Created
September 14, 2012 10:56
-
-
Save Haroperi/3721290 to your computer and use it in GitHub Desktop.
convert from space separated to matrix (wolfram alpha format)
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
l = gets | |
num_list = l.split(/\s/) | |
n = Math.sqrt(num_list.size).to_i | |
print '{' | |
n.times { | |
print '{' | |
(n-1).times { | |
print "%s, " % num_list.shift | |
} | |
print "%s" % num_list.shift | |
print '}' | |
print "," if num_list.size > 0 | |
} | |
print '} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment