Will.Whim

A weblog by Will Fitzgerald

Forwords and Backwords

A ‘forword’ is a word in which all the letters are in alphabetical order, with no repeats. Here are the longest ones I could find, using a particular word list I have on my computer (all six letters):

abhors
almost
begins
begirt
beknot
bijoux
biopsy
chimps
chinos
chintz
dehort
ghosty

If you allow repeats, there’s also ‘beefily’ and ‘billowy’ (at seven letters).

Backwords are the same, in reverse. The longest are (at seven letters):

sponged
wronged

If you allow repeats, there’s also “trollied,” at eight letters.

QuickNDirty Ruby code:

def inorder? (word)
    word=word.downcase
    fmt = "a"*word.length
    srt = (word.unpack(fmt)).sort.uniq.reverse
    word==(srt.pack("a"*srt.length))
end

while (line = gets) do
  line.chomp!
  puts line if inorder?(line) and (line.length >= 7)
end
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: