We disguised the two partners of some famous duos by subtracting their names. If the difference of David and Goliath is -C -N J * C -T -H, then who are these duos?

  1. A -T I B F

  2. -P -N R D -M N

  3. D * C N -T L

  4. -J Q -O G E -C -H -Y

  5. -A C -K J D E

  1. Mario and Luigi

  2. Batman and Robin

  3. Laurel and Hardy

  4. Itchy and Scratchy

  5. Bonnie and Clyde

Assignment

We assign each letter (str; uppercase and lowercase) a value (int) that corresponds to its position in the alphabet (A=1, B=2, C=3, …, Z=26). We consider the asterisk (*) as an extra letter with a value of zero (0).

The difference of two letters is a string (str) determined by first subtracting the values of those two letters. This yields a value between -26 and 26, which we represent as:

A word is a string (str) consisting of one or more letters (uppercase or lowercase; no asterisks). To determine the difference of two words, we first append asterisks (*) to the end of the shortest word until both words have equal length. The difference is then a tuple (tuple) containing the differences of the two letters at corresponding positions in the two words. The length of this tuple is therefore equal to the length of the longest word.

Your task:

Example

In the following interactive session we assume the text file words.txt1 to be located in the current directory.

>>> diff2value('*')
0
>>> diff2value('A')
1
>>> diff2value('-t')
-20

>>> value2diff(0)
'*'
>>> value2diff(1)
'A'
>>> value2diff(-20)
'-T'

>>> disguise('Mario', 'Luigi')
('A', '-T', 'I', 'B', 'F')
>>> disguise('Batman', 'Robin')
('-P', '-N', 'R', 'D', '-M', 'N')
>>> disguise('David', 'Goliath')
('-C', '-N', 'J', '*', 'C', '-T', '-H')

>>> partner('Mario', ('A', '-T', 'I', 'B', 'F'))
'LUIGI'
>>> partner('Batman', ('-P', '-N', 'R', 'D', '-M', 'N'))
'ROBIN'
>>> partner('David', ('-C', '-N', 'J', '*', 'C', '-T', '-H'))
'GOLIATH'

>>> trace(('A', '-T', 'I', 'B', 'F'), 'words.txt2')
{('MARIO', 'LUIGI')}
>>> trace(('-P', '-N', 'R', 'D', '-M', 'N'), 'words.txt3')
{('BATMAN', 'ROBIN')}
>>> trace(('-C', '-N', 'J', '*', 'C', '-T', '-H'), 'words.txt4')
{('DAVID', 'GOLIATH')}
>>> trace(('A', '-Q', 'I', '-A', '*', '*'), 'words.txt5')
{('BARREN', 'ARISEN'), ('CARSON', 'BRITON'), ('HANSEL', 'GRETEL')}

Epilogue

The title of this assignment refers to the movie Hidden Figures6 (2016), telling the true story of scientists Katherine Johnson7 and her two colleagues Dorothy Vaughan8 and Mary Jackson9. Three women who worked in the West Area Computing unit at NASA Langley Research Center10 — an all-female African-American team that played an important role in the space race. Thanks to their calculations, American spaceman John Glenn succeeded to orbit Earth in 1962 as the first American.

Hidden Figures
Theatrical release poster of the movie Hidden Figures (2016).
Katherine Johnson
This cartoon by Steve Breen for the San Diego Union Tribune was a beautiful tribute dedicated to Katherine Johnson at her death back in February 2020.