Today, the Elves are playing a game called look-and-say. They take turns making sequences by reading aloud the previous sequence and using that reading as the next sequence. For example, 211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s).
Look-and-say sequences are generated iteratively, using the previous value as input for the next step. For each step, take the previous value, and replace each run of digits (like 111) with the number of digits (3) followed by the digit itself (1).
For example:
Starting with the digits in your puzzle input, apply this process 40 times. What is the length of the result?
Your puzzle input is 1113122113
.
In [1]:
input=: '1113122113'
las_numeric=: ,@((# , {.);.1~ 1 , 2 ~:/\ ])&.(10x&#.inv)@]^:(1+i.@[)
las=: ([: , (1 , 2 ~:/\ i.~)@] (":@# , {.);.1 ])^:[
echo 'Day10 Part1: ',": # 40 las input
In [2]:
echo 'Day10 Part2: ',": # 50 las input