Skip to content

Instantly share code, notes, and snippets.

View sarahzrf's full-sized avatar

sarahzrf sarahzrf

View GitHub Profile
require 'set'
def fold(line, val)
if val < line
val
elsif val > line
line - (val - line)
else
raise "dot on line!"
end
require 'set'
def fold(line, val)
if val < line
val
elsif val > line
line - (val - line)
else
raise "dot on line!"
end
require 'set'
class CaveSystem
def initialize
@adjs = {}
end
def link(a, b)
(@adjs[a] ||= Set.new) << b
(@adjs[b] ||= Set.new) << a
require 'set'
class CaveSystem
def initialize
@adjs = {}
end
def link(a, b)
(@adjs[a] ||= Set.new) << b
(@adjs[b] ||= Set.new) << a
require 'set'
class Octopus
def initialize(cave, x, y)
@cave = cave
@x = x
@y = y
end
attr_reader :x, :y
require 'set'
class Octopus
def initialize(cave, x, y)
@cave = cave
@x = x
@y = y
end
attr_reader :x, :y
class Corrupted < Exception
def initialize(got)
@got = got
end
attr_reader :got
end
class Parser
def initialize(text)
class Corrupted < Exception
def initialize(got)
@got = got
end
attr_reader :got
end
class Parser
def initialize(text)
class Corrupted < Exception
def initialize(got)
@got = got
end
attr_reader :got
end
class Parser
def initialize(text)
require 'set'
class Cell
def initialize(cave, x, y)
@cave = cave
@x = x
@y = y
end
attr_reader :x, :y