aboutsummaryrefslogtreecommitdiff
path: root/challenge-118/paulo-custodio/python/ch-1.py
blob: b7652634d369fa86ceca88609496f174340ed0eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3

# Challenge 118
#
# TASK #1 - Binary Palindrome
# Submitted by: Mohammad S Anwar
# You are given a positive integer $N.
#
# Write a script to find out if the binary representation of the given integer
# is Palindrome. Print 1 if it is otherwise 0.
#
# Example
# Input: $N = 5
# Output: 1 as binary representation of 5 is 101 which is Palindrome.
#
# Input: $N = 4
# Output: 0 as binary representation of 4 is 100 which is NOT Palindrome.

import sys

N = int(sys.argv[1])
bits = "{:b}".format(N)
rbits = bits[::-1]
if bits==rbits:
    print(1)
else:
    print(0)