Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Matrix Rotator (#209
Luke Cowell
6/16/2009 4:14:00 AM
My solution:
def self.rotate(rect)
rotated = []
rect.each_with_index do |row, irow|
row.reverse.each_with_index do |col, icol|
rotated[icol] ||= []
rotated[icol][irow] = col
end
end
rotated
end
It works by reversing the elements in the row and then swapping elements
in the x & y axis.
Luke
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Matrix Rotator (#209
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password