This file contains 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.new("./pruned-words.txt").read.split("\n") | |
class String | |
def starts_with?(str) | |
self[0..str.length - 1] == str | |
end | |
end | |
# Players can never play "bones", e.g., since the game would end with "bone". | |
# The next two functions remove all 128,832 such extraneous words from our word list. |
This file contains 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
# The Rules of Mindy Coat | |
# ======================= | |
# => Four players, opposite sides are in teams. | |
# => Deal 5 cards each, one-by-one starting left of the dealer. | |
# => Left of the dealer calls trump looking at those 5. | |
# => Dealer deals the last 8 cards out (starts on the left). | |
# => Highest card of the trick wins, unless a trump is thrown, in which case the highest trump wins. | |
# => Team that takes the most tens wins, unless each takes two, in which case the total number of tricks is counted. | |
# => (Must follow suit unless you don't have it.) |
This file contains 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("./TWL06.txt").read.downcase.gsub("\r", "").split("\n") | |
words.select! {|w| w.length == 6} | |
# Approach: | |
# 1. Generate an index that maps 2-templates (like "_l___x") to words ("climax"). | |
# 2. Find 2-templates that map to just one word. | |
def templates(word) | |
"Finds all fifteen (6! / 4! * 2!) 2-templates for a given word." | |
inds = []; (0..4).collect {|i| (i + 1..5).each {|j| inds << [i, j]}} |
This file contains 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 |
This file contains 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 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 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 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 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 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", |
OlderNewer