From b4e95ac05f746c0414cd23bf2ee32a151bad590c Mon Sep 17 00:00:00 2001 From: rstootalow Date: Sat, 15 Apr 2017 16:36:17 -0600 Subject: [PATCH 1/7] name added to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) 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 From a105b9068ec339785e96b02a7ed83a0148df29af Mon Sep 17 00:00:00 2001 From: rstootalow Date: Fri, 19 May 2017 08:01:11 -0600 Subject: [PATCH 2/7] roll dice sides complete --- roll-dice.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 roll-dice.rb diff --git a/roll-dice.rb b/roll-dice.rb new file mode 100644 index 0000000..3e2ba93 --- /dev/null +++ b/roll-dice.rb @@ -0,0 +1,5 @@ +def roll_dice(sides) + rand(sides) + 1 +end + +puts roll_dice(12) \ No newline at end of file From 63457c4de8670cce29b3788d1093866173d1515a Mon Sep 17 00:00:00 2001 From: rstootalow Date: Fri, 19 May 2017 14:28:57 -0600 Subject: [PATCH 3/7] roll dice completed --- roll-dice.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/roll-dice.rb b/roll-dice.rb index 3e2ba93..972948c 100644 --- a/roll-dice.rb +++ b/roll-dice.rb @@ -1,5 +1,12 @@ -def roll_dice(sides) - rand(sides) + 1 +class Die + def roll + rand(6) + 1 + end +end + +dice = [Die.new, Die.new] + +dice.each do |die| + puts die.roll end -puts roll_dice(12) \ No newline at end of file From 0a24613a2b8cacdb755394ccb9db856b8b60041e Mon Sep 17 00:00:00 2001 From: rstootalow Date: Fri, 19 May 2017 14:48:39 -0600 Subject: [PATCH 4/7] roll dice complete with three die --- roll-dice.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/roll-dice.rb b/roll-dice.rb index 972948c..8e5eb3e 100644 --- a/roll-dice.rb +++ b/roll-dice.rb @@ -1,12 +1,13 @@ class Die - def roll + def roll_dice rand(6) + 1 end end -dice = [Die.new, Die.new] +dice = [Die.new, Die.new, Die.new] -dice.each do |die| - puts die.roll +dice.each do |dice| + puts dice.roll_dice end + From 220e706aaf0a08b97c3c20ab4ab07dabfd976188 Mon Sep 17 00:00:00 2001 From: rstootalow Date: Fri, 19 May 2017 15:03:19 -0600 Subject: [PATCH 5/7] final complete --- roll-dice.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/roll-dice.rb b/roll-dice.rb index 8e5eb3e..807a98e 100644 --- a/roll-dice.rb +++ b/roll-dice.rb @@ -1,13 +1,10 @@ -class Die - def roll_dice - rand(6) + 1 +def roll_dice(n) + sum = 0 + n.times do |roll| + roll = 4 + sum += roll end + sum end -dice = [Die.new, Die.new, Die.new] - -dice.each do |dice| - puts dice.roll_dice -end - - +puts roll_dice(5) From 41168f6bbe24d9398757529235954e60bd2bfe10 Mon Sep 17 00:00:00 2001 From: rstootalow Date: Sat, 27 May 2017 08:33:50 -0600 Subject: [PATCH 6/7] dice outcome added --- dice_outcomes.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 dice_outcomes.rb 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 From fcd2669a421d30510e5d180cece6b2d118ad01c7 Mon Sep 17 00:00:00 2001 From: rstootalow Date: Mon, 29 May 2017 14:38:51 -0600 Subject: [PATCH 7/7] final roll dice --- roll-dice.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roll-dice.rb b/roll-dice.rb index 807a98e..b936a26 100644 --- a/roll-dice.rb +++ b/roll-dice.rb @@ -1,10 +1,10 @@ -def roll_dice(n) +def roll_dice(n = 1) sum = 0 - n.times do |roll| - roll = 4 - sum += roll + n.times do + sum += 1 + rand(6) end sum end -puts roll_dice(5) +p roll_dice(5) +