Created
June 20, 2009 21:47
-
-
Save drio/133299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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