int main() { ////Level one //MergersDivOne md; ////int input[3] = {5, -7, 3}; //int input[6] = {10, -10, 100, -100, 1000, -1000}; //double result = md.findMaximum(input, 6); //printf("result is %f\n",result); //Level two int input[20] = {382828264, 942663792, 291832707, 887961277, 546603677, 545185615, 146267547, 6938117, 167567032, 84232402, 700781193, 452172304, 816532384, 951089120, 448136091, 280899512, 256093435, 39595226, 631504901, 154772240}; RollingDiceDivOne rd; long result = rd.mostLikely(input, 20); printf("result is %d\n", result); return 0; }
// BEGIN KAWIGIEDIT TESTING // Generated by KawigiEdit 2.1.4 (beta) modified by pivanof bool KawigiEdit_RunTest(int testNum, vector <int> p0, bool hasAnswer, long long p1) { cout << "Test " << testNum << ": [" << "{"; for (int i = 0; int(p0.size()) > i; ++i) { if (i > 0) { cout << ","; } cout << p0[i]; } cout << "}"; cout << "]" << endl; RollingDiceDivOne *obj; long long answer; obj = new RollingDiceDivOne(); clock_t startTime = clock(); answer = obj->mostLikely(p0); clock_t endTime = clock(); delete obj; bool res; res = true; cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl; if (hasAnswer) { cout << "Desired answer:" << endl; cout << "\t" << p1 << endl; } cout << "Your answer:" << endl; cout << "\t" << answer << endl; if (hasAnswer) { res = answer == p1; } if (!res) { cout << "DOESN'T MATCH!!!!" << endl; } else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) { cout << "FAIL the timeout" << endl; res = false; } else if (hasAnswer) { cout << "Match :-)" << endl; } else { cout << "OK, but is it right?" << endl; } cout << "" << endl; return res; }
void testCase4() { int dice_[] = {382828264, 942663792, 291832707, 887961277, 546603677, 545185615, 146267547, 6938117, 167567032, 84232402, 700781193, 452172304, 816532384, 951089120, 448136091, 280899512, 256093435, 39595226, 631504901, 154772240}; vector<int> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); long long expected_ = 4366828428LL; assertEquals(4, expected_, solution.mostLikely(dice)); }
void testCase3() { int dice_[] = {1, 10, 1}; vector<int> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); long long expected_ = 3LL; assertEquals(3, expected_, solution.mostLikely(dice)); }
void testCase2() { int dice_[] = {2, 3, 4, 5}; vector<int> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); long long expected_ = 9LL; assertEquals(2, expected_, solution.mostLikely(dice)); }
void testCase0() { int dice_[] = {6, 6, 8}; vector<int> dice(dice_, dice_ + (sizeof(dice_) / sizeof(dice_[0]))); long long expected_ = 11LL; assertEquals(0, expected_, solution.mostLikely(dice)); }