Skip to content

Instantly share code, notes, and snippets.

@shudarshon
Created January 1, 2019 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shudarshon/283d09aa059fe5005340635e2b019924 to your computer and use it in GitHub Desktop.
Save shudarshon/283d09aa059fe5005340635e2b019924 to your computer and use it in GitHub Desktop.
Codewars "Complementary DNA" bash solution
#!/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