For the below python statement:
[redacted] I am meant to find the simplest logically equivalent formula. That is...remove a logical connectives such as not, and, or while still making the formula logically equivalent as the one given.
So I plugged in the above formula to a python file and gave it some values (range from -5 to 5). This is the code:
print("------default question---------")
def range1(start, end):
return range(start, end+1)
for y in range1 (-5,5):
if ~([redacted]):
print(y)
else:
print("{} and {}".format("Missed", y))
And I got these numbers:
-5
-4
-3
-2
-1
0
1
2
3
4
5
The first thing that I did from here was to remove the NOT symbol and flip all the logical operators.
So this is the transformed code:
print("------opposite of question---------")
def range1(start, end):
return range(start, end+1)
for y in range1 (-5,5):
if ([redacted])):
print(y)
else:
print("{} {}".format("Missed", y))
which gave me the result:
-5
-4
-3
-2
-1
0
Missed 1
Missed 2
Missed 3
Missed 4
Missed 5
I've tried various test cases but to no avail, I was getting more confused from this small problem.
Would love if someone could point me in the right direction. Cheers :)
At the original statement, you are checking the numbers
y <= 1for divisibility by 2:y <= 1 & y % 2 == 0- you can not just change the inequality toy > 1and leave the divisibility check like thisy > 1 & y % 2 != 0, because that is now checking other numbers. Not to mention, that&should also be a|by your logic, but that still doesn't fix the problem of checking other numbers.