My issue
hidden test case
My code
def check_divisibility(Z, X, Y):
# Check if Z is divisible only by X
if Z % X == 0 and Z % Y != 0:
return "Z is divisible only by X."
# Check if Z is divisible only by Y
if Z % Y == 0 and Z % X != 0:
return "Z is divisible only by Y."
# Check if Z is divisible by both X and Y
if Z % X == 0 and Z % Y == 0:
return "Z is divisible by both X and Y."
# Check if Z is divisible by neither X nor Y
if Z % X != 0 and Z % Y != 0:
return "Z is divisible by neither X nor Y."
# In case none of the above conditions are met (shouldn't happen)
return "Z does not meet any specific condition."
# Example usage
Z = 12
X = 3
Y = 4
print(check_divisibility(Z, X, Y))
Learning course: Design and Analysis of Algorithms
Problem Link: Problem(Farm animals) - Solve sub-components in Design and Analysis of Algorithms