From bf8032b503c262609b9b77e60ed56864a4546aed Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Fri, 29 Oct 2021 14:41:00 +0100 Subject: Add Python solution --- challenge-118/paulo-custodio/Makefile | 2 ++ challenge-118/paulo-custodio/python/ch-1.py | 27 +++++++++++++++++++++++++++ challenge-118/paulo-custodio/test.pl | 4 ---- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 challenge-118/paulo-custodio/Makefile create mode 100644 challenge-118/paulo-custodio/python/ch-1.py delete mode 100644 challenge-118/paulo-custodio/test.pl diff --git a/challenge-118/paulo-custodio/Makefile b/challenge-118/paulo-custodio/Makefile new file mode 100644 index 0000000000..c3c762d746 --- /dev/null +++ b/challenge-118/paulo-custodio/Makefile @@ -0,0 +1,2 @@ +all: + perl ../../challenge-001/paulo-custodio/test.pl diff --git a/challenge-118/paulo-custodio/python/ch-1.py b/challenge-118/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..b7652634d3 --- /dev/null +++ b/challenge-118/paulo-custodio/python/ch-1.py @@ -0,0 +1,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) diff --git a/challenge-118/paulo-custodio/test.pl b/challenge-118/paulo-custodio/test.pl deleted file mode 100644 index ba6c37260b..0000000000 --- a/challenge-118/paulo-custodio/test.pl +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env perl -use Modern::Perl; -use Test::More; -require '../../challenge-001/paulo-custodio/test.pl'; -- cgit