Created
January 1, 2019 12:40
-
-
Save shudarshon/283d09aa059fe5005340635e2b019924 to your computer and use it in GitHub Desktop.
Codewars "Complementary DNA" bash solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# problem url https://www.codewars.com/kata/complementary-dna/shell | |
i=1 | |
c="" | |
while [ $i -le ${#1} ] | |
do | |
var=$(echo $1 | cut -c $i) | |
if [ $var == "A" ] | |
then | |
x="T" | |
elif [ $var == "T" ] | |
then | |
x="A" | |
elif [ $var == "C" ] | |
then | |
x="G" | |
elif [ $var == "G" ] | |
then | |
x="C" | |
fi | |
c="$c$x" | |
((i++)) | |
done | |
echo "${c}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment