Created
July 28, 2017 10:50
-
-
Save minerscale/ab6e3009f0eb7feb94b891b8a72bcb36 to your computer and use it in GitHub Desktop.
Solution to a problem
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
def findVicinals(words): | |
word = words.lower() | |
VicinalLetters = [] | |
for i in word: | |
test = (ord(i)+59)%26 | |
for j in word: | |
othertest = (ord(j)+59)%26 | |
if ((test + 1)%26 == othertest or (test - 1)%26 == othertest): | |
VicinalLetters.append(test) | |
break | |
if (len(VicinalLetters) == len(word)): | |
return (1) | |
elif (len(VicinalLetters) == 0): | |
return (2) | |
else: | |
return (0) | |
while (True): | |
string = input ("Line: ") | |
if (string == ""): | |
break | |
wordlist = string.split() | |
vicinals = [] | |
nonVicinals = [] | |
for word in wordlist: | |
isVicinal = findVicinals(word) | |
if (isVicinal == 1): | |
vicinals.append(word) | |
elif (isVicinal == 2): | |
nonVicinals.append(word) | |
if (vicinals != []): | |
print ("Vicinals:",end="") | |
for word in vicinals: | |
print (" " + word,end = "") | |
print ("") | |
if (nonVicinals != []): | |
print ("Non-vicinals:",end="") | |
for word in nonVicinals: | |
print (" " + word,end = "") | |
print ("") | |
PickledCow
commented
Jul 28, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment