Skip to content

Instantly share code, notes, and snippets.

@pqcfox
Created January 19, 2015 06:04
Show Gist options
  • Save pqcfox/9e9766887d64668ceb3d to your computer and use it in GitHub Desktop.
Save pqcfox/9e9766887d64668ceb3d to your computer and use it in GitHub Desktop.
Adding together nicknames - mixed results may output...
import string
a = "fouric"
b = "nocyno"
name_sum = ""
name_difference_ab = ""
name_difference_ba = ""
alphabet = string.ascii_lowercase
for index in range(len(a)):
# Make sure to add one to convert to one-indexing.
a_index = alphabet.index(a[index]) + 1
b_index = alphabet.index(b[index]) + 1
# Then, subtract one to go back into zero-indexing.
sum_index = a_index + b_index - 1
difference_ab_index = a_index - b_index - 1
difference_ba_index = b_index - a_index - 1
# Use moduluo 26 to keep within alphabet
name_sum += alphabet[sum_index % 26]
name_difference_ab += alphabet[difference_ab_index % 26]
name_difference_ba += alphabet[difference_ba_index % 26]
print name_sum
print name_difference_ab
print name_difference_ba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment