def calc_simultaneous_equation(arg)
  arr = []
  arg_arr = arg.split(/\s/)
  6.times.each { |i| arr[i] = [] << arg_arr[i] }

  arr[0][1] = arr[0][0].to_f / arr[0][0].to_f
  arr[1][1] = arr[1][0].to_f / arr[0][0].to_f
  arr[2][1] = arr[2][0].to_f / arr[0][0].to_f

  arr[3][1] = arr[3][0].to_f / arr[3][0].to_f
  arr[4][1] = arr[4][0].to_f / arr[3][0].to_f
  arr[5][1] = arr[5][0].to_f / arr[3][0].to_f

  y = (arr[2][1] - arr[5][1])/(arr[1][1] - arr[4][1])

  x = (arr[2][0].to_f - arr[1][0].to_f * y)/arr[0][0].to_f

  str = sprintf("%.3f\s%.3f", x, y)
  puts str
end

calc_simultaneous_equation('1 2 3 4 5 6')
calc_simultaneous_equation('2 -1 -2 -1 -1 -5')
calc_simultaneous_equation('2 -1 -3 1 -1 -3')
calc_simultaneous_equation('2 -1 -3 -9 9 27')