-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathocr.rb
More file actions
34 lines (28 loc) · 863 Bytes
/
Copy pathocr.rb
File metadata and controls
34 lines (28 loc) · 863 Bytes
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
def parse_string
#read the input file and split into an array of account numbers
input = IO.read("input.txt").gsub("\n","").scan(/.{108}/m)
parsed_numbers = ""
mappings = { "_| ||_|" => "0",
" | |" => "1",
"_ _||_ " => "2",
"_ _| _|" => "3",
" |_| |" => "4",
"_|_ _|" => "5",
"_|_ |_|" => "6",
"_ | |" => "7",
"_|_||_|" => "8",
"_|_| _|" => "9"}
input.each do |string|
string.gsub!('\n', '')
for i in [1,4,7,10,13,16,19,22,25]
number_string = ""
number_string << string[i]
number_string << string[i+26..i+28]
number_string << string[i+53..i+55]
parsed_numbers << mappings[number_string]
end
parsed_numbers << "\n"
end
puts parsed_numbers
end
parse_string