diff --git a/README.md b/README.md index 45aa284..f4829ad 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,5 @@ assignment_ruby_warmup Dice, dice, baby. [A Ruby assignment from the Viking Codes School](http://www.vikingcodeschool.com) + +Richard Tutalo diff --git a/dice_outcomes.rb b/dice_outcomes.rb new file mode 100644 index 0000000..830ccc8 --- /dev/null +++ b/dice_outcomes.rb @@ -0,0 +1,18 @@ +def dice_outcome (dice = 1, rolls = 100) + results = {} + + (dice..dice*6).each do |i| + results [i] = 0 + end + + rolls.times do |i| + results [roll_dice(dice)] += 1 + end + + results.keys.each do |num| + print "#{num}: ".ljust(4) + results [num].times {print "#" } + print "\n" + end + results +end \ No newline at end of file diff --git a/roll-dice.rb b/roll-dice.rb new file mode 100644 index 0000000..b936a26 --- /dev/null +++ b/roll-dice.rb @@ -0,0 +1,10 @@ +def roll_dice(n = 1) + sum = 0 + n.times do + sum += 1 + rand(6) + end + sum +end + +p roll_dice(5) +