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
require 'benchmark' | |
CANS = [1, 2, 4, 10, 15] | |
PRICES = {1 => 4, 2 => 5, 4 => 6, 10 => 11, 15 => 15} | |
RANDOM = Random.new | |
class Mutation | |
attr_accessor :cans |
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
============= | |
Haskell | |
============= | |
http://learnyouahaskell.com/ | |
Great resource for learning Haskell | |
============= | |
Language |
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 System.IO | |
calculateScore x = 0 | |
testDescription 1 = print "Testing score with [(1,5)] == 6" | |
testDescription 2 = print "Testing score with [(1,5), (3, 5), (7, 2)] == 23" | |
testDescription 3 = print "Testing a spare of [(1,5), (5, 5), (7, 2)] == 31" | |
testDescription 4 = print "Testing a strike with [(1,5), (10, 0), (7, 2)] == 34" | |
testDescription 5 = print "Testing a perfect game with 12 [(10,0)] == 300" | |
testDescription 6 = print "Testing a game with all spares with 10 (5,5) and one (5,0) == 150" |
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
/* | |
Copyright Alex Leone, David Nufer, David Truong, 2011-03-11. kathack.com | |
javascript:var i,s,ss=['http://kathack.com/js/kh.js','http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0); | |
*/ | |
var BORDER_STYLE = "1px solid #bbb", | |
CSS_TRANSFORM = null, | |
CSS_TRANSFORM_ORIGIN = null, | |
POSSIBLE_TRANSFORM_PREFIXES = ['-webkit-', '-moz-', '-o-', '-ms-', ''], |
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 Player | |
def play_turn(warrior) | |
@direction = :forward if @direction.nil? | |
if warrior.look(@direction)[1].empty? and warrior.health == @health or @health.nil? | |
warrior.walk! | |
elsif warrior.look(@direction)[1].empty? and warrior.health < @health | |
if warrior.look(@direction)[1].enemy? | |
warrior.shoot! | |
end | |
elsif warrior.feel(@direction).enemy? |
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 Player | |
def initialize | |
@direction = :forward | |
@health = 20 | |
end | |
def play_turn(warrior) | |
@warrior = warrior | |
if nothing_interesting_ahead? |
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
def disable_tooltips | |
page.execute_script( | |
" \ | |
var css = '.tooltip { display: none !important; }', \ | |
head = document.getElementsByTagName('head')[0], \ | |
style = document.createElement('style'); \ | |
style.type = 'text/css'; \ | |
if (style.styleSheet){ \ | |
style.styleSheet.cssText = css; \ | |
} else { \ |
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
flattenNestedFormJSON = function(json) { | |
if (typeof json === "string" || | |
typeof json === "number" || | |
typeof json === "boolean" || | |
json === null) { | |
return json; | |
} | |
if (typeof json !== "object") { | |
return null; |
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
require 'webrick' | |
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => './' | |
server.start |
OlderNewer