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
#!/usr/bin/env ruby | |
# usage: ./family.rb [trials] | |
# Family problem, 1000000 trials: | |
# | |
# 997496 girls, 1000000 boys | |
# 1.997496 children per family | |
# 0.997496 girls per boy | |
# | |
# Ran in 15.508096s |
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
#!/usr/bin/env ruby | |
# http://www.facebook.com/careers/puzzles.php?puzzle_id=7 | |
# Memory-heavy but low-computation solution | |
LOOP = [nil, nil, "Hoppity", nil, "Hophop", "Hoppity", nil, nil, "Hoppity", "Hophop", nil, "Hoppity", nil, nil, "Hop"] | |
File.open(ARGV[0], 'r') do |f| | |
f.readline.to_i.times do |i| | |
puts LOOP[i] unless LOOP[i].nil? |
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
jQuery.fn.selectAll = function() { | |
return this.each(function() { | |
if (document.body.createTextRange) { // MSIE | |
var r = document.body.createTextRange(); | |
r.moveToElementText(this); | |
r.select(); | |
} else if (window.getSelection) { // W3C | |
var r = document.createRange(); | |
r.selectNodeContents(this); | |
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
#!/usr/bin/ruby | |
numOfTrials = 10000 | |
numTriangles = 0 | |
numOfTrials.times do | |
# generate two random breaks, in order | |
breaks = [ rand, rand ].sort | |
# load the length calculations via the breaks into an "lengths" array |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" "http://www.w3.org/TR/speech-grammar/grammar.dtd"> | |
<grammar xmlns="http://www.w3.org/2001/06/grammar" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.w3.org/2001/06/grammar | |
http://www.w3.org/TR/speech-grammar/grammar.xsd" | |
xml:lang="en-US" | |
version="1.0" | |
root="command" |
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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Windows.Forms; | |
using System.Speech.Recognition; | |
using System.Net; |
NewerOlder