Skip to main content

Ruby 1.9, 119 chars

num = "#{?b.ord-?a.ord}"
one = num.to_i
limit = ?U.ord-?A.ord
loop {
    puts num
    num = num.gsub(/(?<digit>.)\k<digit>*/) { $&.size.to_s + $+ }
    break if (limit -= one) == one - one
}

A golfed version:

k="#{?b.ord-?a.ord}"
j=k.to_i
i=?U.ord-?A.ord
loop{puts k
k=k.gsub(/(?<d>.)\k<d>*/){$&.size.to_s+$+}
(i-=j)==j-j&&exit}

Ruby 1.9

num = "#{?b.ord-?a.ord}"
one = num.to_i
limit = ?U.ord-?A.ord
loop {
    puts num
    num = num.gsub(/(?<digit>.)\k<digit>*/) { $&.size.to_s + $+ }
    break if (limit -= one) == one - one
}

A golfed version:

k="#{?b.ord-?a.ord}"
j=k.to_i
i=?U.ord-?A.ord
loop{puts k
k=k.gsub(/(?<d>.)\k<d>*/){$&.size.to_s+$+}
(i-=j)==j-j&&exit}

Ruby 1.9, 119 chars

num = "#{?b.ord-?a.ord}"
one = num.to_i
limit = ?U.ord-?A.ord
loop {
    puts num
    num = num.gsub(/(?<digit>.)\k<digit>*/) { $&.size.to_s + $+ }
    break if (limit -= one) == one - one
}

A golfed version:

k="#{?b.ord-?a.ord}"
j=k.to_i
i=?U.ord-?A.ord
loop{puts k
k=k.gsub(/(?<d>.)\k<d>*/){$&.size.to_s+$+}
(i-=j)==j-j&&exit}
Source Link
Lowjacker
  • 4.9k
  • 1
  • 19
  • 19

Ruby 1.9

num = "#{?b.ord-?a.ord}"
one = num.to_i
limit = ?U.ord-?A.ord
loop {
    puts num
    num = num.gsub(/(?<digit>.)\k<digit>*/) { $&.size.to_s + $+ }
    break if (limit -= one) == one - one
}

A golfed version:

k="#{?b.ord-?a.ord}"
j=k.to_i
i=?U.ord-?A.ord
loop{puts k
k=k.gsub(/(?<d>.)\k<d>*/){$&.size.to_s+$+}
(i-=j)==j-j&&exit}