private void GetVectorComponents() { //Получаем целые числа в интервале от 1 до p^m-2 for (var i = 1; i <= (int)Math.Pow(Basis, _m) - 1; i++) { InitialList.Add(i); } //Оставляем только те, у которых НОД(2^m-1) = 1 foreach (var number in InitialList) { if (MathHelpers.GetNod((int)Math.Pow(Basis, _m) - 1, number) == 1) { FilteredList.Add(number); } } //Выполняем прореживание по p-сопряженным элементам Vector = PConjugateThinning(FilteredList); //Переводим все значения r в p-ичную запись PBasisVector = GetPBasisList(Vector, Basis); //Применяем функцию g(r) ко всем компонентам вектора GofRVector = GetGofRVector(PBasisVector); }
public static char Join(char Initial, char Medial, char Final) { const string InitialList = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ"; const string MedialList = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ"; const string FinalList = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ"; const int UnicodeHangulBase = 0xAC00; int PosInitial = InitialList.IndexOf(Initial); int PosMedial = MedialList.IndexOf(Medial); int PosFinal = FinalList.IndexOf(Final); int Value = UnicodeHangulBase + (PosInitial * 21 + PosMedial) * 28 + PosFinal; return((char)Value); }
public static void Intermediate() { string input; while (!String.IsNullOrEmpty(input = Console.ReadLine())) { int[] InitialList; try { InitialList = input.Replace("(", "").Replace(")", "").Replace(" ", "").Split(',').Select(x => int.Parse(x)).ToArray(); } catch (Exception e) { Console.WriteLine("Input string incorrectly formatted. Please try again"); continue; } Intermediate_PrintTuple(InitialList); int length = InitialList.Count(); int[] prevList = (int[])InitialList.Clone(); int[] newList = new int[length]; List <string> history = new List <string>(); //bool stopLooping = false; string pattern = ""; int LoopLimit = 0; while (LoopLimit < 100) { for (int i = 0; i < length; i++) { newList[i] = Math.Abs(prevList[i] - prevList[(i + 1) % length]); } Intermediate_PrintTuple(newList); history.Add(string.Join(",", newList)); prevList = (int[])newList.Clone(); //Break cases: //All 0's int sum = 0; foreach (int val in newList) { sum += val; } if (sum == 0) { pattern = string.Join(",", newList); break; } //Repeating pattern var patternStart = history.GroupBy(t => t.ToString()).Select(t => new { Sequence = t.Key, Count = t.Count() }).Where(t => t.Count > 1).SingleOrDefault(); if (patternStart != null) { pattern = patternStart.Sequence; break; } LoopLimit++; } Console.WriteLine("Period Detected. Starting Sequence: " + pattern); //foreach (int in InitialList) //{ // Console.WriteLine(a); //} } Console.Read(); }