Created
October 19, 2014 08:38
-
-
Save siraz-provectus/3f7eba75711c1de3a689 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
puts 'Enter sequence' | |
mass = String(gets.chomp) | |
mass = mass.split(//); | |
count = 1 | |
exit_mass = [] | |
b = '' | |
mass.each_with_index do |a, index| | |
if index > 0 | |
if b == a | |
count +=1 | |
else | |
exit_mass << count | |
exit_mass << b | |
count = 1 | |
b = a | |
end | |
else | |
b = a | |
end | |
end | |
exit_mass << count | |
exit_mass << b | |
exit_mass = exit_mass.join('') | |
puts exit_mass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment