void testCase0() { string rules_[] = {"PICK ANY TWO: 10 2 F F", "PICK TWO IN ORDER: 10 2 T F", "PICK TWO DIFFERENT: 10 2 F T", "PICK TWO LIMITED: 10 2 T T"}; vector<string> rules(rules_, rules_ + (sizeof(rules_) / sizeof(rules_[0]))); string expected__[] = {"PICK TWO LIMITED", "PICK TWO IN ORDER", "PICK TWO DIFFERENT", "PICK ANY TWO"}; vector<string> expected_(expected__, expected__ + (sizeof(expected__) / sizeof(expected__[0]))); assertEquals(0, expected_, solution.sortByOdds(rules)); }
void testCase1() { string rules_[] = {"INDIGO: 93 8 T F", "ORANGE: 29 8 F T", "VIOLET: 76 6 F F", "BLUE: 100 8 T T", "RED: 99 8 T T", "GREEN: 78 6 F T", "YELLOW: 75 6 F F"}; vector<string> rules(rules_, rules_ + (sizeof(rules_) / sizeof(rules_[0]))); string expected__[] = {"RED", "ORANGE", "YELLOW", "GREEN", "BLUE", "INDIGO", "VIOLET"}; vector<string> expected_(expected__, expected__ + (sizeof(expected__) / sizeof(expected__[0]))); assertEquals(1, expected_, solution.sortByOdds(rules)); }
int main(){ Lottery L; vector<string> s; s.push_back ("A:100 10 T T"); s.push_back ("B:20 2 F T"); string ss[]= {"INDIGO: 93 8 T F","ORANGE: 29 8 F T","VIOLET: 76 6 F F","BLUE: 100 8 T T","RED: 99 8 T T","GREEN: 78 6 F T","YELLOW: 75 6 F F"}; vector<string> sss(ss,ss+sizeof(ss)/sizeof(string)); L.sortByOdds(sss); cout<< 1- (double)(factorial(90,10)+10*factorial(90,9))/factorial(100,10)<< endl; cout<< (double)factorial(10,2)*factorial(98,8)/factorial(100,10)<<endl; cout<< factorial(5,2)<<endl; }
bool do_test(vector<string> rules, vector<string> __expected) { time_t startClock = clock(); Lottery *instance = new Lottery(); vector<string> __result = instance->sortByOdds(rules); double elapsed = (double)(clock() - startClock) / CLOCKS_PER_SEC; delete instance; if (__result == __expected) { cout << "PASSED!" << " (" << elapsed << " seconds)" << endl; return true; } else { cout << "FAILED!" << " (" << elapsed << " seconds)" << endl; cout << " Expected: " << to_string(__expected) << endl; cout << " Received: " << to_string(__result) << endl; return false; } }
void testCase2() { vector<string> rules; vector<string> expected_; assertEquals(2, expected_, solution.sortByOdds(rules)); }