Commits

Steven! Ragnarök  committed 0d968fe

Initial commit.

  • Participants

Comments (0)

Files changed (1)

+#     die       sum  mean  sdev
+# ------------  ---  ----  ----
+# A S P F F K    19  3.17  2.23
+# N U I H M Qu   23  3.83  2.14
+# O B J O A B    25  4.17  2.79
+# L N H N R Z    27  4.50  1.87
+# A H S P C O    28  4.67  2.16
+# R Y V D E L    28  4.67  3.27
+# I O T M U C    29  4.83  2.93
+# L R E I X D    30  5.00  3.41
+# T E R W H V    35  5.83  3.49
+# T S T I Y D    36  6.00  2.68
+# W N G E E H    38  6.33  3.88
+# E R T T Y L    41  6.83  3.25
+# O W T O A T    41  6.83  2.23
+# A E A N E G    42  7.00  3.46
+# E I U N E S    43  7.17  3.19
+# T O E S S I    45  7.50  2.07
+# 
+class Array
+
+  def randomize
+    duplicated_original, new_array = self.dup, self.class.new
+    new_array << 
+duplicated_original.slice!(rand(duplicated_original.size)) until 
+new_array.size.eql?(self.size)
+    new_array
+  end
+
+  def randomize!
+    self.replace(randomize)
+  end
+
+end
+
+@dice = [ %w{A S P F F K}, %w{N U I H M Q}, %w{O B J O A B}, %w{L N H N R Z},
+  %w{A H S P C O}, %w{R Y V D E L}, %w{I O T M U C}, %w{L R E I X D},
+  %w{T E R W H V}, %w{T S T I Y D}, %w{W N G E E H}, %w{E R T T Y L},
+  %w{O W T O A T}, %w{A E A N E G}, %w{E I U N E S}, %w{T O E S S I} ]
+@rand = Random.new
+
+@board = []
+@dice.each do |die|
+  @board << die[@rand.rand(die.length)]
+end
+
+str = ""
+4.times do
+  4.times do
+    str << @board.randomize!.pop
+    str << ' '
+  end
+  str << "\n"
+end
+
+puts str