2016-03: Squares With Three Sides

library(data.table)
dtM <- fread("input.txt", header = FALSE) |>
  `colnames<-`(c(letters[1:3]))

Part 1

dt <- dtM
dt$valid <- ifelse(dt$a + dt$b > dt$c &
                     dt$a + dt$c > dt$b &
                     dt$b + dt$c > dt$a, TRUE, FALSE)
table(dt$valid)["TRUE"]
TRUE 
 862 

Part 2

dt <- dtM
dt <- data.table(t(matrix(c(dt$a, dt$b, dt$c), 3, nrow(dt)))) |>
  `colnames<-`(c(letters[1:3]))

dt$valid <- ifelse(dt$a + dt$b > dt$c & 
                     dt$a + dt$c > dt$b &
                     dt$b + dt$c > dt$a, TRUE, FALSE)
table(dt$valid)["TRUE"]
TRUE 
1577