7 lines
139 B
Text
7 lines
139 B
Text
func encode(str) {
|
|
str.gsub(/((.)(\2*))/, {|a,b| "#{a.len}#{b}" });
|
|
}
|
|
|
|
func decode(str) {
|
|
str.gsub(/(\d+)(.)/, {|a,b| b * a.to_i });
|
|
}
|