Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
24
Task/Floyds-triangle/Nim/floyds-triangle.nim
Normal file
24
Task/Floyds-triangle/Nim/floyds-triangle.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import strutils
|
||||
|
||||
proc floyd(rowcount = 5): seq[seq[int]] =
|
||||
result = @[@[1]]
|
||||
while result.len < rowcount:
|
||||
let n = result[result.high][result.high] + 1
|
||||
var row = newSeq[int]()
|
||||
for i in n .. n + result[result.high].len:
|
||||
row.add i
|
||||
result.add row
|
||||
|
||||
proc pfloyd(rows) =
|
||||
var colspace = newSeq[int]()
|
||||
for n in rows[rows.high]: colspace.add(($n).len)
|
||||
for row in rows:
|
||||
for i, x in row:
|
||||
stdout.write align($x, colspace[i])," "
|
||||
echo ""
|
||||
|
||||
echo floyd()
|
||||
|
||||
for i in [5, 14]:
|
||||
pfloyd(floyd(i))
|
||||
echo ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue