diff --git a/2017/input/day_03.txt b/2017/input/day_03.txt index 8c418b6..6cd3b5b 100644 --- a/2017/input/day_03.txt +++ b/2017/input/day_03.txt @@ -1 +1 @@ -361527 \ No newline at end of file +361527 diff --git a/2017/input/day_10.txt b/2017/input/day_10.txt new file mode 100644 index 0000000..7d6d087 --- /dev/null +++ b/2017/input/day_10.txt @@ -0,0 +1 @@ +147,37,249,1,31,2,226,0,161,71,254,243,183,255,30,70 diff --git a/2017/ruby/day_10.rb b/2017/ruby/day_10.rb new file mode 100644 index 0000000..20f0c69 --- /dev/null +++ b/2017/ruby/day_10.rb @@ -0,0 +1,33 @@ +list = (0..255).to_a +current = 0 +# lengths = ARGF.read.strip.split(?,).map(&:to_i) +input = ARGF.read.strip +p input +lengths = input.split(//).map(&:ord) +p lengths +lengths.concat([17, 31, 73, 47, 23]) +skip = 0 + +# list = (0..4).to_a +# lengths = [3,4,1,5] + +64.times do + lengths.each do |length| + list[0, length] = list[0, length].reverse + list = list.rotate(length + skip) + current += length + skip + current %= list.size + skip += 1 + + # p list.rotate(list.size - current) + end +end + +list = list.rotate(list.size - current) +p list +dense = list.each_slice(16).map {|slice| slice.inject(&:^) } +p dense +p hex = dense.map {|n| n.to_s(16).rjust(2, ?0) }.join + +# list = list.rotate(list.size - current) +# p list[0] * list[1]