public static void CallGoogleInterview() { var case1 = new[] { 1, 2, 3, 9 }; var case2 = new[] { 1, 2, 4, 4 }; var sum = 8; var result0Case1 = Ex0.Solve(case1, sum); var result0Case2 = Ex0.Solve(case2, sum); var result1Case1 = Ex1.Solve(case1, sum); var result1Case2 = Ex1.Solve(case2, sum); var result2case1 = Ex2.Solve(case1, sum); var result2case2 = Ex2.Solve(case2, sum); }
private void toolStripButton1_Click(object sender, EventArgs e) { if (goodInput && !loading) { loading = true; toolStripButton1.Enabled = false; if (iterations >= 100000) { DialogResult option = MessageBox.Show("Running " + iterations + " simulations will " + "take approximately: " + getTime() + "\nDo you wish to continue?", "Alert", MessageBoxButtons.OKCancel); if (option == DialogResult.Cancel) { goto Done; } } try { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } } catch (Exception Ex0) { var nullErrorMessageBox = MessageBox.Show ("ERROR disposing old image file! \nOutput: " + Ex0.ToString(), "Alert", MessageBoxButtons.OK); } RscriptWriter(); userInputScript = rPathDest; Console.WriteLine("userInputScript: " + userInputScript); outputLocation = RpathFinder(); Console.WriteLine("outputLocation: " + outputLocation); try { RunFromCmd(userInputScript, userInputCSV, outputLocation, iterations.ToString(), distributionType); } catch (Exception Ex1) { var nullErrorMessageBox = MessageBox.Show ("ERROR on CMD process! \nOutput: " + Ex1.ToString(), "Alert", MessageBoxButtons.OK); } try { Cursor.Current = Cursors.WaitCursor; toolStripButton1.BackColor = Color.GreenYellow; if (iterations >= 10000000) { Thread.Sleep(Convert.ToInt32(iterations * 0.10)); } else if (iterations >= 100000 && iterations < 10000000) { Thread.Sleep(Convert.ToInt32(iterations * 0.30)); } else if (iterations >= 10000 && iterations < 100000) { Thread.Sleep(Convert.ToInt32(iterations * 0.50)); } else { Thread.Sleep(2500); } } catch (Exception Ex2) { var nullErrorMessageBox = MessageBox.Show ("ERROR waiting for process to complete! \nOuput: " + Ex2.ToString(), "Alert", MessageBoxButtons.OK); } try { pictureBox1.Image = Image.FromFile(RpathFinder() + @"\output.png"); } catch (Exception Ex3) { var nullErrorMessageBox = MessageBox.Show ("ERROR loading the image file! \nOuput: " + Ex3.ToString(), "Alert", MessageBoxButtons.OK); } Done: try { if (!string.IsNullOrWhiteSpace(userInputScript)) { DeleteTempFile(userInputScript); } //if (!string.IsNullOrWhiteSpace(userInputScript)) //DeleteTempFile(RpathFinder() + @"\output.png"); loading = false; maxWarning = false; minWarning = false; } catch (Exception Ex4) { var nullErrorMessageBox = MessageBox.Show ("ERROR on cleanup process! \nOutput: " + Ex4.ToString(), "Alert", MessageBoxButtons.OK); } } }