From 7e686a60569db36e07c3f2de1c2dde02d9e80d86 Mon Sep 17 00:00:00 2001 From: itume Date: Sun, 3 Dec 2017 11:48:58 +0900 Subject: [PATCH] =?UTF-8?q?Array=E3=81=AE=E8=BB=A2=E7=BD=AE=E3=81=AFtransp?= =?UTF-8?q?ort=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E4=BD=BF?= =?UTF-8?q?=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/transport.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/transport.rb b/lib/transport.rb index d930638..161488b 100644 --- a/lib/transport.rb +++ b/lib/transport.rb @@ -1,11 +1,5 @@ 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 = array.transpose transported_array.map {|s| s.join(" ")}.join("\n") -end \ No newline at end of file +end