Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created December 31, 2014 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/bb5cbe5e408dfd9136a5 to your computer and use it in GitHub Desktop.
Save shigemk2/bb5cbe5e408dfd9136a5 to your computer and use it in GitHub Desktop.
import scala.util.Random
var math = 0.0
var sum = 0
var r = new Random
var count = new Array[Int](13)
for (i <- 1 to 100) {
var math = 0.0
for (i <- 1 to 12) {
math += r.nextDouble
}
sum = (math + 0.5).floor.toInt
count(sum) += 1
}
for (i <- 0 to 12) {
val c = i - 6
val spc = " " * (2 - c.toString.length)
val star = "*" * count(i)
println(s"$spc$c: $star")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment