Time for an 2014 update…
This commit is contained in:
parent
372c577f83
commit
09687c4926
2520 changed files with 34227 additions and 7318 deletions
|
|
@ -1,19 +1,16 @@
|
|||
class Array
|
||||
def beadsort
|
||||
self.map {|e| [1] * e}.columns.columns.map {|e| e.length}
|
||||
end
|
||||
def beadsort
|
||||
map {|e| [1] * e}.columns.columns.map {|e| e.length}
|
||||
end
|
||||
|
||||
def columns
|
||||
y = self.length
|
||||
x = self.map {|l| l.length}.max
|
||||
|
||||
Array.new(x) do |row|
|
||||
Array.new(y) { |column|
|
||||
self[column][row]
|
||||
}.compact # Remove nulls.
|
||||
end
|
||||
end
|
||||
def columns
|
||||
y = length
|
||||
x = map {|l| l.length}.max
|
||||
Array.new(x) do |row|
|
||||
Array.new(y) { |column| self[column][row] }.compact # Remove nils.
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Demonstration code:
|
||||
[5,3,1,7,4,1,1].beadsort
|
||||
p [5,3,1,7,4,1,1].beadsort
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue