From 2bdf51703359ef35c7ec3829ee25be3e89c45490 Mon Sep 17 00:00:00 2001 From: Paulo Custodio Date: Tue, 9 Mar 2021 19:33:35 +0000 Subject: Add Lua and Python solutions to challenge 090 --- challenge-090/paulo-custodio/python/ch-1.py | 27 +++++++++++++++++++++++++++ challenge-090/paulo-custodio/python/ch-2.py | 24 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 challenge-090/paulo-custodio/python/ch-1.py create mode 100644 challenge-090/paulo-custodio/python/ch-2.py (limited to 'challenge-090/paulo-custodio/python') diff --git a/challenge-090/paulo-custodio/python/ch-1.py b/challenge-090/paulo-custodio/python/ch-1.py new file mode 100644 index 0000000000..0af71bfe29 --- /dev/null +++ b/challenge-090/paulo-custodio/python/ch-1.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +# Challenge 090 +# +# TASK #1 > DNA Sequence +# Submitted by: Mohammad S Anwar +# DNA is a long, chainlike molecule which has two strands twisted into a +# double helix. The two strands are made up of simpler molecules called +# nucleotides. Each nucleotide is composed of one of the four nitrogen-containing +# nucleobases cytosine (C), guanine (G), adenine (A) and thymine (T). +# +# You are given DNA sequence, +# GTAAACCCCTTTTCATTTAGACAGATCGACTCCTTATCCATTCTCAGAGATGTGTTGCTGGTCGCCG. +# +# Write a script to print nucleiobase count in the given DNA sequence. +# Also print the complementary sequence where Thymine (T) on one strand +# is always facing an adenine (A) and vice versa; guanine (G) is always +# facing a cytosine (C) and vice versa. + +import sys +import string + +seq = sys.argv[1] +compl = seq.translate(str.maketrans("TAGC", "ATCG")) + +print(len(seq)) +print(compl) diff --git a/challenge-090/paulo-custodio/python/ch-2.py b/challenge-090/paulo-custodio/python/ch-2.py new file mode 100644 index 0000000000..29efd0d507 --- /dev/null +++ b/challenge-090/paulo-custodio/python/ch-2.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Challenge 090 +# +# TASK #2 > Ethiopian Multiplication +# Submitted by: Mohammad S Anwar +# You are given two positive numbers $a and $b. +# +# Write a script to demonstrate Ethiopian Multiplication using the given numbers. + +import sys + +def mul(a,b): + mul = 0 + while True: + if (a & 1) != 0: + mul += b + if a <= 1: + break + a >>= 1 + b <<= 1 + return mul + +print(mul(int(sys.argv[1]), int(sys.argv[2]))) -- cgit