Skip to content

Instantly share code, notes, and snippets.

@drio
Created June 20, 2009 21:47
Show Gist options
  • Save drio/133299 to your computer and use it in GitHub Desktop.
Save drio/133299 to your computer and use it in GitHub Desktop.
require 'pp'
def mark_them(l, poss)
i=0
poss.each do |p|
l.insert(i + p[0], '*')
i = i + 1
l.insert(i + p[1] + 1, '*')
i = i + 1
end
[poss.size.to_s, l]
end
def pos_rep(ta) # ta = the array
d_chr_pos = []
ta.each_index do |i|
d_chr_pos << [i, i+1] if ta[i+1] and ta[i] == ta[i+1]
end
d_chr_pos
end
final = ""
DATA.each do |line|
puts line
a_line = line.split('')
pr = pos_rep(a_line)
n_line = mark_them(a_line, pr)
final << "{" + n_line[0] + "} " + n_line[1].join
end
puts "--"
puts final
__END__
test. AA. I greatXXrr love it.
audi tt uu yes.
stop here, axmmen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment