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
from itertools import product | |
def iterate_dice_simple(diceNums, diceToHold): | |
roles = list(product(range(1, 7), repeat=len(diceNums))) | |
return [r for r in roles if has_held_dice(r, diceNums, diceToHold)] | |
def has_held_dice(r, diceNums, diceToHold): | |
for i in range(len(diceToHold)): | |
if diceToHold[i] == 0: continue | |
if r[i] != diceNums[i]: return False |
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
#!/Users/jsomers/.rvm/rubies/ruby-1.9.2-p290/bin/ruby | |
require 'prime' | |
class Menke | |
def initialize(numbers) | |
@numbers = numbers | |
@grid = make_grid | |
end | |
def solve! |
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
words = File.open("/usr/share/dict/words").read.split("\n").map(&:downcase) | |
anagram_index = words.inject(Hash.new {[]}) { |idx, word| idx[word.split("").sort] += [word]; idx } | |
p anagram_index.select {|_, v| v.length == 4} |
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
$rom_counter = 0 | |
$ram_counter = 16 | |
$symbols = { | |
"SP" => "0", | |
"LCL" => "1", | |
"ARG" => "10", | |
"THIS" => "11", | |
"THAT" => "100", | |
"R0" => "0", | |
"R1" => "1", |
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
<!-- TODOS | |
* More feedback about when the last save was, and what type it was. | |
* Word count responding to highlights initiated via the keyboard. | |
--> | |
<link type="text/css" href="./pad.css" rel="stylesheet" /> | |
<script src="./diff_match_patch.js" type="text/javascript"></script> | |
<script src="./jquery-1.3.2.min.js" type="text/javascript"></script> | |
<script src="./field-selection.js" type="text/javascript"></script> |
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
# See http://www.glicko.net/glicko/glicko.pdf | |
DEFAULT_RATING = 1500.0 | |
AVERAGE_RD = 50.0 # Could be determined empirically. | |
PERIODS_TO_RESET = 400.0 # If you sit out 400 games your rating is as uncertain as a new player's. | |
UNRATED_RD = 350.0 | |
MINIMUM_RD = 30.0 | |
C = Math::sqrt((UNRATED_RD ** 2 - AVERAGE_RD ** 2) / PERIODS_TO_RESET) | |
Q = 0.0057565 |
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
=begin | |
Most of the work here is in generating a sort of matrix of mutually | |
compatible "p-bricksets," or single-row arrangements of bricks. There are | |
something like 3,300 of these total. | |
Once you have that matrix - what in the code I call the "compatimap" - all you | |
do is exhaustively "expand" each p-brickset ten times (for the ten rows). | |
It helps to imagine the space of possible walls as a tree in which nodes are |
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
N = 6 | |
R = 2 | |
def masks | |
@masks ||= (0..N - 1).to_a.combination(N - R).to_a | |
end | |
def templates(word) | |
masks.inject([]) do |templates, indexes_to_hide| | |
arr = word.split('') |
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
# [n, tot, -AA, 0Ls, -A, 1L-AA, 1L-A, 1LnotA] | |
lst = [1, 3, 0, 2, 1, 0, 0, 1] | |
while lst[0] < 30 | |
n, t, a, b, c, d, e, f = lst | |
lst = [n + 1, 2 * t + b - a, c, 2 * b - a + d, t - (a + c), e, f, t] | |
end | |
p lst[1] # => 1918080160 |
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
index = {} | |
def nxt(n) | |
(n % 2 == 0 ? n / 2 : 3 * n + 1) | |
end | |
(2..1_000_000).each do |n| | |
c = n + 0 | |
ct = 0 | |
while n > 1 |