blob: 6d6f8496aca6824d3b46666689b013b43d8d2d42 (
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
33
34
35
36
37
38
39
40
41
42
43
|
TEST_S = <<EOF
[D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
EOF
class Stacks
end
class Instructions
attr_reader :indexes
def initialize(header)
indexes = {}
indexes.default = []
header.readlines do |line|
line.scan(/\w/).each do |c|
indexes[line.index(c)] << c
end
end
self.indexes = {}
indexes.each_key.each_with_index do |i, index|
self.indexes[i] = indexes[index]
end
end
end
def parse_input(filename)
File.open(filename) do |file|
contents = file.read
header, body = contents.split(/^$/)
end
end
|