Skip to content

Instantly share code, notes, and snippets.

source 'https://rubygems.org'
gem 'celluloid'
gem 'celluloid-io'
@geofflane
geofflane / minesweeper.rb
Last active December 15, 2015 04:29
Ruby user group minesweeper kata
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
@geofflane
geofflane / robot3.rb
Created November 21, 2012 01:09 — forked from st23am/robot3.rb
geoff_and_joe_bot.rb
require 'rrobots'
class Gml_robot
include Robot
INIT_SCAN_DEG = 60
CLOSE_ENOUGH_DEG = 5
MAX_GUN_TURN_DEG = 30
def initialize()
@geofflane
geofflane / Bot.scala
Created November 14, 2012 00:45
Scalatron Bot
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
@geofflane
geofflane / berlin.clj
Created April 18, 2012 17:29
Berlin Clock Kata in clojure
(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)
@geofflane
geofflane / berlin.rb
Created April 18, 2012 00:00 — forked from jimweirich/abstract.md
Berlin Clock Kata
require 'time'
class BerlinClock
ON = '*'
OFF = '.'
def initialize(time)
@time = time
end
@geofflane
geofflane / urinal_etiquette.rb
Created February 22, 2012 01:01 — forked from st23am/urinal_etiquette.rb
Test Problem
# 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