Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Floyds-triangle/Scala/floyds-triangle.scala
Normal file
20
Task/Floyds-triangle/Scala/floyds-triangle.scala
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
def floydstriangle( n:Int ) = {
|
||||
val s = (1 to n)
|
||||
val t = s map {i => (s.take(i-1).sum) + 1}
|
||||
|
||||
(s zip t) foreach { n =>
|
||||
var m = n._2;
|
||||
|
||||
for( i <- 0 until n._1 ) {
|
||||
val w = (t.last + i).toString.length + 1 // Column width from last row
|
||||
print(" " + m takeRight w )
|
||||
m+=1
|
||||
}
|
||||
|
||||
print("\n")
|
||||
}
|
||||
}
|
||||
|
||||
// Test
|
||||
floydstriangle(5)
|
||||
floydstriangle(14)
|
||||
Loading…
Add table
Add a link
Reference in a new issue