From 65da3d8dda8aee14e8be09113aaa0cbcc65476aa Mon Sep 17 00:00:00 2001 From: Masato Komatsubara Date: Wed, 6 Dec 2017 13:56:10 +0900 Subject: [PATCH] =?UTF-8?q?transport=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=81=AE=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA?= =?UTF-8?q?=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/transport.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/transport.rb b/lib/transport.rb index d930638..a3b8505 100644 --- a/lib/transport.rb +++ b/lib/transport.rb @@ -1,11 +1,4 @@ def transport(source) - array = source.split("\n").map {|s| s.split(" ")} - rows_count = array.first.count - - transported_array = [] - 0.upto(rows_count - 1) do |i| - transported_array << array.map {|a| a[i]} - end - - transported_array.map {|s| s.join(" ")}.join("\n") -end \ No newline at end of file + array = source.split("\n").map { |s| s.split(' ') } + array.transpose.map { |s| s.join(' ') }.join("\n") +end