/* * * I took a brute force approach to this, using some rough math first to know that I should start around 18-20, * After one day, I found a 19 card deal without a set, then continued on with 20 * this random guesser with infinite loops took 5 days on a powerful computer to randomly find the 20 nonset deal * There was a 1 in 4,694,436,188,839,116,720 (I think) chance of this happening per iteration! (I got lucky on the random) * I ran it on 21, but by the deadline the 20 is all I found. I think that this is the true largest anyway * Here's the output of the 20 cards it found without a set: A Purple Striped Oval with the number 1 A Green Striped Diamond with the number 2 A Green Solid Oval with the number 1 A Purple Open Squiggle with the number 3 A Purple Solid Squiggle with the number 2 A Purple Solid Oval with the number 1 A Purple Solid Squiggle with the number 1 A Green Striped Diamond with the number 1 A Purple Solid Oval with the number 2 A Green Open Diamond with the number 3 A Green Solid Oval with the number 2 A Green Striped Oval with the number 1 A Red Striped Diamond with the number 3 A Purple Striped Oval with the number 2 A Purple Striped Squiggle with the number 3 A Green Solid Diamond with the number 3 A Green Striped Oval with the number 2 A Green Solid Squiggle with the number 3 A Purple Striped Diamond with the number 3 A Red Solid Squiggle with the number 3 * Average number of available sets at - * 12: 12!/(9!3!) * 1/79 = 2.78... * 18: 18!/(15!3!) * 1/79 = 10.33 * 19: 19!/(16!3!) * 1/79 = 12.27 * 20: 20!/(17!3!) * 1/79 = 14.43 * */ void SetGame::findLargestNonSet() { vector<Card> NoSetCards; vector<Card> testCards; Deck testDeck; int startNum = 19; for (int num = 0; num < 3; num++) { // this will run for a long time and has a small chance of succeeding!!! for (int i = 0; i < 10000; i++) // while (true) { testDeck.Shuffle(); testDeck.Deal(startNum + num, testCards); if (findAllSets(testCards, false).size() == 0) { cout << "Found no sets in a deal of " << startNum + num << " cards. Continuing with " << startNum + num + 1 << endl; NoSetCards = testCards; break; } else if (i % 100 == 0) { cout << "Testing " << startNum + num << " the " << i << "th time" << endl; } else if (i == 9999) { cout << "Found sets in 10000 random deals of " << startNum + num << " cards" << endl; goto END; } testDeck.Replace(testCards); } } END: printCards(NoSetCards); int x; cin >> x; }