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
# 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.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. |
NewerOlder