This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby-debug' | |
NUM_SQUARES = 40 | |
JAIL = 10 | |
GOTO_JAIL = 30 | |
DOUBLE_MAX = 3 | |
MONTE = 4 | |
TOTAL_MOVES = 1 | |
GUESTS = 30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names.each_with_index do |name, i| | |
z = zipped[i].sort | |
avg = z.inject{ |sum, el| sum + el }.to_f / z.size | |
index = (MONTE * 0.95).to_i | |
if(HUMAN) | |
puts "Avg servings #{avg} 95th pct #{z[index]} max #{z[-1]} #{name}" | |
else | |
puts "\"#{name}\", #{avg}, #{z[index]}, #{z[-1]}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 3], [0, 2, 1, 3], [3, 0, 2, 4], [3, 4, 3, 5], [4, 2, 3, 2], [5, 3, 4, 3], [5, 10, 7, 5], [3, 2, 5, 2], [2, 3, 1, 2], [3, 3, 3, 1], [2, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zipped = SQUARES.shift | |
zipped = zipped.zip(*SQUARES) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[0, 0, 0, 0, 3, 3, 4, 5, 5, 3, 2, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 4, 2, 3, 10, 2, 3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 2, 3, 3, 4, 7, 5, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 3, 4, 5, 2, 3, 5, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names = ["Go", | |
"Mediterranean Avenue (Purple)", | |
"Community Chest", | |
"Baltic Avenue (Purple)", | |
"Income Tax", ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MONTE = 100000 | |
NUM_SQUARES = 40 | |
SQUARES = [] | |
MONTE.times do | |
SQUARES << [0] * NUM_SQUARES | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MONTE.times do |m| | |
GUESTS.times do |i| | |
move(m, 0, TOTAL_MOVES, 0) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def move(curMonte, space, moves, doubles) | |
dieOne = rand(6) + 1 | |
dieTwo = rand(6) + 1 | |
doubles += 1 if dieOne == dieTwo | |
nextSpace = (space + dieOne + dieTwo) % NUM_SQUARES | |
SQUARES[curMonte][nextSpace] += 1 | |
if moves > 1 | |
move(curMonte, nextSpace, moves - 1, doubles) | |
end | |
end |