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
# Rule 1: Farthest from the door | |
# Rule 2: Dont stand next to occupied | |
# Rule 3: Dont stand between 2 dudes | |
# Except: If line => Ignore 2 & 3 | |
# Except: If 2 or 3 is broken, ignore them | |
def which_stall(stalls, line) | |
if line || rules_broken?(stalls) | |
return furthest_empty(stalls) | |
end |
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
require 'time' | |
class BerlinClock | |
ON = '*' | |
OFF = '.' | |
def initialize(time) | |
@time = time | |
end |
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
(import '(java.text SimpleDateFormat)) | |
(defn make-counts [time] | |
^{:doc "*make-counts* deconstructs a time into the 5 integer | |
values needed by the berlin clock for each line" | |
} | |
[seq | |
(mod (.getSeconds time) 2) | |
(unchecked-divide-int (.getHours time) 5) | |
(mod (.getHours time) 5) |
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
import util.Random | |
// Example Bot #1: The Reference Bot | |
/** | |
* This bot builds a 'direction value map' that assigns an attractiveness score to | |
* each of the eight available 45-degree directions. Additional behaviors: | |
* - aggressive missiles: approach an enemy master, then explode | |
* - defensive missiles: approach an enemy slave and annihilate 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
require 'rrobots' | |
class Gml_robot | |
include Robot | |
INIT_SCAN_DEG = 60 | |
CLOSE_ENOUGH_DEG = 5 | |
MAX_GUN_TURN_DEG = 30 | |
def initialize() |
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
require 'rspec/given' | |
describe "minesweeper" do | |
Given(:minesweeper) { Minesweeper.new(input) } | |
context "the example minesweeper" do | |
Given(:input) { "*...\n....\n.*..\n...." } | |
Then { minesweeper.solve.should == "*100\n2210\n1*10\n1110" } | |
end |
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
source 'https://rubygems.org' | |
gem 'celluloid' | |
gem 'celluloid-io' |
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
# Life: | |
# Rule 1: Any live cell with fewer than 2 live neighbors dies | |
# Rule 2: Any live cell with more than 3 live neighbors | |
# Rule 3: Any live cell with two or three live neighbors lives on | |
# Rule 4: Any dead cell with exatctly three live cells becomes a live cell | |
require "rspec/given" | |
describe "grid" do | |
Given(:grid) { Grid.new(input) } |
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
// This is a program to load test the OAuth Token API in AlphaAuth | |
// It's written in Go to allow it to take advantage of parallelism and run many requests at the same time | |
// MRI Ruby doesn't handle parallelism well so isn't very appropriate for this task. | |
// Install Go v1.1.2 | |
// Build with "go build load.go" to build a native binary for your platform. Go builds statically linked binaries, so you don't | |
// need the go runtime installed where the app is run (but you do need to build it for the target architecture) | |
// ./load -h for command line options | |
// Currently this is only good for testing oauth token API |
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
class ZombieWasteland | |
DEFAULT_WASTELAND = %q(@*^^^ | |
zz*z. | |
**... | |
^..*z | |
zz*zS) | |
def initialize(wasteland=DEFAULT_WASTELAND) | |
@wasteland = wasteland.gsub(' ', '') | |
end |
OlderNewer