about summary refs log tree commit diff
path: root/day10.rb
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-12-10 14:26:15 +0100
committerChristian Neukirchen <chneukirchen@gmail.com>2015-12-10 14:26:15 +0100
commit7dcc57442fcbaa83e40bf5f832799e235b6b2f57 (patch)
tree0afbf081c9345105b2aeaa9386a4d3cfe6c00a62 /day10.rb
parent4af2965c747210abb8ca2a405b45bcd1e513074e (diff)
downloadadventofcode2015-7dcc57442fcbaa83e40bf5f832799e235b6b2f57.tar.gz
adventofcode2015-7dcc57442fcbaa83e40bf5f832799e235b6b2f57.tar.xz
adventofcode2015-7dcc57442fcbaa83e40bf5f832799e235b6b2f57.zip
day10
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