public void TestMethod1() { Ana a = new Ana(); List <string> test = new List <string>() { "em", "me", "to" }; int finalCount = a.anagrams(test); Assert.AreEqual(1, finalCount); }
public void TestMethod2() { Ana a = new Ana(); List <string> test = new List <string>() { "tape", "rate", "seat", "pate", "east", "pest" }; int finalCount = a.anagrams(test); Assert.AreEqual(2, finalCount); }
public void TestMetho6() { Ana a = new Ana(); Rando r = new Rando(); int x = r.RandomNumLengthofArray(100000); int y = r.RandomNumLengthofWords(10000); int z = r.RandomNumOfAnagrams(40000); int fin = x - z; int finalCount = a.anagrams(r.randomGen(x, y, z)); Assert.AreEqual(finalCount, fin); }
static void Main(string[] args) { var _ana = new Ana(); var _beto = new Beto(); Console.WriteLine("Chave simétrica Ana:" + _ana.calculaChaveSimetrica(_beto)); Console.WriteLine("Chave simétrica Beto:" + _beto.calculaChaveSimetrica(_ana)); Console.WriteLine("Chave pública Ana:" + _ana.chavePublica); Console.WriteLine("Chave pública Beto:" + _beto.chavePublica); Console.ReadKey(); }
public static double Timer() { Rando r = new Rando(); Ana a = new Ana(); Stopwatch sw = new Stopwatch(); double elapsed = 0; long repetitions = 1; int size = 32; do { repetitions *= 2; int _x = r.RandomNumLengthofArray(size); int _y = r.RandomNumLengthofWords(100); int _z = r.RandomNumOfAnagrams(size); List <string> Time = r.randomGen(size, _y, _z); sw.Restart(); for (long i = 0; i < repetitions; i++) { double time = a.anagrams(Time); } sw.Stop(); elapsed = msecs(sw); size = size * 2; } while (elapsed < DURATION); double totalAverage = elapsed / repetitions; return(totalAverage); }
private void btn_Kmean_Click(object sender, EventArgs e) { this.Ana = new BLAnalysis((int)numericUpDown_ClusterAmount.Value); if (Ana.Kmean(radioButton_KmeanPlusPlus.Checked, cbb_Deparment.Text, cbb_Subject.Text, ProfessorID) == 0) { MessageBox.Show("Your data contains null value in some grade ! Please Check !"); return; } chart_AmountStudent.Show(); chart_PercentClusters.Show(); chart_AverageGrade.Show(); chart_AmountStudent.Series["Student"].Points.Clear(); chart_AverageGrade.Series["Average Grade"].Points.Clear(); chart_PercentClusters.Series["Student"].Points.Clear(); chart_PercentClusters.Series["Student"].IsValueShownAsLabel = true; using (var ctx = new UniversityContext()) { int studentAmount; if (cbb_Deparment.Text == "All") { studentAmount = ctx.Students.Count(); } else { if (cbb_Deparment.Text != string.Empty) { var departmentid = ctx.Departments.FirstOrDefault(d => d.DeparmentName == cbb_Deparment.Text).DepartmentID; studentAmount = ctx.Students.Where(s => s.DepartmentID == departmentid).Count(); } else { var subject = ctx.Subjects.SingleOrDefault(s => s.SubjectName == cbb_Subject.Text); var classes = ctx.Classes.Where(s => s.SubjectID == subject.SubjectID && s.ProfessorID == ProfessorID); var points = from grade in ctx.Grades join eachclass in classes on grade.ClassID equals eachclass.ClassID select grade; var pointList = points.GroupBy(s => s.StudentID).ToList(); studentAmount = pointList.Count; } } int count = 0; foreach (var cluster in Ana.Clusters) { chart_AmountStudent.Series["Student"].Points.AddXY("Cluster" + count.ToString(), cluster.Count()); chart_AmountStudent.Series["Student"].Points[count].Label = cluster.Count().ToString(); chart_PercentClusters.Series["Student"].Points.AddXY("Cluster" + count.ToString(), (cluster.Count() * 100 / studentAmount)); double?averageGrade = 0; foreach (var grade in Ana.CentralPoint[count]) { averageGrade += grade.Mark; } averageGrade = averageGrade / Ana.CentralPoint[count].Count(); chart_AverageGrade.Series["Average Grade"].Points.AddXY("Cluster" + count.ToString(), averageGrade); chart_AverageGrade.Series["Average Grade"].Points[count].Label = String.Format("{0:0.00}", averageGrade); count++; } } }
/// <summary> /// Zips two sequences together. /// </summary> /// <typeparam name="T1">Left sequence element type.</typeparam> /// <typeparam name="T2">Right sequence element type.</typeparam> /// <typeparam name="R">Result sequence element type.</typeparam> /// <param name="left">Left sequence.</param> /// <param name="right">Right sequence.</param> /// <param name="selector">Zip function.</param> /// <returns>Result sequence.</returns> public static Func <Func <Maybe <R> > > Zip <T1, T2, R>(this Func <Func <Maybe <T1> > > left, Func <Func <Maybe <T2> > > right, Func <T1, T2, R> selector) { return(() => Ana(new { L = left(), R = right() }.Let(es => new { E = es, Lc = es.L(), Rc = es.R() }), c => !(c.Lc is Maybe <T1> .None) && !(c.Rc is Maybe <T2> .None), c => new { E = c.E, Lc = c.E.L(), Rc = c.E.R() }, c => selector(c.Lc.Value, c.Rc.Value))()); }
static void Main(string[] args) { Ana a = new Ana(); Rando r = new Rando(); Console.WriteLine("\nsize\tTime (msec)\tRation (msec)"); double previousTime = 0; int size = 32; for (int i = 0; i <= 17; i++) { size = size * 2; double currentTime = Timer(); Console.Write((size - 1) + "\t" + currentTime.ToString("G3")); if (i > 0) { Console.WriteLine(" \t" + (currentTime / previousTime).ToString("G3")); } else { Console.WriteLine(); } previousTime = currentTime; } //random generations #region //int x = r.RandomNumLengthofArray(500); //int y = r.RandomNumLengthofWords(20); //int z = r.RandomNumOfAnagrams(60); //int fin = x - z; //double finalCount = a.anagrams(r.randomGen(x, y, z)); //Console.WriteLine("Total Number of words"); //Console.WriteLine(x); //Console.WriteLine("Total Number of Anagrams"); //Console.WriteLine(z); //Console.WriteLine("what my algorthim produces"); //Console.WriteLine(finalCount); //Console.WriteLine("Actual number of non anagrams"); //Console.WriteLine(fin); #endregion //commented code for taken in console input #region //string size = Console.ReadLine(); //string[] split = size.Split(' '); //int numberofwords = int.Parse(split[0]); //int lengthofwords = int.Parse(split[1]); //List<string> wordlist = new List<string>(); //for (int j = 0; j < numberofwords; j++) //{ // string userinput = Console.ReadLine(); // if (userinput.Length == lengthofwords) // { // wordlist.Add(userinput); // } //} //int fianl = anagram(wordlist); //Console.WriteLine(fianl); #endregion Console.Read(); }