[ Download the Python program/view it as text · View the output · Nick's poems ]
#!/usr/bin/env python

"""The First M Numbers Classified in Alphabetical Order

Props to Claude Closky, the Romans, and computers.
Happy New Year from Nick Montfort. Have a great MMXIII."""

def romanize(arabic):
    """Return the roman numeral representing n.
    Should work for n in (1, 4999)."""
    numerals = [(1000, 'M'), (500, 'D'), (100, 'C'), 
                (50, 'L'), (10, 'X'), (5, 'V'), (1, 'I')]
    smaller = {1000: (100, 'C'), 500: (100, 'C'),
               100: (10, 'X'), 50: (10, 'X'), 10: (1, 'I'),
               5: (1, 'I')}
    roman = ''
    for (value, numeral) in numerals:
        roman += (arabic / value) * numeral
        arabic -= (arabic / value) * value
        if value in smaller and arabic >= value - smaller[value][0]:
            roman += smaller[value][1] + numeral                
            arabic -= (value - smaller[value][0])
    return roman

nums = []
for i in range(1, 1001):
    nums += [romanize(i)]
nums.sort()
print ' '.join(nums)