Groovy web console

subscribe to the feed Subscribe
to this
site

600 die rolls

Published 1 month ago by SophistiCat with tags probability
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def rnd = new Random()
def roll = { Math.abs(rnd.nextInt()) % 6 + 1 }
def results = (1..6).collectEntries { [it, 0] }
600.times {
    results[roll()]++
}
println results