Skip to content

Instantly share code, notes, and snippets.

Avatar

Johannes Brodwall jhannes

View GitHub Profile
View minefield_spec.coffee
describe "Explored minefield", ->
expectHints = (mines) ->
expect(new exports.Minefield(mines:mines,explored:true).hints())
it "shows rows and columns", ->
expectHints(["...","..."]).toEqual ["000", "000"]
it "shows minefield shape", ->
expectHints(["..","..",".."]).toEqual ["00","00","00"]
@jhannes
jhannes / investigate.rb
Created May 13, 2011
Refactoring in the 4th dimension
View investigate.rb
require 'rubygems'
require 'awesome_print'
load 'repodepot.rb'
class CodeEvent
def full_method_name
class_name + "#" + method_name
end
@jhannes
jhannes / print-tree.clj
Created Apr 29, 2011
Tree pretty printer in clojure
View print-tree.clj
(defn print-subtree [subtree prefix]
(if (empty? subtree)
""
(apply str prefix (first subtree) "\n"
(map #(print-subtree %1 (str "\t" prefix)) (rest subtree)))))
(defn print-tree [tree]
(print-subtree tree ""))
(deftest print-empty-tree
You can’t perform that action at this time.