Skip to content

Instantly share code, notes, and snippets.

@Haroperi
Created September 14, 2012 10:56
Show Gist options
  • Save Haroperi/3721290 to your computer and use it in GitHub Desktop.
Save Haroperi/3721290 to your computer and use it in GitHub Desktop.
convert from space separated to matrix (wolfram alpha format)
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