static void OnDrawGizmo(Question5 question5, GizmoType type) { foreach (Vector3 potison in question5.positions) { Gizmos.DrawWireSphere(potison, 0.5f); } }
public static void Run() { // warms up the methods Question1.Answer(0.0, 0.0, 0.0); Question2.Answer(new int[] { 0 }, new int[] { 0 }, new int[] { 0 }); Question3.Answer(new int[] { 0 }, new int[] { 0 }); Question4.Answer(new int[] { 0 }, new int[] { 0 }, 0); Question5.Answer(new int[] { 0 }); Question6.Answer(new string[] { "AA", "AA" }); }
static void Main(string[] args) { Console.WriteLine("Hello PTG world!"); Question1 questionOne = new Question1(); int[] testOne = new int[] { 2, 7, 11, 15 }; int[] resultOne = questionOne.TwoSumIterative(testOne, 9); int[] resultOnePT2 = questionOne.TwoSumEfficient(testOne, 9); Console.WriteLine("[{0}]", string.Join(", ", resultOne)); Console.WriteLine("[{0}]", string.Join(", ", resultOnePT2)); Question2 questionTwo = new Question2(); int[] testTwo = new int[] { 3, 2, 2, 3, 3, 4, 5, 6, 9, 3 }; Console.WriteLine($"Initial Lenght: {questionTwo.InitialLength(testTwo, 3)}"); Console.WriteLine($"Final Lenght: {questionTwo.NewLength(testTwo, 3)}"); Question3 question3 = new Question3(); int[] test3Arr1 = new int[] { 1, 2, 3, 0, 0, 0 }; int[] test3Arr2 = new int[] { 2, 5, 6 }; int[] question3Result = question3.MergeSort(test3Arr1, test3Arr2); Console.WriteLine("Question 3"); Console.WriteLine("[{0}]", string.Join(", ", question3Result)); Question4 question4 = new Question4(); Question5 question5 = new Question5(); Console.WriteLine("Question 5:"); string q5InTrue = "A man,! - a plAn, a canal: Panama"; string q5InFasle = "race a car"; Console.WriteLine($"Q5 Should be TRUE: {question5.ValidPalindrome(q5InTrue)}"); Console.WriteLine($"Q5 Should be FALSE: {question5.ValidPalindrome(q5InFasle)}"); Question6 question6 = new Question6(); Console.WriteLine(""); Console.WriteLine("QUESTION 6"); string simple = "(([[{{"; string test6True = "(){}[]"; string test6True2 = "}}))(({{[]"; string test6False = "{{{{((()(){{{{}}{{[[]{{{{{"; Console.WriteLine($"Q6 false should be: {question6.HashMapCharacterValidation(simple)}"); Console.WriteLine($"Q6 True should be: {question6.HashMapCharacterValidation(test6True)}"); Console.WriteLine($"True should be for starting with close: {question6.HashMapCharacterValidation(test6True2)}"); Console.WriteLine($"False should be: {question6.HashMapCharacterValidation(test6False)}"); Console.ReadLine(); }
protected override void OnDisappearing() { base.OnDisappearing(); Question1.RemoveBehaviors(); Question2.RemoveBehaviors(); Question3.RemoveBehaviors(); Question4.RemoveBehaviors(); Question5.RemoveBehaviors(); Question6.RemoveBehaviors(); Question7.RemoveBehaviors(); }
public void SwappedNumbers() { Question5 q = new Question5(100, 200); Assert.AreEqual(q.First, 100); Assert.AreEqual(q.Second, 200); q.Run(); Assert.AreEqual(q.First, 200); Assert.AreEqual(q.Second, 100); q.RunXor(); Assert.AreEqual(q.First, 100); Assert.AreEqual(q.Second, 200); }
TimedAnswer <int> getFifthAnwser(Test <StructuredTrades> test) { var timer = new Stopwatch(); var structuredTrades = test.GetInput(); timer.Start(); var answer = Question5.Answer(structuredTrades.allowedAllocations, structuredTrades.totalValue); timer.Stop(); var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000; return(new TimedAnswer <int>(answer, timeTaken)); }
Answer getFifthAnswer(int[] input, TestCase test) { var timer = new Stopwatch(); timer.Start(); var answer = Question5.Answer(input); timer.Stop(); var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000; return(new Answer() { questionNumber = 5, testNumber = test.testNumber, correct = answer == test.output ? "CORRECT" : "INCORRECT", speed = timeTaken }); }
Answer getFifthAnswer(StructuredTrades input, TestCase test) { var timer = new Stopwatch(); timer.Start(); var answer = Question5.Answer(input.allowedAllocations, input.totalValue); timer.Stop(); var timeTaken = ((double)timer.ElapsedTicks / Stopwatch.Frequency) * 1000000000; return new Answer() { questionNumber = 5, testNumber = test.testNumber, correct = answer == test.output ? "CORRECT" : "INCORRECT", speed = timeTaken }; }
public void Run() { Question5.Run(); }
public ActionResult AddQuestionnaire(QuestionnairesViewModel Model, string[] BlankOptions, string[] AnswerOptions) { try { VTSDBEntities objDB = new VTSDBEntities(); if (Model.QuestionType == DAL.Model.QuestionType.SingleLine) { Question1 question1 = new Question1(); question1.QuestionSentence = Model.QuestionText; question1.OriginalSentence = ""; List <Option1> QuesOptions = new List <Option1>(); foreach (string OptionText in BlankOptions) { Option1 EachOption = new Option1(); EachOption.OptionText = OptionText; EachOption.Question1 = question1; QuesOptions.Add(EachOption); } List <Answer1> AllAnswers = new List <Answer1>(); foreach (string AnswerText in AnswerOptions) { Answer1 EachAnswer = new Answer1(); EachAnswer.AnswerText = AnswerText; EachAnswer.Question1 = question1; AllAnswers.Add(EachAnswer); } question1.Answer1 = AllAnswers; question1.Option1 = QuesOptions; objDB.Question1.Add(question1); objDB.SaveChanges(); ViewBag.SuccessMsg = "Questionnaire added successfully."; } else if (Model.QuestionType == DAL.Model.QuestionType.MultiLine) { Question2 question2 = new Question2(); question2.QuestionText = Model.QuestionText; List <Option2> QuesOptions = new List <Option2>(); foreach (string OptionText in BlankOptions) { Option2 EachOption = new Option2(); EachOption.OptionText = OptionText; EachOption.Question2 = question2; QuesOptions.Add(EachOption); } List <Answer2> AllAnswers = new List <Answer2>(); Answer2 EachAnswer = new Answer2(); EachAnswer.Answer = Model.AnswerText; EachAnswer.Question2 = question2; AllAnswers.Add(EachAnswer); question2.Answer2 = AllAnswers; question2.Option2 = QuesOptions; objDB.Question2.Add(question2); objDB.SaveChanges(); ViewBag.SuccessMsg = "Questionnaire added successfully."; } else if (Model.QuestionType == DAL.Model.QuestionType.SingleOption) { Question3 question3 = new Question3(); question3.QuestionText = Model.QuestionText; List <Answer3> AllAnswers = new List <Answer3>(); foreach (string AnswerText in AnswerOptions) { Answer3 EachAnswer = new Answer3(); EachAnswer.Answer = AnswerText; EachAnswer.Question3 = question3; AllAnswers.Add(EachAnswer); } question3.Answer3 = AllAnswers; objDB.Question3.Add(question3); objDB.SaveChanges(); ViewBag.SuccessMsg = "Questionnaire added successfully."; } else if (Model.QuestionType == DAL.Model.QuestionType.MultiOption) { Question4 question4 = new Question4(); question4.QuestionText = Model.QuestionText; List <Answer4> AllAnswers = new List <Answer4>(); foreach (string AnswerText in AnswerOptions) { Answer4 EachAnswer = new Answer4(); EachAnswer.Answer = AnswerText; EachAnswer.Question4 = question4; AllAnswers.Add(EachAnswer); } question4.Answer4 = AllAnswers; objDB.Question4.Add(question4); objDB.SaveChanges(); ViewBag.SuccessMsg = "Questionnaire added successfully."; } else if (Model.QuestionType == DAL.Model.QuestionType.Date) { Question5 question5 = new Question5(); question5.QuestionText = Model.QuestionText; List <Answer5> AllAnswers = new List <Answer5>(); foreach (string AnswerText in AnswerOptions) { Answer5 EachAnswer = new Answer5(); EachAnswer.Answer = AnswerText; EachAnswer.Question5 = question5; AllAnswers.Add(EachAnswer); } question5.Answer5 = AllAnswers; objDB.Question5.Add(question5); objDB.SaveChanges(); ViewBag.SuccessMsg = "Questionnaire added successfully."; } } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } //throw raise; ViewBag.ErrorMsg = "An error occurred while saving the questionnaire."; } ModelState.Clear(); return(View()); }
public void Question5Test() { Assert.AreEqual(Question5.MakePattern(), "1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11"); }
static void Main(string[] args) { Console.WriteLine("Hello Third Day"); Console.WriteLine(""); Console.WriteLine("Question 1 !!!"); int[] testQ1arr1 = new int[] { 1, 2, 3, 4 }; int testQ1Len1 = 2; int[] testQ1arr2 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 }; int testQ1Len2 = 3; Question1Proper question1 = new Question1Proper(); int[][] q1ResultTest1 = question1.subArrs(testQ1arr1, testQ1Len1); for (int i = 0; i < q1ResultTest1.Length; i++) { for (int j = 0; j < q1ResultTest1[i].Length; j++) { Console.Write(q1ResultTest1[i][j]); } Console.WriteLine(); } int[][] q1ResultTest2 = question1.subArrs(testQ1arr2, testQ1Len2); for (int i = 0; i < q1ResultTest2.Length; i++) { for (int j = 0; j < q1ResultTest2[i].Length; j++) { Console.Write(q1ResultTest2[i][j]); } Console.WriteLine(); } Console.WriteLine(""); Question2 question2 = new Question2(); Console.WriteLine("Question 2 !!!!"); string testQ2str1 = "?rail? !SafeTy!"; string testQ2str2 = "fairy tales"; string testQ2str3 = "rail safeee"; Console.WriteLine($"Question 2:?rail? !SafeTy!: rail safety: {question2.AreStringsAnagrams(testQ2str1, testQ2str2)} "); Console.WriteLine($"Question 2:rail? SafeTy!: rail safeee: {question2.AreStringsAnagrams(testQ2str1, testQ2str3)} "); Console.WriteLine(""); Question3 question3 = new Question3(); Console.WriteLine("Question 3 !!!!"); question3.BuildPyramid(-1); question3.BuildPyramid(1); question3.BuildPyramid(2); question3.BuildPyramid(3); question3.BuildPyramid(4); question3.BuildPyramid(7); Question5 question5 = new Question5(); question5.PrintPascal(5); Console.WriteLine($"Print only the last line..example input 5:"); question5.SinglePascal(5); Console.ReadLine(); }