[2017][ruby][5.x] speedrun
change uswnmlvzqtzpvzlyzowunvwzmkpvkvvu
commit d4382b5489affd489fc4859a50206ccec976b5a8
author Alpha Chen <alpha.chen@gmail.com>
date
parent spqovnlp
diff --git a/2017/ruby/day_05.rb b/2017/ruby/day_05.rb
new file mode 100644
index 0000000..364cf7d
--- /dev/null
+++ b/2017/ruby/day_05.rb
@@ -0,0 +1,14 @@
+instructions = ARGF.read.strip.split("\n").map(&:to_i)
+pc = 0
+count = 0
+while (0...instructions.size).cover?(pc)
+  offset = instructions[pc]
+  if offset >= 3
+    instructions[pc] -= 1
+  else
+    instructions[pc] += 1
+  end
+  pc += offset
+  count += 1
+end
+p count