testing

Ruby code posted
created at 09 Mar 14:49

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def print_array(file, arr)
  arr.each do |i|
    file.write i
    file.write "\t"
  end
end

code = ['0','1']
n = 7
file = File.open('text.txt', 'w')
print_array(file, code)
file.write "\n"
(n-1).times do 
    old = code
    new = code.reverse
    old.map! {|i| '0' + i}
    new.map! {|i| '1' + i}
    code = old + new
    print_array(file, code)
    file.write "\n"
end
file.close
#print_array(code)
404 Bytes in 2 ms with coderay