From: Robert Klemme Date: 2012-12-08T19:54:09+09:00 Subject: Re: Rows and columns in a text file. On Fri, Dec 7, 2012 at 4:24 AM, 7stud -- wrote: > Joao Silva wrote in post #1088123: > results = [] > rows = 9 > columns = 8 Hey, that's cheating. :-) The algorithm must determine these from the input. Two more solutions puts "-- 1 --" lines = [] max = 0 File.foreach "t" do |line| line.chomp! lines << line max = [max, line.length].max end max.times do |i| puts lines.map {|l| l[i] || ' '}.join end puts "-- 2 --" lines = [] File.foreach "t" do |line| line.chomp! line.each_char.each_with_index do |c, i| (lines[i] ||= '') << c end end puts lines Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/