-
Notifications
You must be signed in to change notification settings - Fork 0
/
euler.cpp
121 lines (96 loc) · 2.45 KB
/
euler.cpp
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// euler.cpp : Defines the entry point for the console application.
//
#include "Problems.h"
#include "String.h"
#include "Stopwatch.h"
#include <vector>
#include <string>
#include <iostream>
#include <stdio.h>
#include <tchar.h>
#include "Tests.h"
#include "UnitTesting/UnitTesting.h"
using namespace std;
// Global variable to hold all problems, we will add to this in GetProblems
std::map<int, ProblemLambda> allProblems;
int ParseCommandLine(int argc, char* argv[]);
int RunTests();
int main(int argc, char* argv[])
{
int problemNum = ParseCommandLine(argc, argv);
if (problemNum == -1)
return RunTests();
GetProblems();
cout << "Project Euler" << endl << endl;
if(problemNum != 0)
{
allProblems[problemNum].Solve();
cout << "Finished." << endl;
}
else
{
Stopwatch s;
s.Start();
for (auto problem : allProblems)
{
problem.second.Solve();
}
s.Stop();
cout << "Finished in " << s.ElapsedMilliseconds() << "ms in total." << endl;
}
}
// return problem number to solve, 0 for all
int ParseCommandLine(int argc, char* argv[])
{
int iProblemNum = 0;
if(argc > 1)
{
string s(argv[1]);
if (s == "test")
{
return -1;
}
iProblemNum = ToInt(s);
}
return iProblemNum;
}
int RunTests()
{
PokerTest();
GeneralMathsTest();
EndTest
}
/*
vector<Problem*> GetProblems()
{
vector<Problem*> vProblems;
for(int i = 0; i <= 150; i++)
{
vProblems.push_back(NULL);
}
vProblems[1] = new Problem1();
vProblems[2] = new Problem2();
vProblems[3] = new Problem3();
vProblems[4] = new Problem4();
vProblems[5] = new Problem5();
vProblems[6] = new Problem6();
vProblems[7] = new Problem7();
vProblems[8] = new Problem8();
vProblems[9] = new Problem9();
vProblems[10] = new Problem10();
vProblems[11] = new Problem11();
vProblems[12] = new Problem12();
vProblems[13] = new Problem13();
vProblems[14] = new Problem14();
vProblems[15] = new Problem15();
vProblems[16] = new Problem16();
vProblems[17] = new Problem17();
vProblems[18] = new Problem18();
vProblems[19] = new Problem19();
vProblems[20] = new Problem20();
vProblems[21] = new Problem21();
vProblems[22] = new Problem22();
vProblems[23] = new Problem23();
vProblems[67] = new Problem67();
return vProblems;
}*/