Andrew Jorgensen
It's better than bad, it's good!

What's It Worth??

My 6th grader had some homework that assigned values from -13 to 12 to letters and asked the student to sum the values of letters in some words. It also asked some questions I thought were too hard.

I'm assuming by value they don't mean magnitude.
Please let me know if you have some clever strategy for finding answers to "find a word" questions. Short of that, here's a brute force answer in Python.

The Code

# These are the letters a-z
from string import ascii_lowercase as letters

# Assign values to each letter as given in the assingment
# stored as a dictionary with a: -13 and so on.
v = dict(zip(letters, range(-13, 13)))

# To store tuples of the calculated values
calculations = []

# "words" is a word list with one English word per line
with open('/usr/share/dict/words', 'r') as words:
    for word in words:
        # Each line has a '\n' newline at the end, so strip it
        word = word.strip()
        # Ignore words that have capital letters or other characters
        if not set(word).issubset(set(letters)):
            continue
        # Enumerate the assigned values for letters in the word
        values = list((v.get(l, 0) for l in word))
        # String together a calculation (like +5-2+3...)
        calculation = ''.join(('%+d' % v for v in values))
        # Add a tuple of the word, the "show your work", and the total
        calculations.append((word, calculation, sum(values)))

# Sort the calculations by word length
calculations = sorted(calculations, key=lambda a: len(a[0]))

print('Find a word that has a value of 18:')
# Let's grab the longest five and the shortest 10
eighteens = list((c for c in calculations if c[2] == 18))
for answer in eighteens[:10] + eighteens[-10:]:
    print('%s: %s=%d' % answer)

print('Find a word that has a value of -16:')
# Let's grab the longest five and the shortest 10
minussixteens = list((c for c in calculations if c[2] == -16))
for answer in minussixteens[:10] + minussixteens[-10:]:
    print('%s: %s=%d' % answer)

# The next two questions are about values of 5
fives = list((c for c in calculations if len(c[0]) == 5))

# Sort from highest value to lowest
fives = sorted(fives, key=lambda a: - a[2])

print('Find the highest value 5 letter word you can:')
for answer in fives[:10]:
    print('%s: %s=%d' % answer)

print('Find the lowest value 5 letter word you can:')
for answer in fives[-10:]:
    print('%s: %s=%d' % answer)

You can also try it on Replit.

The Answers

Here are some of the results.

Find a word that has a value of 18.

spy: +5+2+11=18
unresponsively: +7+0+4-9+5+2+1+0+5-5+8-9-2+11=18

Find a word that has a value of -16:

dim: -10-5-1=-16
weatherstripping: +9-9-13+6-6-9+4+5+6+4-5+2+2-5+0-7=-16

Find the highest value 5 letter word you can:

muzzy: -1+7+12+12+11=41

Find the lowest value 5 letter word you can:

baaed: -12-13-13-9-10=-57