── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0 ✔ purrr 0.3.5
✔ tibble 3.1.8 ✔ dplyr 1.0.10
✔ tidyr 1.2.1 ✔ stringr 1.4.1
✔ readr 2.1.3 ✔ forcats 0.5.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
02: I Was Told There Would Be No Math
Part 1
Part 2
tmp <- dt %>%
.[, c("l", "w", "h") := .(V1 * V2, V2 * V3, V1 * V3)]
tmp <- tmp[, c("l", "w", "h") := .(V1, V2, V3)] %>%
.[, max := apply(dt[, .(l, w, h)], 1, max)] %>%
rowwise() %>%
mutate(test = list(c(l, w, h)))
tmp$min1 <- t(data.frame(sapply(tmp$test, sort)))[,1]
tmp$min2 <- t(data.frame(sapply(tmp$test, sort)))[,2]
tmp <- data.table::data.table(tmp)[,rib := ((2*min1 + 2*min2) + (V1 * V2 * V3))]
sum(tmp$rib, na.rm = TRUE)
[1] 3812909