Skip to content

Instantly share code, notes, and snippets.

@bradpauly
Created December 10, 2014 02:04
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 bradpauly/a7b4557bb51914460dd2 to your computer and use it in GitHub Desktop.
Save bradpauly/a7b4557bb51914460dd2 to your computer and use it in GitHub Desktop.
class Matrix
def initialize(numbers)
@numbers = numbers
end
def rows
@rows ||= @numbers.split("\n").map{ |row| row.split.map(&:to_i) }
end
def columns
rows.transpose
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment