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