blob: e1482545eeb6a323ba465e93b34a80e22899ad99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#! /usr/bin/ruby
class Bank
attr_accessor :routes, :strips, :current
def initialize( routes = 17, strips = 8, current = 0 )
@routes = routes
@strips = strips
@current = current
end
def left
new_initial = current - routes
if new_initial < 0
new_initial = 0
end
current = new_initial
self
end
def right
delta = routes - ( strips + current ) - 1
puts "delta: #{delta}"
if delta > strips
delta = strips
end
@current += delta
self
end
end
b=Bank.new
|