Permalink
Browse files

First commit.

  • Loading branch information...
danielmiessler committed Feb 8, 2012
0 parents commit 3bdb8845db6f44f401bdc36691d92f1bba06dfb0
Showing with 30 additions and 0 deletions.
  1. +30 −0 dicematch.rb
@@ -0,0 +1,30 @@
+nod = 4
+noc = 1000000
+rolls = []
+dicetype = 6
+succeed = 0
+fail = 0
+
+noc.times do
+ nod.times do
+ rolls.push(1 + rand(dicetype))
+ end
+
+rolls.sort!
+rolls.uniq!
+
+if rolls.length == 1 :
+ succeed += 1
+else
+ fail += 1
+end
+rolls.clear
+end
+
+percentage = succeed.to_f / noc.to_f * 100
+
+print "When rolling #{nod} d#{dicetype}'s #{noc} times, there were #{succeed} instances of all dice matching, and #{fail} failures, which is #{percentage}%. \n"
+
+
+
+

0 comments on commit 3bdb884

Please sign in to comment.