#๐ Not getting the desired output for a codeforce problem (rectangle cutting).
11 messages ยท Page 1 of 1 (latest)
@deft glade
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
it will be helpful if someone can point me the mistake i made in this code to solve the codeforces problem :-
https://codeforces.com/problemset/problem/1928/A
t = int(input("Enter the no of test cases:- "))
print("Enter the lengths and breadth of the rectangle:- ",end="\n")
for i in range(t):
tuple_ = eval(input())
a, b = tuple_
val = []
case = 0
if a % 2 == 0 and b % 2 != 0:
if a != 2*b and b != a/2:
val.append(True); print(True)
else:
val.append(False); print(False)
elif b % 2 == 0 and a % 2 != 0:
if a != b/2 and b != 2*a:
val.append(True); print(True)
else:
val.append(False); print(False)
elif a % 2 == 0 and b % 2 == 0:
if case == 0:
if a != 2*b and b != a/2:
val.append(True); print(True)
else:
val.append(False); print(False)
case = 1
if case == 1:
if a != b/2 and b != 2*a:
val.append(True); print(True)
else:
val.append(False); print(False)
print(val)
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
It's difficult for me to read on mobile
@deft glade
and instead of doing the check like this, I would suggest checking if min(a, b) is divisible by 2, if not then check the larger number is two times the smaller number
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.