#!/usr/bin/ruby -w
seen1 = Array.new
seen2 = Array.new
seen3 = Array.new
string = '011010100110000101100001'
debug = true
y = String.new
temp = String.new
echar = String.new
schar = String.new
string.each_byte do |x|
y << x
if !seen1.include?(y)
seen1.push(y)
print "Unique: ", y,"\n" if debug
y = ""
end
end
x='y'
seen1.each {|r| print r, "--"}
for i in 0..seen1.length
temp = seen1[i]
#schar = temp[1..-1]
schar = "asd"
echar = temp[-1,1]
if echar == seen1[i]
seen2.push('0',echar)
else
z = 1
while x != 'y'
if schar == seen1.fetch((i-z))
seen2.push(z,echar)
x = 'y'
else
z = z + 1
end
end
end
end
seen2.each {|r| print r, "--"}