This is another problem that I'm having that goes along with a previous question that i asked.
The basic program is that a person puts in two DNA strings that consist of only A,T,C,or G.

DNA strings work to where A can only match with T, and G can only match with C.

So the program needs to look at each individual character in the string and make sure that the corresponding character in the other string matches...

so if:

With that data everything corresponds correctly except the last two characters. My desire is to have my program look at DNA1 and make sure that DNA2 matches correctly, and if it doesn't i want it to correct it so that it does. So the program would run and then the output would be:

I've tried using for loops along with nested if statements but have been unable to get anything to work correctly...
if anyone has any ideas about how i might be able to achieve this, i would be very grateful for your input. Thanks

9 Years
Discussion Span
Last Post by Salem

Nothing was wrong with the response to my previous thread it was very helpful in making sure that the DNA strands didn't contain any characters that weren't C,G,T,or A.

Now that I know that those two strings (DNA1 and DNA2) only contain those characters, i want the program to automatically find when a character from DNA2 doesn't match the same subscript character in DNA1, and then correct it.

So if DNA1[2] = A
and DNA2[2] = G

then i want the program to see that these two don't match and automatically change DNA[2] so that it equals T... because only T can match A, and only G can match C.

I hope this better explains my predicament.


So again, just a for loop to step along the strings then, comparing each DNA1[i] with DNA2[i]

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.