[Question]
  [
# Text to DNA golf
## Challenge
Convert input into a DNA output.
## Algorithm
* Convert text into ASCII code points (e.g. `codegolf` -> `[99, 111, 100, 101, 103, 111, 108, 102]`)
* String the ASCII codes together (e.g. `99111100101103111108102`)
* Convert to binary (e.g. `10100111111001101001011010001000011001101011011110000110010111111011000000110`)
* Pad `0`s onto the end to make an even number of characters (e.g. `101001111110011010010110100010000110011010110111100001100101111110110000001100`)
* Replace `00` with `A`, `01` with `C`, `10` with `G`, and `11` with `T` (e.g. `GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA`)
* Output
## Test Cases
```
codegolf > GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA
ppcg > GGCTAATTGTCGCACTT
} > TTGG (padding)
```
## Specifications
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'")
* Your program must accept spaces in input.
* Your program must work for `codegolf`.
  
[Answer]
# [Jelly](http://github.com/DennisMitchell/jelly), ~~15~~ 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
OVBs2UḄị“GCTA
```
[Try it online!](http://jelly.tryitonline.net/#code=T1ZCczJV4biE4buL4oCcR0NUQQ&input=&args=J2NvZGVnb2xmJw) or [verify all test cases](http://jelly.tryitonline.net/#code=T1ZCczJV4biE4buL4oCcR0NUQeKAnQrDh-KCrGrigbc&input=&args=J2NvZGVnb2xmJywgJ3BwY2cnLCAnfSc).
### How it works
```
OVBs2UḄị“GCTA    Main link. Argument: s (string)
O                Ordinal; replace each character with its code point.
 V               Eval. This converts the list to a string before evaluating, so it
                 returns the integer that results of concatenating all the digits.
  B              Binary; convert from integer to base 2.
   s2            Split into chunks of length 2.
     U           Upend; reverse the digits of each chunk.
                 Reversing means that we would have to conditionally PREPEND a zero
                 to the last chunk, which makes no difference for base conversion.
      Ḅ          Unbinary; convert each chunk from base 2 to integer.
                 `UḄ' maps:
                     [0, 1   ] -> [1,    0] -> 2
                     [1, 0(?)] -> [0(?), 1] -> 1
                     [1, 1   ] -> [1,    1] -> 3
                     [0, 0(?)] -> [0(?), 0] -> 0
       ị“GCTA    Replace each number by the character at that index.
                 Indexing is 1-based, so the indices are [1, 2, 3, 0].
```
[Answer]
## CJam, ~~24~~ 23 bytes
*Thanks to Dennis for saving 1 byte in a really clever way.* :)
```
l:isi2b2/Wf%2fb"AGCT"f=
```
[Test it here.](http://cjam.aditsu.net/#code=l%3Aisi2b2%2FWf%252fb%22AGCT%22f%3D&input=codegolf)
### Explanation
Very direct implementation of the specification. The only interesting bit is the padding to an even number of zeros (which was actually Dennis's idea). Instead of treating the digits in each pair in the usual order, we make the second bit the most significant one. That means, ending in a single bit is identical to appending a zero to it, which means we don't have to append the zero at all.
```
l          e# Read input.
:i         e# Convert to character codes.
si         e# Convert to flat string and back to integer.
2b         e# Convert to binary.
2/         e# Split into pairs.
Wf%        e# Reverse each pair.
2fb        e# Convert each pair back from binary, to get a value in [0 1 2 3].
"AGCT"f=   e# Select corresponding letter for each number.
```
[Answer]
# Python 2, ~~109~~ 103 bytes
```
lambda s,j=''.join:j('ACGT'[int(j(t),2)]for t in
zip(*[iter(bin(int(j(`ord(c)`for c in s))*2)[2:])]*2))
```
Test it on [Ideone](http://ideone.com/pp9MHm).
[Answer]
# Ruby, 59 bytes
```
$_='%b0'.%$_.bytes*''
gsub(/../){:ACGT[$&.hex%7]}
chomp'0'
```
A full program. Run with the `-p` flag.
[Answer]
# Python 3, 126 bytes
```
lambda v:"".join(["ACGT"[int(x,2)]for x in map(''.join,zip(*[iter((bin(int("".join([str(ord(i))for i in v])))+"0")[2:])]*2))])
```
[Answer]
# Python 3, 130 bytes.
Saved 2 bytes thanks to vaultah.  
Saved 6 bytes thanks to Kevin Lau - not Kenny.
I hate how hard it is to convert to binary in python.
```
def f(x):c=bin(int(''.join(map(str,map(ord,x)))))[2:];return''.join('ACGT'[int(z+y,2)]for z,y in zip(*[iter(c+'0'*(len(c)%2))]*2))
```
Test cases:
```
assert f('codegolf') == 'GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA'
assert f('ppcg') == 'GGCTAATTGTCGCACTT'
```
[Answer]
# Ruby, 80 bytes
```
->s{s=s.bytes.join.to_i.to_s 2;s+=?0*(s.size%2)
s.gsub(/../){"ACGT"[$&.to_i 2]}}
```
[Answer]
# Mathematica, 108 bytes
```
{"A","C","G","T"}[[IntegerDigits[Mod[Floor@Log2@#,2,1]#&@FromDigits[""<>ToString/@ToCharacterCode@#],4]+1]]&
```
Takes a string as input, and outputs a list of bases.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 17 bytes
```
Cṅb₅∷[0J]B`ACGT`τ
```
[Try it Online!](https://lyxal.pythonanywhere.com?flags=&code=C%E1%B9%85b%E2%82%85%E2%88%B7%5B0J%5DB%60ACGT%60%CF%84&inputs=%7D&header=&footer=)
A mess.
```
C                 # Charcodes
 ṅ                # Concatenated
  b               # To binary
   ₅∷[  ]         # If length is odd
      0J          # Append a 0
         B        # To base10
          `ACGT`τ # Convert to custom base `ACGT` (convert to base4, replace 0-3 with corresponding item of "ACGT")
```
[Answer]
# Pyth, 25 bytes
```
sm@"ACGT"id2Pc.B*4sjkCMQ2
```
[Try it here!](http://pyth.herokuapp.com/?code=sm%40%22ACGT%22id2Pc.B*4sjkCMQ2&input=%22codegolf%22&test_suite_input=%22codegolf%22%0A%22ppcg%22&debug=0)
### Explanation
Burrowing the padding trick from [Martins CJam answer](https://codegolf.stackexchange.com/a/79170/49110).
```
sm@"ACGT"id2Pc.B*4sjkCMQ2    # Q = input
                     CMQ     # Map each character of Q to its character code
                  sjk        # Join into one string and convert to an integer
              .B*4           # Mulitply with 4 and convert to binary
             c          2    # Split into pairs
            P                # Discard the last pair
 m                           # Map each pair d
         id2                 # Convert pair from binary to decimal
  @"ACGT"                    # Use the result ^ as index into a lookup string
s                            # Join the resulting list into on string
```
[Answer]
# [05AB1E](http://github.com/Adriandmen/05AB1E), 23 bytes
Code:
```
SÇJb00«2÷¨C3210"TGCA"‡á
```
Uses **CP-1252** encoding. [Try it online!](http://05ab1e.tryitonline.net/#code=U8OHSmIwMMKrMsO3wqhDMzIxMCJUR0NBIuKAocOh&input=cHBjZw).
[Answer]
# Java, 194 bytes
```
String a(int[]a){String s="",r=s;for(int i:a)s+=i;s=new BigInteger(s).toString(2)+0;for(int i=0,y,n=48;i<(s.length()/2)*2;r+=s.charAt(i++)==n?y==n?'A':'G':y==n?'C':'T')y=s.charAt(i++);return r;}
```
### Ungolfed
```
String a(int[] a) {
    String s = "", r = s;
    for (int i : a) s += i;
    s = new BigInteger(s).toString(2) + 0;
    for (int i = 0, y, n = 48; i < (s.length() / 2) * 2; 
        r += s.charAt(i++) == n 
                 ? y == n 
                 ? 'A' 
                 : 'G' 
                 : y == n 
                 ? 'C' 
                 : 'T')
        y = s.charAt(i++);
    return r;
}
```
### Note
* Input is an array of chars (which should count as a form of String), parameter is of type `int[]` because thats one byte saved over `char[]`.
### Output
```
Input:  codegolf
Output: GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA
Input:  .
Output: GTG
Input:  }
Output: TTGG
Input:  wow
Output: TGATAGTTGTGCTG
Input:  programming puzzles
Output: GTGTCAGAGTTGAAGGCCGTTCCGCAGTGCATTTGGCTCGTCTGGTGTCTACTAGCCTGCGAGAGGAGTTACTTTGGATCCTTGACTTGT
```
[Answer]
# Python 2.7, 135 bytes
```
def f(A):g=''.join;B=bin(int(g(map(str,map(ord,A)))))[2:];B+=len(B)%2*'0';return g('ACGT'[int(B[i:i+2],2)] for i in range(len(B))[::2])
```
Ungolfed:
```
def f(A):
    g = ''.join
    B = bin(int(g(map(str,map(ord,A)))))[2:] # convert string input to binary
    B += len(B)%2 * '0' # add extra 0 if necessary
    return g('ACGT'[int(B[i:i+2],2)] for i in range(len(B))[::2]) # map every two characters into 'ACGT'
```
# Output
```
f('codegolf')
'GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA'
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 21 bytes
```
'CGTA'joV4Y2HZa2e!XB)
```
[**Try it online!**](http://matl.tryitonline.net/#code=J0NHVEEnam9WNFkySFphMmUhWEIp&input=Y29kZWdvbGY)
### Explanation
```
'CGTA'   % Push string to be indexed into
j        % Take input string
o        % Convert each char to its ASCII code
V        % Convert to string (*). Numbers are separated by spaces
4Y2      % Push the string '0123456789'
H        % Push number 2
Za       % Convert string (*) from base '0123456789' to base 2, ignoring spaces
2e       % Reshape into a 2-column matrix, padding with a trailing 0 if needed
!        % Transpose
XB       % Convert from binary to decimal
)        % Index into string with the DNA letters. Indexing is 1-based and modular
```
[Answer]
# [Factor](https://factorcode.org/) + `grouping.extras`, 95 bytes
```
[ [ present ] f map-as concat dec> >bin 2 48 pad-groups 2 group [ bin> "ACGT" nth ] "" map-as ]
```
Doesn't work on TIO because `pad-groups` postdates build 1525, the one TIO uses. Here's a picture of running it in build 2101:
[![enter image description here](https://i.stack.imgur.com/ICdtC.png)](https://i.stack.imgur.com/ICdtC.png)
There is no build where whitespace can be omitted after strings and `pad-groups` exists, but `pad-groups` makes it worth it.
## Explanation:
It's a quotation (anonymous function) that accepts a string from the data stack as input and leaves a string on the data stack as output. Assuming `"ppcg"` is on the data stack when this quotation is called...
| Snippet | Output |
| --- | --- |
| `[ present ] f map-as` | `{ "112" "112" "99" "103" }` |
| `concat` | `"11211299103"` |
| `dec>` | `11211299103` |
| `>bin` | `"1010011100001111101101100100011111"` |
| `2 48 pad-groups` | `"1010011100001111101101100100011111"` (append zeros so length is divisible by 2.) |
| `2 group` | `{ "10" "10" "01" "11" "00" "00" "11" "11" "10" "11" "01" "10" "01" "00" "01" "11" "11" }` |
| `[ bin> ] map` | `{ 2 2 1 3 0 0 3 3 2 3 1 2 1 0 1 3 3 }` |
| `[ "ACGT" nth ] "" map-as` | `"GGCTAATTGTCGCACTT"` |
 
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 23 bytes
```
sm@"AGCT"i_d2c.BsjkCMQ2
```
[Try it online!](http://pyth.herokuapp.com/?code=sm%40%22AGCT%22i_d2c.BsjkCMQ2&input=%22codegolf%22&test_suite_input=%22codegolf%22%0A%22ppcg%22&debug=0)
### Explanation
Borrowing the trick from [Dennis' Jelly answer](https://codegolf.stackexchange.com/a/79178/48934).
```
sm@"AGCT"i_d2c.BsjkCMQ2
                   CMQ   convert each character to its byte value
                sjk      convert to a string and then to integer
              .B         convert to binary
             c        2  chop into pairs
 m         d             for each pair:
          _                  reverse it
         i  2                convert from binary to integer
  @"AGCT"                    find its position in "AGCT"
s                        join the string
```
[Answer]
# Groovy, 114 bytes
```
{s->'ACGT'[(new BigInteger(((Byte[])s).join())*2).toString(2).toList().collate(2)*.with{0.parseInt(it.join(),2)}]}
```
Explanation:
```
{s->
    'ACGT'[ //access character from string
        (new BigInteger( //create Big Integer from string
           ((Byte[])s).join() //split string to bytes and then join to string
        ) * 2) //multiply by 2 to add 0 at the end in binary
        .toString(2) //change to binary string
        .toList() //split to characters
        .collate(2) //group characters by two
        *.with{
            0.parseInt(it.join(),2) //join every group and parse to decimal
        }
     ]
}
```
[Answer]
# Julia 0.4, 77 bytes
```
s->replace(bin(BigInt(join(int(s)))),r"..?",t->"AGCT"[1+int("0b"reverse(t))])
```
This anonymous function takes a character array as input and returns a string.
[Try it online!](http://julia.tryitonline.net/#code=ZiA9IHMtPnJlcGxhY2UoYmluKEJpZ0ludChqb2luKGludChzKSkpKSxyIi4uPyIsdC0-IkFHQ1QiWzEraW50KCIwYiJyZXZlcnNlKHQpKV0pCgpwcmludGxuKGYoWyJjb2RlZ29sZiIuLi5dKSkKcHJpbnRsbihmKFsicHBjZyIuLi5dKSkKcHJpbnRsbihmKFsifSIuLi5dKSk)
[Answer]
# Javascript ES7, ~~105~~ 103 bytes
```
s=>((+[for(c of s)c.charCodeAt()].join``).toString(2)+'0').match(/../g).map(x=>"ACGT"['0b'+x-0]).join``
```
The ES7 part is the `for(c of s)` part.
## ES6 version, ~~107~~ 105 bytes
```
s=>((+[...s].map(c=>c.charCodeAt()).join``).toString(2)+'0').match(/../g).map(x=>"ACGT"['0b'+x-0]).join``
```
## Ungolfed code
```
dna = (str)=>{
  var codes = +[for(c of str)c.charCodeAt()].join``;
  var binaries = (codes.toString(2)+'0').match(/../g);
  return binaries.map(x=>"ACGT"['0b'+x-0]).join``
}
```
This is my first try at golfing on PPCG, feel free to correct me if something's wrong.
Thanks @AlexA for the small improvement.
[Answer]
# J, 52 bytes
```
 3 :'''ACGT''{~#._2,\#:".,&''x''":(,&:(":"0))/3&u:y'
```
Usage: `3 :'''ACGT''{~#._2,\#:".,&''x''":(,&:(":"0))/3&u:y' 'codegolf'` ==> `GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA`
[Answer]
## [Hoon](https://github.com/urbit/urbit), ~~148~~ 138 bytes
```
|*
*
=+
(scan (reel +< |=({a/@ b/tape} (weld <a> b))) dem)
`tape`(flop (turn (rip 1 (mul - +((mod (met 0 -) 2)))) |=(@ (snag +< "ACGT"))))
```
"abc" is a list of atoms. Interpolate them into strings (`<a>`) while folding over the list, joining them together into a new string. Parse the number with `++dem` to get it back to an atom.
Multiply the number by (bitwise length + 1) % 2 to pad it. Use `++rip` to disassemble every two byte pair of the atom into a list, map over the list and use the number as an index into the string "ACGT".
```
> =a |*
  *
  =+
  (scan (reel +< |=({a/@ b/tape} (weld <a> b))) dem)
  `tape`(flop (turn (rip 1 (mul - +((mod (met 0 -) 2)))) |=(@ (snag +< "ACGT"))))
> (a "codegolf")
"GGCTTGCGGCCGGAGACGCGGTCTGACGCCTTGTAAATA"
> (a "ppcg")
"GGCTAATTGTCGCACTT"
> (a "}")
"TTGG"
```
[Answer]
## Common Lisp (Lispworks), 415 bytes
```
(defun f(s)(labels((p(e f)(concatenate'string e f)))(let((b"")(d""))(dotimes(i(length s))(setf b(p b(write-to-string(char-int(elt s i))))))(setf b(write-to-string(parse-integer b):base 2))(if(oddp #1=(length b))(setf b(p b"0")))(do((j 0(+ j 2)))((= j #1#)d)(let((c(subseq b j(+ j 2))))(cond((#2=string="00"c)(setf d(p d"A")))((#2#"01"c)(setf d(p d"C")))((#2#"10"c)(setf d(p d"G")))((#2#"11"c)(setf d(p d"T")))))))))
```
ungolfed:
```
(defun f (s)
  (labels ((p (e f)
             (concatenate 'string e f)))
  (let ((b "") (d ""))
    (dotimes (i (length s))
      (setf b
            (p b
               (write-to-string
                (char-int (elt s i))))))
    (setf b (write-to-string (parse-integer b) :base 2))
    (if (oddp #1=(length b))
        (setf b (p b "0")))
      (do ((j 0 (+ j 2)))
          ((= j #1#) d)
        (let ((c (subseq b j (+ j 2))))
          (cond ((#2=string=  "00" c)
                 (setf d (p d "A")))
                ((#2# "01" c)
                 (setf d (p d "C")))
                ((#2# "10" c)
                 (setf d (p d "G")))
                ((#2# "11" c)
                 (setf d (p d "T")))))))))
```
Usage:
```
CL-USER 2060 > (f "}")
"TTGG"
CL-USER 2061 > (f "golf")
"TAAAAATTATCCATAAATA"
```
[Answer]
# [PowerShell Core](https://github.com/PowerShell/PowerShell), ~~143~~ 121 bytes
```
filter d{if($_){"$(($_-($i=$_%2))/2|d)$i"}}-join([regex]"(..)"|% s* "$(-join($args|%{+$_})|d)0"|?{$_[1]}|%{"ACGT"[$_%8]})
```
[Try it online!](https://tio.run/##VY3RToMwFIbveYqm6UyrY@quTMwiDVEuNa53hJAJB8aCgi2LS6DPjgeQqU2a05z/@7/W1Rdos4eydJNKQ8@yTdtnRdmAJmlbZJzFoqWM43Q5KzYsXqyFuF53qWAFtdY9VMUHDzXkcIooX60E7RbEXBLsTBnb6dx0i/aKxVZg7YZ2Dy2Lw9vI4pZKP1A0RO1dZEVvHcfjDsGz9DhNqhTyqszoktAg8JUKfBx4ZYA1nMpX42uIlJRSSSrO7bpO8rmJERJISkT/MHYAMApwJ0hHnir9uEv27vPbAZKGtCPIGjCNvzOwJAxONQaQkg1h8ZRqMMeywcUFy4g3s2MWvmz9o2mq98kXeZNwONtjkoAxg@fsdOFz1t2fQfUjHMhZ/pu@zp//61nHOv03 "PowerShell Core – Try It Online")
## Explanations
Takes as an input a string transformed as a char array using splatting
First, a filter to convert decimal to binary as Powershell can't do it for number larger than `long`
```
filter d{if($_){"$(($_-($i=$_%2))/2|d)$i"}}
```
This converts the char array to an int array, joins them as a string, splits with binary string concatenated with the padding in strings of length 2.  
It converts each substring to a number, and using modulus 8, finds the correct char in the `ACGT` string.
```
-join([regex]"(..)"|% s* "$(-join($args|%{+$_})|d)0"|?{$_[1]}|%{"ACGT"[$_%8]})
```
[Answer]
# Perl, ~~155~~ ~~148~~ 137 + 1 (`-p` flag) = 138 bytes
```
#!perl -p
s/./ord$&/sge;while($_){/.$/;$s=$&%2 .$s;$t=$v="";$t.=$v+$_/2|0,$v=$_%2*5
for/./g;s/^0// if$_=$t}$_=$s;s/(.)(.)?/([A,C],[G,T])[$1][$2]/ge
```
Test it on [Ideone](http://ideone.com/MuPT0K).
[Answer]
# Perl 6, 57 + 1 (`-p` flag) = 58 bytes
```
$_=(+[~] .ords).base(2);s:g/..?/{<A G C T>[:2($/.flip)]}/
```
Step by step explanation:
`-p` flag causes Perl 6 interpreter to run code line by line, put current line `$_`, and at end put it back from `$_`.
`.ords` - If there is nothing before a period, a method is called on `$_`. `ords` method returns list of codepoints in a string.
`[~]` - `[]` is a reduction operator, which stores its reduction operator between brackets. In this case, it's `~`, which is a string concatenation operator. For example, `[~] 1, 2, 3` is equivalent to `1 ~ 2 ~ 3`.
`+` converts its argument to a number, needed because `base` method is only defined for integers.
`.base(2)` - converts an integer to a string in base 2
`$_=` - assigns the result to `$_`.
`s:g/..?/{...}/` - this is a regular expression replacing any (`:g`, global mode) instance of regex `..?` (one or two characters). The second argument is a replacement pattern, which in this case in code (in Perl 6, curly brackets in strings and replacement patterns are executed as code).
`$/` - a regex match variable
`.flip` - inverts a string. It implicitly converts `$/` (a regex match object) to a string. This is because a single character `1` should be expanded to `10`, as opposed to `01`. Because of that flip, order of elements in array has G and C reversed. 
`:2(...)` - parses a base-2 string into an integer.
`<A G C T>` - array of four elements.
`...[...]` - array access operator.
What does that mean? The program gets list of all codepoints in a string, concatenates them together, converts them to base 2. Then, it replaces all instances of two or one character into one of letters A, G, C, T depending on flipped representation of a number in binary.
[Answer]
# [Python 3](https://docs.python.org/3/), 117 bytes
This answer ignores padding. Looks like it could be shorter.
```
lambda x:''.join('ACGT'[h//4]+'ACGT'[h%4]for h in [int(h,16)for h in hex(int(''.join(map(str,x.encode()))))[2:]])[1:]
```
[Try it online!](https://tio.run/##K6gsycjPM/5foWCroF5QkJyu/j8nMTcpJVGhwkpdXS8rPzNPQ93R2T1EPTpDX98kVhvGUTWJTcsvUshQyMxTiM7MK9HI0DE004QLZaRWaIBEYWbkJhZoFJcU6VTopeYl56ekamiCQLSRVWysZrShVez/giKQ8jSNCk3N/wA "Python 3 – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 92 90 bytes
Does not handle padding, but is under 100.
```
lambda x,s='':f(x,'ACGT'[v%4]+s)if (v:=int(''.join(map(str,x.encode())))>>len(s)*2) else s
```
[Try it online!](https://tio.run/##Jc0xDsIgFIDhvadgMe@hTQd1ME1oQhi4AJs6YAta01ICpMHTY43/Af7Pf9JrcaeLDyUTRsD7/gmVZbcy6fkxaJLryABai7kGLqSC67o73w@Rjpbg2rLRJQRo3svocNYeYwp1bozrl8Eg3eq6yTiMdH@kxEzRkFh0jCYkYvHPUcI2WUqhOFdKKiEFF0pB5cPvvtGUli8 "Python 3.8 (pre-release) – Try It Online")
# [Python 3](https://docs.python.org/3/), 113 110 bytes
Spending almost 1/5 bytes on padding.
```
def f(x):
	v=int(''.join(map(str,x.encode())));v<<=len(bin(v))%2;c=''
	while v:c='ACGT'[v%4]+c;v>>=2
	return c
```
[Try it online!](https://tio.run/##RU/BDoIwDD2zr9jFdIvGg3oCRrJw2A/sZjzoGILBsYw58euxeLFJ0zbv9bXPf2I3uuMyU0HBe3OHpbEtbdnMc5Il0bvIAPaPsXfsefVsimE3760zY2MZxyhSWYrBOnZDRuJ8cyiMACDZu@sHS1OOk6yVhnPanC5bU6SqEgeSBRtfwVGzXKfJhogXYdW8j0MLnAr8Rqlaa1VjwZQKRbDqWv@6FdJSSi2B/BV@Bv7bCCML2RLpQHxY3azW@PIF "Python 3 – Try It Online")
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 110 bytes
```
f=lambda x,s='':f(x,'ACGT'[v%4]+s)if(v:=(u:=int(''.join(map(str,x.encode()))))<<len(bin(u))%2>>len(s)*2)else s
```
[Try it online!](https://tio.run/##RU8xDsIwDNx5RRZkGyqGwoAqghR1yAeyIYYWEigqadQUVF5fnC61ZNnW3Vl34Tc8O78/hn4ahRQQwu0Bk5Nt9a7vlRizKAEKh2MGqtQGLt/14bqN1Dj8FhI/hWz8gAC7V9d4fFcB49Bn4876W3e3SKlOp9Z6rBn/EK3z8zmdkTY52TZaEacqRtsPwiEk0aNrHZCQ7Ebr0hhd8uBWmh3wNKWZtwQZpZRRsFo@zAEWNcPMYrZiOqxCn@xyHKLpDw "Python 3.8 (pre-release) – Try It Online")
]