about summary refs log tree commit diff
path: root/day10.rb
diff options
context:
space:
mode:
Diffstat (limited to 'day10.rb')
-rw-r--r--day10.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/day10.rb b/day10.rb
new file mode 100644
index 0000000..a429aff
--- /dev/null
+++ b/day10.rb
@@ -0,0 +1,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