Changeable words

var file = File("unixdict.txt")

if (!file.exists) {
    require('LWP::Simple')
    say ":: Retrieving #{file} from internet..."
    %S<LWP::Simple>.mirror(
        'https://web.archive.org/web/20180611003215if_/' +
        'http://www.puzzlers.org:80/pub/wordlists/unixdict.txt',
    'unixdict.txt')
}

var words  = file.read.words
var bucket = Hash()
var count = 0

words.each {|word|

    var len = word.len

    len > 11 || next
    bucket{len} := []

    bucket{len}.each{|prev|
        if (prev ^ word -> count("\0") == len-1) {
            printf("%2d: %20s <-> %s\n", ++count, prev, word)
        }
    }
    bucket{len} << word
}

Output:

Last updated

Was this helpful?