Created
July 30, 2017 01:18
-
-
Save PickledCow/ad1c4c86d611c5b605dd9c80cdc05877 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
letters = {"a" : "1", "b" : "2", "c" : "3", "d" : "4", "e" : "5", "f" : "6", "g" : "7", "h" : "8", "i" : "9", "j" : "10", "k" : "11", "l" : "12", "m" : "13", "n" : "14", "o" : "15", "p" : "16", "q" : "17", "r" : "18", "s" : "19", "t" : "20", "u" : "21", "v" : "22", "w" : "23", "x" : "24", "y" : "25", "z" : "26"} | |
blank = 0 | |
while blank == 0: | |
line = input("Line: ") | |
word = line.split() | |
lineNum = 0 | |
vicList = [] | |
nVicList = [] | |
if line == "": | |
blank = 1 | |
if blank == 0: | |
for i in range(len(word)): | |
worder = (word[lineNum]) | |
worderBackup = str(worder) | |
worder = str(worder).lower() | |
worder = sorted(worder) | |
worder = str("".join(worder)) | |
checkVic = 0 | |
error = 0 | |
for j in range(len(worder)): | |
if checkVic < len(worder) - 1: | |
if abs(int(letters[str(worder[checkVic])]) - int(letters[str(worder[checkVic + 1])])) == 1: | |
error += 1 | |
elif abs(int(letters[str(worder[checkVic])]) - int(letters[str(worder[checkVic + 1])])) == 25: | |
error += 1 | |
else: | |
error += 0 | |
elif checkVic == len(worder) - 1: | |
if abs(int(letters[str(worder[checkVic])]) - int(letters[str(worder[0])])) == 1: | |
error += 1 | |
elif abs(int(letters[str(worder[checkVic])]) - int(letters[str(worder[0])])) == 25: | |
error += 1 | |
else: | |
error += 0 | |
if error >= len(worder) / 2: | |
vicList.append(worderBackup) | |
elif error == 0: | |
nVicList.append(worderBackup) | |
checkVic += 1 | |
lineNum += 1 | |
vicList = str(" ".join(vicList)) | |
nVicList = str(" ".join(nVicList)) | |
if int(len(vicList)) > (0): | |
print("Vicinals: " + vicList) | |
else: | |
pass | |
if int(len(nVicList)) > (0): | |
print("Non-vicinals: " + nVicList) | |
else: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment