Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created December 31, 2014 13:34
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/9c80fe9fe0590dc42243 to your computer and use it in GitHub Desktop.
Save shigemk2/9c80fe9fe0590dc42243 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 star = "*" * count(i)
println(s"$c: $star")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment