September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,10 +1,10 @@
|
|||
func floyd(rows, n=1) {
|
||||
var max = Math.range_sum(1, rows);
|
||||
var widths = (max-rows .. max-1 -> map{(.+n).to_s.len});
|
||||
var max = Math.range_sum(1, rows)
|
||||
var widths = (max-rows .. max-1 -> map{.+n->to_s.len})
|
||||
{ |r|
|
||||
say %'#{1..r -> map{|i| "%#{widths[i-1]}d" % n++}.join(" ")}';
|
||||
} * rows;
|
||||
say %'#{1..r -> map{|i| "%#{widths[i-1]}d" % n++}.join(" ")}'
|
||||
} << 1..rows
|
||||
}
|
||||
|
||||
floyd(5); # or: floyd(5, 88);
|
||||
floyd(14); # or: floyd(14, 900);
|
||||
floyd(5) # or: floyd(5, 88)
|
||||
floyd(14) # or: floyd(14, 900)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue