Find words whose first and last three letters are equal

File("unixdict.txt").open_r.each {|word|
    word.len > 5 || next
    if (word.ends_with(word.first(3))) {
        say word
    }
}

Output:

antiperspirant
calendrical
einstein
hotshot
murmur
oshkosh
tartar
testes

Last updated