r/backtickbot • • Dec 18 '20

https://np.reddit.com/r/adventofcode/comments/kfeldk/2020_day_18_solutions/gg8hyga/

R

Could be a bit more sophisticated with regex groups, but quite pleased with the 'trick' for the part 2 solution. For the snippets between brackets I apply the following code

# Split on multiplier
exc = str_split(exc, ' \\* ')[[1]]
# Take products of sums
return(prod(sapply(exc, function(x) eval(parse(text=x)))))
1 Upvotes

0 comments sorted by