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
# A Ruby version of the Labouchère system simulation in | |
# CoffeeScript by Anders Löfgren that can be found at | |
# https://github.com/gnidde/gniddegit/blob/master/roulette.coffee | |
# 2012-03-19 [email protected] | |
TABLE_ZEROS = 1 | |
MAX_BET = 24 | |
RED_NUMBERS = [1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36] | |
class Player |
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
; A Clojure version of the Labouchère system simulation in | |
; CoffeeScript by Anders Löfgren that can be found at | |
; https://github.com/gnidde/gniddegit/blob/master/roulette.coffee | |
; Ruby version at https://gist.github.com/2127599 | |
; | |
; I'm a complete beginner at Clojure so there's little to | |
; no chance that this code follows conventions and such. | |
; 2012-03-20 [email protected] | |
(def table-zeros 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
require'prime';s=500;n=s*(s+1)/2;i=s+1;while(n.prime_division.transpose[1].map{|n|n+1}.reduce(&:*)<s);n+=i;i+=1;end;n |
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
=begin | |
A line of 100 airline passengers is waiting to board a plane. They | |
each hold a ticket to one of the 100 seats on that flight. (For | |
convenience, let's say that the nth passenger in line has a ticket for | |
the seat number n.) | |
Unfortunately, the first person in line is crazy, and will ignore the | |
seat number on their ticket, picking a random seat to occupy. All of | |
the other passengers are quite normal, and will go to their proper | |
seat unless it is already occupied. If it is occupied, they will then | |
find a free seat to sit in, at random. |
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' | |
@properties = [] | |
1.upto(10000) do | |
@properties << { | |
Strasse:"Oberdorfstrasse", | |
StrassenNr:6, | |
Plz:6277, | |
Ort:"Lieli", |
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
function getRandomInt (min, max) { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
var houses = []; | |
for(var i = 0; i < 10000; i++) { | |
var house = { | |
Street:"Orchard Street", | |
StreetNumber:getRandomInt(1,20), |
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.Diagnostics; | |
namespace Test | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
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
arr = ["imer".split(//), "mare".split(//)].transpose | |
0.upto(arr.length**2-1) {|n| print "De"; 0.upto(arr.length-1) {|m| print arr[m][n>>m & 1] }; puts "t"} |
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
# De Bruijn sequence | |
# Original implementation by Frank Ruskey (1994) | |
# translated to C by Joe Sawada | |
# translated to Ruby by Jonas Elfström (2009) | |
@n = 4 | |
@k = 10 | |
@a = [0] | |
@sequence = [] |
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
# Produces colorized output of the Common Log Format | |
# Usage: $ tail -f access.log | ruby colorpipe.rb | |
require 'rubygems' | |
require 'fastercsv' | |
require 'colorize' | |
require 'resolv' | |
colors = String.colors.reject {|c| c == :black || c == :light_cyan} | |
hosts = {} |