Skip to content

Instantly share code, notes, and snippets.

View jdwyah's full-sized avatar

Jeff Dwyer jdwyah

View GitHub Profile
names = ["Go",
"Mediterranean Avenue (Purple)",
"Community Chest",
"Baltic Avenue (Purple)",
"Income Tax", ...
[[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]]
zipped = SQUARES.shift
zipped = zipped.zip(*SQUARES)
[[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]]
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
require 'ruby-debug'
NUM_SQUARES = 40
JAIL = 10
GOTO_JAIL = 30
DOUBLE_MAX = 3
MONTE = 4
TOTAL_MOVES = 1
GUESTS = 30
@jdwyah
jdwyah / 0_reuse_code.js
Created January 2, 2014 22:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
ruby '2.0.0'
gem 'rails', '4.0.7'
gem 'pg'
gem 'foreigner'
gem 'devise'
gem 'unicorn'
@jdwyah
jdwyah / homebrew.rb
Last active August 29, 2015 14:07 — forked from pincheira/homebrew.rb
ruby -e "$(curl -fsSL https://gist.githubusercontent.com/jdwyah/a7432521ea8fa81c1557/raw/9e5b58c28c7965ff94e6aeb1c718c67be62df1f5/homebrew.rb)"