Most type-II restriction enzymes recognise sites that are reverse-complement palindromes — EcoRI
cuts GAATTC, whose reverse complement is also GAATTC. That symmetry is why the enzyme's homodimer
can bind either strand identically, and recognising it is fundamental to cloning and RFLP work.
Statement
A DNA string is a reverse-complement palindrome if it is equal to its own reverse complement.
Given a DNA string, decide whether it is one.
Print YES if it is, or NO if it is not.
(The verdict is deliberately YES/NO rather than a boolean, because Python prints True
while R prints TRUE — a language-neutral token keeps the problem solvable in both.)
Input — read from standard input
| Variable | Type | Description |
|---|---|---|
s
line 1
|
str |
The candidate restriction site
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 exactly YES or NO, on one line
Sample Cases
GAATTC
YES
AAAA
NO
Submit also runs your code against 5 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.
Constraints
1 <= length(s) <= 1000- Uppercase
A,C,G,Tonly - Odd-length strings can never be reverse-complement palindromes
Further Reading
- Reuse your reverse-complement routine and compare the result to the input.
- Print the token exactly:
YESorNO, uppercase, nothing else.
My Notes
Private to you. Saved to your account, separate from your code.
- Ctrl + Enter run · Ctrl + Shift + Enter submit