DoVip has asked for the wisdom of the Perl Monks concerning the following question:
Write a program that simulates the rolling of a die 6000 times and displays in a tabular format the number of occurrences of each side of the die.
Did I wrong something. Pls let me know. Thanks#!/usr/bin/perl $roll = &rolldie; @count = (); @array = (1 .. 6000); print "@array\n"; foreach (1..6000) { $roll = $rolldie; &rolldie; print $roll; push (@count, $roll); &tally; } print "@count\n"; print "ROLL SCORE\n"; print "======================\n"; print sort (keys %tally), "\n"; print sort (values %tally), "\n"; ########### subroutines begin here ############## #### subroutine1 ############################### sub rolldie { return 1 + int(rand(6)); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I need help
by kcott (Archbishop) on Mar 12, 2014 at 04:52 UTC | |
|
Re: I need help
by NetWallah (Canon) on Mar 12, 2014 at 02:57 UTC | |
|
Re: I need help (describe code steps in words)
by Anonymous Monk on Mar 12, 2014 at 02:52 UTC | |
|
Re: I need help
by davido (Cardinal) on Mar 12, 2014 at 14:05 UTC | |
|
Re: I need help
by Lennotoecom (Pilgrim) on Mar 12, 2014 at 04:19 UTC | |
by Kenosis (Priest) on Mar 12, 2014 at 05:34 UTC | |
by Lennotoecom (Pilgrim) on Mar 12, 2014 at 05:50 UTC |