DNA is double-stranded and antiparallel, so any tool touching real genomic data — primer design,
aligners like BWA and Bowtie, restriction mapping — must be able to compute the reverse
complement to check both strands. PCR primer design cannot be done correctly without it.
Statement
Given a DNA string, return its reverse complement: take the complement of each base
(A to T, T to A, C to G, G to C), then reverse the result.
Print the reverse complement on one line.
Input — read from standard input
Variable
Type
Description
s
line 1
str
The DNA sequence to reverse-complement
1 <= len(s) <= 1000, uppercase A, C, G, T only
These variables are already read for you in the starter code on the right.
Output
str
the reverse complement of s, on one line
Sample Cases
Sample 1
Input
AAAACCCGGT
Expected Output
ACCGGGTTTT
Complement of AAAACCCGGT is TTTTGGGCCA; reversing gives ACCGGGTTTT.
Sample 2
Input
ACGT
Expected Output
ACGT
A palindromic case — its own reverse complement.
Submit also runs your code against 4 hidden test cases.
Hidden inputs are never shown — if one fails you'll get its number and a description of the
mismatch, not the data.