Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace DNA
- {
- class Program
- {
- static void Main()
- {
- var dna = "TTTAAAAAGGTTTAAAAAGGAAAACCCCCCAAAAACCCCCAAAAACCCCCCAAAAAGGGTTTAAAAGAAAACCCCCAGGGTTTAGGGTTTAAAAAAGGGTTTA";
- var duplicateSequences = Analyze(dna);
- foreach (var item in duplicateSequences)
- {
- Console.WriteLine(item);
- }
- }
- public static IEnumerable<string> Analyze(string dna)
- {
- var workCollection = new HashSet<string>();
- var outputCollection = new HashSet<string>();
- for (int i = 0; i < dna.Length; i++)
- {
- if (dna.Length - i < 10)
- {
- break;
- }
- var temp = string.Empty;
- for (int j = i; j < i + 10; j++)
- {
- temp += dna[j];
- }
- if(workCollection.Add(temp))
- {
- continue;
- }
- else
- {
- outputCollection.Add(temp);
- }
- }
- return outputCollection;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement