Advent of code Day 11

Goal: Evaluate the optimal path to move object on a map with constraint

Hack: There is an easy way to calculate the optimal path without the need to do it. Based on the fact that you need at least to move up 2 object and then down 1 (exept the first object)

Ref: http://adventofcode.com/2016/day/11


In [1]:
totalObject <- 10
ObjectFloor2 <- 4
ObjectFloor3 <- 4
totalObjectQ2 <- 14

In [2]:
Total <-       (2*(totalObject - 1) -1 )* 3
TotalFloor2 <- (2*(ObjectFloor2-1) -1) * 1 + 1
TotalFloor3 <- (2*(ObjectFloor3-1) -1) * 2 + 2
TotalQ2 <-     (2*(totalObjectQ2 - 1) -1 )* 3

In [3]:
cat("Q1- The mimimum amount of step is: ", Total - TotalFloor2 - TotalFloor3, '\n')
cat("Q2- The mimimum amount of step is: ", TotalQ2 - TotalFloor2 - TotalFloor3, '\n')


Q1- The mimimum amount of step is:  33 
Q2- The mimimum amount of step is:  57