code golf for https://fosstodon.org/@coolbutuseless/113668013712145841
x <- c("apple", "app", "aptitude")
mx <- max(nchar(x))
pool <- c(letters, LETTERS)
flat <- function(x) {
c(x, rep(0L, mx - length(x)))
}
## match letter to number and flatten to mx, then process for uniqueness by column (possibly could use rowSums to avoid apply loop)
which(apply(do.call(rbind, lapply(strsplit(x, ""), \(.x) flat(match(.x, pool)))), 2, \(.x) length(unique(.x))) > 1)[1L] + 1
[1] 4
is it faster if we avoid apply()?
(none of this is really tested, fwiw)