-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalphabetSoup.py
30 lines (22 loc) · 1.21 KB
/
alphabetSoup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import time
def checkAlphabetSoup(message, alphabet):
message_list = list(message) # convert the message into an array
alphabet_list = list(alphabet) # convert the alphabet taken from the bowl into an array
is_included = True # boolean variable for checking the state of program
# checking if the message is not empty
if len(message_list) > 0:
# itrating into the list of message chars
for msg_char in message_list:
# checking if the current character of message is included to alphabet bowl array
if msg_char in alphabet_list:
alphabet_list.remove(msg_char) # remove the alphabet_list the character that have been found
else:
is_included = False # if the current character of message is included to alphabet bowl array then change the state of variable
break # stop iterating
else:
is_included = False # change the state because the message is empty
return is_included
if __name__ == "__main__":
start_time = time.time()
print(checkAlphabetSoup("annastasia", "basnkaqltadlhflvkbaqqqqfdjwertyuioyusiofgnhjk"))
print("Execution time is: %s seconds " % (time.time() - start_time))