River Crossing ¶
- 2011 4 4 모 된 교 께는 CodeRace.라 CodeRace 못 것 늦게라 딩본다. 늘 말 려고 는데 다가 무무 보고 갑기 깨길래 떻게 고민. 고민다 달날 로 고 것 그냥 기면 되겠다 벽 3 나 딩 .
- 는 RubyLanguage
- TDD로 개발려 는데 rake aborted! No Rakefile found. 라는 메가 뜨면 가 되 기. 동 봤만 모르겠다. 문를 면 답 것 같데 더 를 고ㅜㅜㅜㅜㅜㅜ
- 가 또 더 날렸다... 곤 러가.
목 ¶
- 모든 람 A B 로 다.
¶
- A 과 B 는 강 다.
- 강 무나 고 깊기 때문 배를 고 다.
Step 1 ¶
- 교가 A B 로 다.
class Layton @location attr_accessor :location def initialize @location = false end def crossRiver @location = true end end
layton = Layton.new() layton.crossRiver if !layton.location print "FAIL" end
Step 2 ¶
- 교는 배를 고 맞 로 다.
- A -> B
- B -> A
- A -> B
class Layton @location attr_accessor :location def initialize @location = false end def crossRiver @location = !@location end end
class Solver def run(person) person.crossRiver end end
solver = Solver.new() layton = Layton.new() solver.run(layton) if !layton.location print "FAIL" end
Step 3 ¶
- 루
- 루는 려 는 배를 다.
- 루는 려 는 배를 다.
Step 4 ¶
- 로
- 로는 교가 면 루를 강 던린다.
- 로는 교가 면 루를 강 던린다.
Step 5 ¶
- 2 배만 다.