From e2d0ee960837bca9ad2e85a88be5a0375e112ee5 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Fri, 20 Sep 2024 09:41:59 +0100 Subject: Add Python solution to challenge 069 --- challenge-069/paulo-custodio/python/ch-1.py | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 challenge-069/paulo-custodio/python/ch-1.py (limited to 'challenge-069/paulo-custodio/python/ch-1.py') diff --git a/challenge-069/paulo-custodio/python/ch-1.py b/challenge-069/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..6fa58d6338 --- /dev/null +++ b/challenge-069/paulo-custodio/python/ch-1.py @@ -0,0 +1,34 @@ +#!/usr/bin/env perl + +# Challenge 069 +# +# TASK #1 > Strobogrammatic Number +# Submitted by: Mohammad S Anwar +# A strobogrammatic number is a number that looks the same when looked at upside +# down. +# +# You are given two positive numbers $A and $B such that 1 <= $A <= $B <= 10^15. +# +# Write a script to print all strobogrammatic numbers between the given two +# numbers. +# +# Example +# Input: $A = 50, $B = 100 +# Output: 69, 88, 96 + +import sys + +A, B = map(int, sys.argv[1:3]) +out = [] + +def is_strobogrammatic(n): + if not all(c in '0689' for c in str(n)): + return False + inv = str(n).translate(str.maketrans('69', '96')) + return int(inv[::-1]) == n + +for n in range(A, B + 1): + if is_strobogrammatic(n): + out.append(n) + +print(", ".join(map(str, out))) -- cgit From 5354c57e27196ca67ad5e821b3e999867c1aaef3 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Fri, 20 Sep 2024 10:23:09 +0100 Subject: Add Python solution to challenge 070 --- challenge-069/paulo-custodio/python/ch-1.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'challenge-069/paulo-custodio/python/ch-1.py') diff --git a/challenge-069/paulo-custodio/python/ch-1.py b/challenge-069/paulo-custodio/python/ch-1.py index 6fa58d6338..ca37f65b7d 100644 --- a/challenge-069/paulo-custodio/python/ch-1.py +++ b/challenge-069/paulo-custodio/python/ch-1.py @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/usr/bin/env python3 # Challenge 069 # -- cgit