df <- readLines("input.txt")
Warning in readLines("input.txt"): incomplete final line found on 'input.txt'
dt <- df dt <- dt[!grepl("(ab)|(cd)|(pq)|(xy)", dt)] dt <- dt[grepl("(\\w*[aeuio]\\w*){3,}", dt)] dt <- dt[grepl("(.)\\1+", dt)] length(dt)
[1] 255
dt <- df dt <- dt[grepl("(..).*(\\1)", dt, perl = TRUE)] dt <- dt[grepl("(.)(.)(\\1)", dt, perl = TRUE)] length(dt)
[1] 55