Your code is going to generate a very simple ASCII-art representation of DNA, forever. It will take two numbers as input in any format you want: as a list, as arguments to a function, on stdin, etc.
- A floating-point interval
Iin seconds between 0.0 and 1.0 (inclusive)
- A zoom level
Zas an integer from 1 to 64 (inclusive)
Your code will print one line to stdout or its equivalent every
I seconds, producing an infinite output that looks something like this (for zoom level 4):
A T-----a G-------c G-----c g t-----A a-------T c-----G T A-----t C-------g ...
Specifically, our representation of DNA is a pair of sine waves connected by hyphens, one consisting of the characters
t, the other of the characters
x is the 0-indexed number of the line we're currently printing, the 0-based position of the character in the lowercase wave is given by
(sin(πx / Z) + 1) * Z, and in the uppercase wave is given by
(-sin(πx / Z) + 1) * Z, both rounded (not floored) to the nearest integer. Further details:
- In cases where the two waves overlap, you need to alternate which wave is in the front, starting with the uppercase wave. (Starting with the lowercase wave would give us a double helix that does not exist!)
- Ignoring case, A always pairs with T and C always pairs with G, as in real DNA. The pairs themselves should be randomly chosen with a uniform distribution over the four possibilities. It does not matter if the choice of pairs is the same or different on successive runs of your code. The statistical quality of your random choices is not an issue as long as the output has no obvious pattern and a period at least in the billions (flawed PRNGs like RANDU are fine.)
- You must either have no trailing spaces or pad every line to the maximum position of the waves at that zoom level (in the example above, nine characters.) Zoom level 1 may have one optional additional trailing space for mathematical reasons.
Because DNA is small, your code will need to be as short as possible.
Zoom level 8:
T C-----g A-----------t C-------------g G---------------c T-------------a T-----------a T-----a c g-----C t-----------A g-------------C a---------------T ...
Zoom level 2:
A T---a c g---C G A---t c a---T ...
Zoom level 1 (note the leading space):
G a C t ...