-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
54 lines (42 loc) · 1.58 KB
/
Copy pathProgram.cs
File metadata and controls
54 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
namespace Euler
{
public class Progam
{
private static bool debug = false;
public static void Main()
{
int numberOfRuns = 1;
/* Choose your problem ;P
* Descritpion is available at:
* https://projecteuler.net/problem=<problemNumber>
* or
* https://projecteuler.net/archives
*/
int problemNumber = 80;
string eulerProblemName = "Euler.Euler" + problemNumber;
var eulerType = Type.GetType(eulerProblemName);
if (eulerType == null)
{
throw new Exception($"Euler problem {problemNumber} not found");
}
IEulerProblem? problem = Activator.CreateInstance(type: eulerType) as IEulerProblem;
Console.WriteLine($"\n\nEuler Project problem number {problemNumber}\n");
var watch = System.Diagnostics.Stopwatch.StartNew();
if (debug) Console.SetOut(TextWriter.Null);
for (int i = 0; i < numberOfRuns; i++)
{
problem?.Start();
}
if (debug)
{
var standardOutput = new StreamWriter(Console.OpenStandardOutput());
standardOutput.AutoFlush = true;
Console.SetOut(standardOutput);
}
watch.Stop();
Console.WriteLine();
Console.WriteLine("Time: {0} ms ({1} runs average)\n\n",
watch.ElapsedMilliseconds / numberOfRuns, numberOfRuns);
}
}
}