Wobble Hypothesis - Combination or Permutation of Array of strings in ruby
2014-09-02 11:18
501 查看
I have a ruby array with 4 strings
I need 4^3 combinations of strings.
This is the wobble hypothesis in genetics. Could someone explain how I could go about achieving this using ruby.
use
nucleotides = ['A', 'G', 'C', 'T']
I need 4^3 combinations of strings.
new_array = ['AGC', 'AGT' .. 'TTT']
This is the wobble hypothesis in genetics. Could someone explain how I could go about achieving this using ruby.
use
Array#repeated_permutation:
nucleotides = %w(A G C T) nucleotides.repeated_permutation(3).map(&:join) #=> ["AAA", "AAG", "AAC", "AAT", "AGA", "AGG", "AGC", "AGT", "ACA", "ACG", "ACC", "ACT", "ATA", "ATG", "ATC", "ATT", "GAA", "GAG", "GAC", "GAT", "GGA", "GGG", "GGC", "GGT", "GCA", "GCG", "GCC", "GCT", "GTA", "GTG", "GTC", "GTT", "CAA", "CAG", "CAC", "CAT", "CGA", "CGG", "CGC", "CGT", "CCA", "CCG", "CCC", "CCT", "CTA", "CTG", "CTC", "CTT", "TAA", "TAG", "TAC", "TAT", "TGA", "TGG", "TGC", "TGT", "TCA", "TCG", "TCC", "TCT", "TTA", "TTG", "TTC", "TTT"]
相关文章推荐
- Ruby: Sorting an array of strings, in alphabetical order, that includes some arrays of strings
- Write a program that gives count of common characters presented in an array of strings..(or array of
- Get indices for sorted permutation of an array in Ruby?
- Finding sum of every combination of two numbers in an array in Ruby
- Write a program that gives count of common characters presented in an array of strings..(or array of
- Get nth element of an array in Ruby?
- Converting a array to an array of ranges in ruby
- How to format strings in an array in ruby?
- how to merge array of hash based same keys in ruby?
- Separate list items by their class or kind_of in ruby
- Sorting an array of hash in Ruby
- 初始化一个NULL-terminated array of strings in C (以NULL结尾的字符串数组)
- Whats the best way to split an array in ruby into multiple smaller arrays of random size
- Creating one array of strings in c fails ,why?
- Condensing an array of hashes within that same array in Ruby
- Matching Portions of A String to Elements of an Array in Ruby
- How to find number of a specific integer in an array of Fixnums ruby
- How to get the length of array of strings in C? - Yahoo! Answers
- Each child in an array or iterator should have a unique "key" prop. Check the render method of `Tabl
- Distinguish between index of a decimal number and integer inside an array in Ruby?