Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions lib/transport.rb

This file was deleted.

5 changes: 5 additions & 0 deletions lib/transpose.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def transpose(matrix_text)
source_array = matrix_text.lines.map(&:split)
source_array.transpose.map{ |array| array.join(" ")}.join("\n")
end

12 changes: 6 additions & 6 deletions test/transport_test.rb → test/transpose_test.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require 'minitest/autorun'
require './lib/transport'
require './lib/transpose'

class TransportTest < MiniTest::Test
def test_transport
class TransposeTest < MiniTest::Test
def test_transpose
input = "1 2 3\n4 5 6\n7 8 9"
output = "1 4 7\n2 5 8\n3 6 9"
assert_equal output, transport(input)
assert_equal output, transpose(input)

input = "1 2 3\n4 5 6\n7 8 9\n10 11 12"
output = "1 4 7 10\n2 5 8 11\n3 6 9 12"
assert_equal output, transport(input)
assert_equal output, transpose(input)
end
end
end