Preparing git repo for final project
This commit is contained in:
28
problems/pset1/deep/deep.py
Normal file
28
problems/pset1/deep/deep.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import re
|
||||
answer_regex = re.compile(r"\s*(42|forty[ -]?two)\s*", re.IGNORECASE)
|
||||
|
||||
def ifelse_answer():
|
||||
answer = input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t")
|
||||
answer = answer.strip()
|
||||
answer = answer.replace('-', '')
|
||||
answer = answer.replace(' ', '')
|
||||
answer = answer.lower()
|
||||
if answer in ('42', 'fortytwo'):
|
||||
print("Yes")
|
||||
else:
|
||||
print("No")
|
||||
|
||||
|
||||
def regex_answer():
|
||||
print('Yes'
|
||||
if answer_regex.match(
|
||||
input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t"))
|
||||
else 'No')
|
||||
|
||||
|
||||
def oneliner():
|
||||
print({True: 'Yes', False: 'No'}[input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t").lower().strip() in ('42', 'fortytwo', 'forty two', 'forty-two')])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
regex_answer()
|
Reference in New Issue
Block a user