Last active
February 8, 2017 04:24
-
-
Save tekkoc/9684cf79506f598c5b20929bfbc003ed to your computer and use it in GitHub Desktop.
ピラミッドっぽいやつ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App{ | |
def pir(n: Int): Iterable[String] = { | |
import scala.math._ | |
for ( | |
i <- (-n to n); | |
height = n - abs(i) | |
if (height > 0) | |
) yield "o" * height | |
} | |
for (i <- 0 to 5) { | |
println(s"pir(${i}):") | |
pir(i).foreach(println) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pir(0): | |
pir(1): | |
o | |
pir(2): | |
o | |
oo | |
o | |
pir(3): | |
o | |
oo | |
ooo | |
oo | |
o | |
pir(4): | |
o | |
oo | |
ooo | |
oooo | |
ooo | |
oo | |
o | |
pir(5): | |
o | |
oo | |
ooo | |
oooo | |
ooooo | |
oooo | |
ooo | |
oo | |
o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment