Skip to content

Instantly share code, notes, and snippets.

@kballenegger
Created February 1, 2012 23:55
Show Gist options
  • Save kballenegger/f63427fb298e19960033 to your computer and use it in GitHub Desktop.
Save kballenegger/f63427fb298e19960033 to your computer and use it in GitHub Desktop.
directions = {
:right => {
:count => 0,
:next_direction => :down,
:next => lambda {|r,c| {:r => r,:c => c+1}}
},
:down => {
:count => 0,
:next_direction => :left,
:next => lambda {|r,c| {:r => r+1,:c => c}}
},
:left => {
:count => 0,
:next_direction => :up,
:next => lambda {|r,c| {:r => r,:c => c-1}}
},
:up => {
:count => 0,
:next_direction => :right,
:next => lambda {|r,c| {:r => r-1,:c => c}}
}
}
while line = gets
tokens = line.split ';'
rows = tokens[0].to_i
columns = tokens[1].to_i
input = tokens[2]
numbers = line.split ' '
count = 0
matrix = []
for r in (0..rows)
array = []
for j in (0..columns)
array.push numbers[count]
count++
end
matrix.push array
end
p matrixech
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment