Given a verbal question in a deductive reasoning style, is it possible to solve in python?
If the potential variables are never assigned a real world/solid value rather a distance from each other, can it be done? Meaning there is no fixed starting point (i.e. x = 1).
I have tried assigning all variables a 0
to start with and then building from there, but I think this isn't right.
I have an example question here to try, and I have included what I kind of imagine the code to look like. I know its not written in the perfect PEP8 style so please don't criticize that...It is more of a possible example of how I have tried solving the question.
"""Denise arrived at the party 1 hour later than Kylie and 30 minutes before James.
Melissa arrived at the party 30 minutes earlier than Denise and 45 minutes earlier than Sarah.
Is the statement below True?
When James arrived, he found both Melissa and Denise enjoying the party and learned that Sarah
arrived at the party 30 minutes prior to him."""
def deductive_reasoning():
kylie = 0
james = 0
denise = 0
sarah = 0
melissa = [denise - 30, sarah - 45]
denise = [kylie + 60, james - 30]
if (james > melissa[0] and melissa[1]) and (james > denise[0] and denise[1]) and (sarah == james - 30):
print("That is true")
else:
print("That is not true")
deductive_reasoning()
def deductive_reasoning():
# "Denise arrived at the party 1 hour later than Kylie"
# Some time point needs to be pinned, so we'll arbitrarily pin Kylie
kylie = 0
# and set Denise relative to Kylie
denise = 60
# "and 30 minutes before James"
james = denise + 30
# "Melissa arrived as the party 30 minutes earlier that Danise"
melissa = denise - 30
# "and 45 minutes earlier than Sarah"
sarah = melissa + 45
# Query: Did James arrive at a time after both Melissa and Denise
# and 30 minutes after Sarah?
return james > melissa and james > denise and james - sarah == 30
It's possible to write a function which encodes that specific logic puzzle. But did the software solve the puzzle or did the programmer solve it in the process of converting the puzzle to code? Personally, I'd say it was the programmer.