Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Test2
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> coll = new List<string>();
- for (int i = 0; i < args.Length; i++)
- { coll.Add(args[i]); }
- Genome GG = new Genome();
- string s = GG.GetConcatGenom(coll);
- Console.WriteLine(s);
- Console.ReadKey();
- //GetConcatGenom(coll);
- }
- }
- public class Genome
- {
- public string GetConcatGenom(List<String> genoms)
- {
- return ConcatRecursive("", genoms);
- }
- public string ConcatRecursive(string s, List<String> genoms)
- {
- List<String> gens = new List<String>(genoms);
- if (genoms.Count ==1)
- {
- return s;
- }
- foreach (var gen in gens)
- {
- string newgen = s + "";
- //if (genoms.Count == 0) { return newgen ; }
- for (int j = 1; 1 < genoms.Count;j++)
- {
- if (gen.EndsWith(genoms[j].Substring(0, 3)))
- {
- newgen = string.Concat(gen, genoms[j].Substring(3));
- gens.Remove(gen);
- return ConcatRecursive(newgen, gens);
- }
- else
- {
- if (gen.EndsWith(genoms[j].Substring(0, 2)))
- {
- newgen = string.Concat(gen, genoms[j].Substring(2));
- gens.Remove(gen);
- return ConcatRecursive(newgen, gens);
- }
- else
- {
- if (gen.EndsWith(genoms[j].Substring(0, 1)))
- {
- newgen = string.Concat(gen, genoms[j].Substring(1));
- gens.Remove(gen);
- return ConcatRecursive(newgen, gens);
- }
- }
- }
- }
- }return "Не вышло";
- // public List<string> geni = new List<string>();
- // //public Genome(List<string> coll) { geni = coll; }
- // public void perebor_elementov (List<string> geni)
- //{
- // for (int i = 0; i < geni.Count; i++)
- // { Assembly(geni[i],geni); }
- //}
- // public string Assembly (string gen ,List<string> geni )
- // {
- // //string result = string.Empty;
- // //Здесь сравнение элемента с другими и соединение
- // for (int j = 0; 0 < geni.Count;j++)
- // {
- // if (gen.EndsWith(geni[j].Substring(1)))
- // {
- // gen = string.Concat(gen, geni[j].Substring(1));
- // geni.RemoveAt(j);
- // }
- // else
- // {
- // if (gen.EndsWith(geni[j].Substring(2)))
- // {
- // gen = string.Concat(gen, geni[j].Substring(2));
- // geni.RemoveAt(j);
- // }
- // else
- // {
- // if (gen.EndsWith(geni[j].Substring(1)))
- // {
- // gen = string.Concat(gen, geni[j].Substring(1));
- // geni.RemoveAt(j);
- // }
- // else { result = "не подошел"; return result; }
- // }
- // }
- // }
- // return gen;
- // }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement