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
alias shouldstrip { if ($nick == Nick && $chan == #channel) return $true } | |
on ^:TEXT:*:#:if ($shouldstrip) { echo -mbflirt # #+(<,$nick(#,$nick).pnick,>) $strip($1-) | haltdef } | |
on ^:ACTION:*:#:if ($shouldstrip) { echo $color(action) -mbflirt # * $nick(#,$nick).pnick $strip($1-) | haltdef } |
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
# _____ __ _ ____ | |
# / ___// /___ ______ (_) __/_ __ | |
# \__ \/ __/ / / / __ \/ / /_/ / / / | |
# ___/ / /_/ /_/ / /_/ / / __/ /_/ / | |
# /____/\__/\__,_/ .___/_/_/ \__, / | |
# /_/ /____/ | |
# type like you're trying really hard | |
# give it a sentence, an intelligence score from 0 to 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
# nonsense.rb | |
# a markov chain of varying depth | |
# USAGE: make a new nonsense tree, add lines, then chain! | |
# > non = Nonsense.new 2 | |
# > non.add_line "What is happening" | |
# > non.add_line "The world is on fire" | |
# > non.chain | |
# => "What won hat woren ire worenis hape" | |
class Nonsense |
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
var GameView = require('./console_view.js'); | |
function ConnectFour() { | |
this.buildBoard(); | |
this.player = 1; | |
this.playerWon = false; | |
} | |
ConnectFour.prototype.buildBoard = function() { | |
var board = [], row; |
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
# Sieve of Eratosthenes. Use it for all of your prime number shenanigans. | |
# Built this for solving Project Euler problems. | |
# Hash map chosen over array after careful arbitrary consideration. | |
### O(1) amortized lookup of any prime with dynamic resizing. | |
### O(n) memory where n = size of cache, but RAM is cheap these days. | |
class Sieve | |
def initialize() | |
@size = 64 | |
@next = 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
import itertools | |
array = [1,2,3,4,5,6,7,8] | |
combs = itertools.combinations( array, 2 ) | |
largest = 0 | |
for x in combs: | |
largest = max( sum( x ), largest ) | |
print largest |
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
class PrefixTree | |
attr_reader :longest | |
def initialize | |
@tree = {} | |
@longest = 0 | |
end | |
def insert( str ) | |
node = @tree |