Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Rep-string/Ruby/rep-string.rb
Normal file
16
Task/Rep-string/Ruby/rep-string.rb
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
ar = %w(1001110011
|
||||
1110111011
|
||||
0010010010
|
||||
1010101010
|
||||
1111111111
|
||||
0100101101
|
||||
0100100
|
||||
101
|
||||
11
|
||||
00
|
||||
1)
|
||||
|
||||
ar.each do |str|
|
||||
rep_pos = (str.size/2).downto(1).find{|pos| str.start_with? str[pos..-1]}
|
||||
puts str, rep_pos ? " "*rep_pos + str[0, rep_pos] : "(no repetition)", ""
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue