Advent of Code 2020

1a.R 315B

1234567891011121314
  1. # Target: find two numbers that sum to 2020, submit them multiplied together
  2. # Get input
  3. input <- read.csv("input1a.csv", header=F)[[1]]
  4. # Find the value that would have to be present for them to add to 2020
  5. alt <- 2020 - input
  6. # Returns the three numbers
  7. vals <- input[input %in% alt]
  8. vals
  9. # 719796
  10. prod(vals)