[Tutor] (no subject)

singh000taran at gmail.com
Wed Mar 24 14:39:27 EDT 2021


You've saved the password to access your Bitcoins on your personal
computer. You have created an application that encrypts the password. To
decrypt, you need to perform an operation between two integers, say A and
B, as described below - 1) Let X and Y be the numbers obtained by REVERSING
A and B. For example, the reverse of 123 is 321, and the reverse of 320 is
23 (leading zeroes are discarded) 2) If both X and Y are PRIME, then the
answer is X + Y 3) If EXACTLY ONE of X and Y is PRIME, then the answer is A
+ B 4) Otherwise, the answer is A * B Your task is to write a program to
help you perform this operation. Input: Two COMMA-separated integers A and
B. There can be any number of white-spaces in the input. Output : A single
integer that is the result of applying the operation described above on the
input integers. Constraints: 1≤A,B≤100001≤A,B≤10000 Example: Input: 142
,123 Output: 265 Explanation : The reverse of 142 is 241 (prime) and that
of 123 is 321 (not prime). Hence the answer is A + B = 142 + 123 = 265
IMPORTANT : Make sure your code is modular i.e. you REUSE as much of the
code as possible USING FUNCTIONS. You may LOSE MARKS if this guideline is
not followed.

My code is not working. How to solve it

A, B = int(input())

rev1 = A[::-1]
rev2 = B[::-1]

X = rev1
Y = rev2

qw = min(X, Y)
for i in range(1, qw+1):
    if X&i == 0 and Y%i == 0:
    hcf = i
if hcf == 1:
    print(X+Y)

elif:
    for j in range(2, X):
        if X%j == 0 or Y%j == 0:
            print(A+B)

else:
    print(A*B)


More information about the Tutor mailing list