This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #CS352 Homework 2, Summer '12 | |
| #Victoria Wu | |
| #Josephus Problem | |
| #----------------- | |
| #N people are in a circle, with first person (1) holding a hot potato. | |
| #After M passes of the potato, the person holding the potato is out, and the | |
| #game continues with the next person in line picking up the potato. | |
| #Continue until one person remains. Who will be the victor, given (N>0, M>=0)? | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #CS352 - Homework 2, Summer '12 | |
| #Victoria Wu | |
| #Write a program to check for balancing symbols. | |
| #Input from user | |
| def balancing(meat): | |
| stk = [] | |
| right = ["(","[","{"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 1000; x < 5000; x += 500) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that no terms are like, and nothing | |
| //will simplify. | |
| term t1(i+1, i+2, i+3); | |
| term t2(i+2, i+1, i+1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| long Poly::simplifyTester() | |
| { | |
| long time = 0; | |
| list<term>* p = this->getTerms(); | |
| list<term>* tempList = new list<term>(); | |
| if(!p->empty()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 1000; x < 5000; x += 500) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that all terms are alike. | |
| term t1(i+1, 2,2); | |
| term t2(i+2, 2,2); | |
| pol1->addTerm(t1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 1000; x <= 8000; x += x) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that all terms are alike. | |
| term t1(i+1, 2,2); | |
| term t2(i+2, 2,2); | |
| pol1->addTerm(t1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 1000; x <= 32000; x += x) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that all terms are alike. | |
| term t1(i+1, 2,2); | |
| term t2(i+2, 2,2); | |
| pol1->addTerm(t1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 1000; x < 16000; x += x) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that no terms are like, and nothing | |
| //will simplify. | |
| term t1(i+1, i+2, i+3); | |
| term t2(i+2, i+1, i+1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 1000; x < 16000; x += x) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that no terms are alike, | |
| //but both polynomials are equal. | |
| term t1(i+1, 2,2+i); | |
| term t2(i+2, 2,2+i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for(int x = 100; x < 800; x += x) | |
| { | |
| Poly* pol1 = new Poly(); | |
| Poly* pol2 = new Poly(); | |
| for(int i = 0; i < x; i++) | |
| { | |
| //This ensures that no terms are like, and nothing | |
| //will simplify. | |
| term t1(i+1, i+2, i+3); | |
| term t2(i+2, i+1, i+1); |
OlderNewer