aboutsummaryrefslogtreecommitdiff
path: root/day10.rb
blob: a429affec885f4ff27733b1c4289a9bc4616f8b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
def ls(s)
  n = ""
  s.scan(/(\d)\1*/) {
    n << "#{$&.size}#{$1}"
  }
  n
end

d = "1113122113"
40.times { d = ls(d) }
p d.size
10.times { d = ls(d) }
p d.size