- Each character is expressed by a 3-letter codon.
- Each codon is expressed by a 3-digit number in base 4.
A
is 0,C
is 1,G
is 2,T
is 3.- Example:
ACG = 0*4^2 + 1*4^1 + 2*4^0 = 6
, which represents the 7th letter of the alphabet, G. (since we start from 0)
- Example:
- Lower case letters are expressed by the numbers 0-25, upper case letters are expressed by the numbers 37-62. So lower case start with
AAA
and upper case start withGCC
. - The numbers 26-30 represent the characters
' '
,'.'
,','
,'!'
, and'?'
respectively. - The numbers 31-36 are not used, so are numbers greater than 62.
Simply compile the program using GCC and run it. It will prompt you for a message to encode or decode, and then it will print the result.
Take this screenshot from the anime as an example: It should produce the following result:
Enter 'encode' or 'decode': decode
Enter DNA code: GTCCGGCCGAGAAGTAGTCGGAAAAGTCCGAAACGAC
Message: I will alway
Would you like to encode/decode another message? (y/n): y
Enter 'encode' or 'decode': decode
Enter DNA code: GTAATGCCGCGGAAACACACACGGATGCCACACCGGCATATGATAAAACATATGACACAGCTG
Message: How are our tomatoes?
Would you like to encode/decode another message? (y/n): y
Enter 'encode' or 'decode': encode
Enter message: How are our tomatoes?
DNA code: GTAATGCCGCGGAAACACACACGGATGCCACACCGGCATATGATAAAACATATGACACAGCTG
Would you like to encode/decode another message? (y/n): n