What does print("YNEOS"[(w%2)|(w<=2)::2])?
I was just trying to solve this problem on Codeforces: Check whether it's possible to split a number w (1 ≤ w ≤ 100) into a sum of 2 even numbers. I solved the problem like this: n = int(input()) if (n-2)%2 == 0 and n > 2: print("YES") else: print("NO") Next, I looked at other solutions for the problem. Then I found this solution: w = int(input()) print("YNEOS"[(w%2)|(w<=2)::2]) It took half of the time than mine. Unfortunately I am not understanding: how it is working, and why it is faster than mine. I am a beginner in Python. So it would help me to get a proper explanation.
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.