#rstats Using matrix multiplies
#rstats Using matrix multiplies
May have cheated for part 2 - used google + chatgpt to see how to use linear programming solver.
github.com/mdg583/AOC/t...
May have cheated for part 2 - used google + chatgpt to see how to use linear programming solver.
github.com/mdg583/AOC/t...
This one was super hard - I finally got it. Code is here: github.com/mdg583/AOC/t....
The solution takes some time. It walks around each region and checks when it steps off a boundary.
This one was super hard - I finally got it. Code is here: github.com/mdg583/AOC/t....
The solution takes some time. It walks around each region and checks when it steps off a boundary.
Going row-by-row and using element-wise vector operations, where lshift and rshift look left and right
Going row-by-row and using element-wise vector operations, where lshift and rshift look left and right
I came up with a solution for Day 2 which I am pretty happy with. %95 sure it is correct. It assumes the inputs are <= 10 digits.
After a lot of thinking I concluded that an inclusion/exclusion principle holds for 2,3,5,7 - 6,10 repeated numbers.
github.com/mdg583/AOC/t...
I came up with a solution for Day 2 which I am pretty happy with. %95 sure it is correct. It assumes the inputs are <= 10 digits.
After a lot of thinking I concluded that an inclusion/exclusion principle holds for 2,3,5,7 - 6,10 repeated numbers.
github.com/mdg583/AOC/t...
Working through these in #RStats. Nothing too interesting about this solution, used a convolution with a matrix kernel
github.com/mdg583/AOC/t...
Working through these in #RStats. Nothing too interesting about this solution, used a convolution with a matrix kernel
github.com/mdg583/AOC/t...
x = readr::read_lines("input.txt")
xdir = substring(x,1,1)
xlen = as.numeric(substring(x,2))
xcum = cumsum(c(50,xlen*ifelse(xdir=="L",-1,1)))
sum(
0.5 * abs(diff(floor(xcum / 100))) +
0.5 * abs(diff(floor((xcum-1) / 100)))
)
x = readr::read_lines("input.txt")
xdir = substring(x,1,1)
xlen = as.numeric(substring(x,2))
xcum = cumsum(c(50,xlen*ifelse(xdir=="L",-1,1)))
sum(
0.5 * abs(diff(floor(xcum / 100))) +
0.5 * abs(diff(floor((xcum-1) / 100)))
)