This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Don't forget to do: chmod +x ./dna_text.rb | |
print 'INPUT sequence: ' | |
sequence = gets.strip.scan(/\w/) | |
binary = sequence.map do |n| | |
case n | |
when 'A' then '00' | |
when 'C' then '01' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Don't forget to do: chmod +x ./text_dna.rb | |
print 'INPUT text: ' | |
text = gets.strip | |
binary = text.unpack('B*') | |
bits = binary[0].scan(/\w/) | |
sequence_bits = bits.each_slice(2).map do |a, b| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile: gcc -o bit2dna bit_dna.c | |
// Libraries | |
#include <stdio.h> | |
#include <string.h> | |
// Declare constants | |
#define A 0 // 00 | |
#define C 1 // 01 | |
#define G 2 // 10 | |
#define T 3 // 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Compile: gcc -o dna2bit dna_bit.c | |
// Libraries | |
#include <stdio.h> | |
#include <string.h> | |
// Declare constants | |
#define A 0 // 00 | |
#define C 1 // 01 | |
#define G 2 // 10 |