fork download
  1. require 'matrix'
  2.  
  3. for n in 1..10
  4. for i in 0..3
  5. for j in 0..3
  6.  
  7. end
  8. end
  9. end
  10.  
  11.  
  12. # Create a 2x2 matrix
  13. m = Matrix[[1, 2], [3, 4]]
  14.  
  15. # Calculate the determinant
  16. det = m.determinant
  17.  
  18. m.to_a.each {|r| puts r.inspect}
  19. p m[1,0]
  20. puts "The determinant of the matrix is #{det}"
  21.  
  22.  
  23.  
Success #stdin #stdout 0.02s 9008KB
stdin
Standard input is empty
stdout
[1, 2]
[3, 4]
3
The determinant of the matrix is -2