From 84a70945becac110141dc1ccc10b50ec34d767a3 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:32:12 +0300 Subject: [PATCH 1/5] adding the dna algorithm --- strings/dna.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 strings/dna.py diff --git a/strings/dna.py b/strings/dna.py new file mode 100644 index 000000000000..b08e6205be2a --- /dev/null +++ b/strings/dna.py @@ -0,0 +1,27 @@ +import re +import string + + +def dna(dna: str) -> str: + + """ + https://en.wikipedia.org/wiki/DNA + Returns the second side of a DNA strand + + >>> dna("GCTA") + 'CGAT' + >>> dna("ATGC") + 'TACG' + >>> dna("CTGA") + 'GACT' + >>> dna("GFGG") + 'Invalid Strand' + """ + + r = len(re.findall("[ATCG]", dna)) != len(dna) + val = dna.translate(dna.maketrans("ATCG", "TAGC")) + return "Invalid Strand" if r else val + + +if __name__ == "__main__": + __import__("doctest").testmod() From a30901839f0509d28a4a00953f520a905b8fde94 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:42:54 +0300 Subject: [PATCH 2/5] following bot recommendations following bot recommendations for the indentation --- strings/dna.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/dna.py b/strings/dna.py index b08e6205be2a..e0a0f6efc7e0 100644 --- a/strings/dna.py +++ b/strings/dna.py @@ -24,4 +24,4 @@ def dna(dna: str) -> str: if __name__ == "__main__": - __import__("doctest").testmod() + __import__("doctest").testmod() From 6d02a26b65e00203a65dc288642db647bc949f14 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:51:19 +0300 Subject: [PATCH 3/5] following bot recommendations following bot recommendations regarding indentation [ again ] --- strings/dna.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/strings/dna.py b/strings/dna.py index e0a0f6efc7e0..c276da1e7001 100644 --- a/strings/dna.py +++ b/strings/dna.py @@ -4,24 +4,24 @@ def dna(dna: str) -> str: - """ - https://en.wikipedia.org/wiki/DNA - Returns the second side of a DNA strand - - >>> dna("GCTA") - 'CGAT' - >>> dna("ATGC") - 'TACG' - >>> dna("CTGA") - 'GACT' - >>> dna("GFGG") - 'Invalid Strand' - """ + """ + https://en.wikipedia.org/wiki/DNA + Returns the second side of a DNA strand + + >>> dna("GCTA") + 'CGAT' + >>> dna("ATGC") + 'TACG' + >>> dna("CTGA") + 'GACT' + >>> dna("GFGG") + 'Invalid Strand' + """ - r = len(re.findall("[ATCG]", dna)) != len(dna) - val = dna.translate(dna.maketrans("ATCG", "TAGC")) - return "Invalid Strand" if r else val + r = len(re.findall("[ATCG]", dna)) != len(dna) + val = dna.translate(dna.maketrans("ATCG", "TAGC")) + return "Invalid Strand" if r else val if __name__ == "__main__": - __import__("doctest").testmod() + __import__("doctest").testmod() From d1d85179e41162d00fe073364a5fd6bd59a4c571 Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:54:30 +0300 Subject: [PATCH 4/5] following bot recommendations following bot recommendations regarding indentation [ again. ] --- strings/dna.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/dna.py b/strings/dna.py index c276da1e7001..9a9672756aec 100644 --- a/strings/dna.py +++ b/strings/dna.py @@ -7,7 +7,7 @@ def dna(dna: str) -> str: """ https://en.wikipedia.org/wiki/DNA Returns the second side of a DNA strand - + >>> dna("GCTA") 'CGAT' >>> dna("ATGC") From 5dd8f98053e132dcbe51629ea3869c6e80cf379c Mon Sep 17 00:00:00 2001 From: Margaret <62753112+meg-1@users.noreply.github.com> Date: Sat, 13 Aug 2022 14:59:18 +0300 Subject: [PATCH 5/5] following bot recommendations following bot recommendations. --- strings/dna.py | 1 - 1 file changed, 1 deletion(-) diff --git a/strings/dna.py b/strings/dna.py index 9a9672756aec..46e271d689db 100644 --- a/strings/dna.py +++ b/strings/dna.py @@ -1,5 +1,4 @@ import re -import string def dna(dna: str) -> str: