Make Number Even
Python
Medium
3 views
Problem Description
Read one integer n. In one move you can add 1 or subtract 1. Output minimum moves needed to make n even.
Input Format
One integer n.
Output Format
One integer moves.
Official Solution
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
sys.stdout.write('0' if n%2==0 else '1')
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!