Challenge
You must write an encoder (and a separate decoder) which takes a string as input and outputs the string encoded in the style of a strand of DNA.
DNA
DNA is made up of four types of nucleotide:
- Adenine (A)
- Thymine (T)
- Cytosine (C)
- Guanine (G)
Adenine and thymine pair up together to make AT
or TA
. Similarly, cytosine and guanine pair up together to make CG
or GC
.
Let's call these pairs units. This means that your encoded string is only allowed to contain the four units AT, TA, CG and GC.
This means that:
ATTAGACG
Would be invalid because it contains the unit GA, which is impossible.
Similarly,
TAGCGCCGATA
Is invalid because the final A does not have a thymine to pair up with.
Example
You must encode the following example text and use its encoded length as part of your score:
I have a friend who's an artist and has sometimes taken a view which I don't agree with very well. He'll hold up a flower and say "look how beautiful it is," and I'll agree. Then he says "I as an artist can see how beautiful this is but you as a scientist take this all apart and it becomes a dull thing," and I think that he's kind of nutty. First of all, the beauty that he sees is available to other people and to me too, I believe. Although I may not be quite as refined aesthetically as he is ... I can appreciate the beauty of a flower. At the same time, I see much more about the flower than he sees. I could imagine the cells in there, the complicated actions inside, which also have a beauty. I mean it's not just beauty at this dimension, at one centimeter; there's also beauty at smaller dimensions, the inner structure, also the processes. The fact that the colors in the flower evolved in order to attract insects to pollinate it is interesting; it means that insects can see the color. It adds a question: does this aesthetic sense also exist in the lower forms? Why is it aesthetic? All kinds of interesting questions which the science knowledge only adds to the excitement, the mystery and the awe of a flower. It only adds. I don't understand how it subtracts.
Bounty
If you answer this challenge in the language DNA#, I will offer a 100 to 200 rep bounty.
Rules
Your encoder and decoder programs must work for any string supplied. Therefore, your encoder must produce a genuine encoding and your decoder should not simply hardcode the example text.
You must support all printable ASCII characters:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
If you can support more characters, that is acceptable.
Scoring
Your score is how long in characters (not units) the encoded version of the above text plus the length in bytes of your decoder and your encoder.
Winning
The program with the lowest score wins.