double test2() {
	int t0[] = {1,2,3,4,1,2,3,4,1,2,3,1,2,3,4,1,2,3,3,3};
	vector <int> p0(t0, t0+sizeof(t0)/sizeof(int));
	ManySquares * obj = new ManySquares();
	clock_t start = clock();
	int my_answer = obj->howManySquares(p0);
	clock_t end = clock();
	delete obj;
	cout <<"Time: " <<(double)(end-start)/CLOCKS_PER_SEC <<" seconds" <<endl;
	int p1 = 3;
	cout <<"Desired answer: " <<endl;
	cout <<"\t" << p1 <<endl;
	cout <<"Your answer: " <<endl;
	cout <<"\t" << my_answer <<endl;
	if (p1 != my_answer) {
		cout <<"DOESN'T MATCH!!!!" <<endl <<endl;
		return -1;
	}
	else {
		cout <<"Match :-)" <<endl <<endl;
		return (double)(end-start)/CLOCKS_PER_SEC;
	}
}
Exemplo n.º 2
0
// BEGIN CUT HERE
int main( int argc, char* argv[] ) {
    {
        int sticksARRAY[] = {1,1,2,2,1,1,2};
        vector <int> sticks( sticksARRAY, sticksARRAY+ARRSIZE(sticksARRAY) );
        ManySquares theObject;
        eq(0, theObject.howManySquares(sticks),1);
    }
    {
        int sticksARRAY[] = {3, 1, 4, 4, 4, 10, 10, 10, 10}
           ;
        vector <int> sticks( sticksARRAY, sticksARRAY+ARRSIZE(sticksARRAY) );
        ManySquares theObject;
        eq(1, theObject.howManySquares(sticks),1);
    }
    {
        int sticksARRAY[] = {1,2,3,4,1,2,3,4,1,2,3,1,2,3,4,1,2,3,3,3};
        vector <int> sticks( sticksARRAY, sticksARRAY+ARRSIZE(sticksARRAY) );
        ManySquares theObject;
        eq(2, theObject.howManySquares(sticks),3);
    }
    {
        int sticksARRAY[] = {1,1,1,2,2,2,3,3,3,4,4,4};
        vector <int> sticks( sticksARRAY, sticksARRAY+ARRSIZE(sticksARRAY) );
        ManySquares theObject;
        eq(3, theObject.howManySquares(sticks),0);
    }
    {
        int sticksARRAY[] = {1,1,1,2,1,1,1,3,1,1,1};
        vector <int> sticks( sticksARRAY, sticksARRAY+ARRSIZE(sticksARRAY) );
        ManySquares theObject;
        eq(4, theObject.howManySquares(sticks),2);
    }
    {
        int sticksARRAY[] = {2,2,4,4,8,8};
        vector <int> sticks( sticksARRAY, sticksARRAY+ARRSIZE(sticksARRAY) );
        ManySquares theObject;
        eq(5, theObject.howManySquares(sticks),0);
    }
	return 0;
}