Created
November 25, 2012 23:52
-
-
Save olaugh/4145918 to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#define PRINT_RACKS 0 | |
static const char NUM_TILES = 27; | |
int main(int argc, char **argv) { | |
char tiles[NUM_TILES][2] = { | |
{'A', 9}, {'B', 2}, {'C', 2}, {'D', 4}, {'E', 12}, {'F', 2}, {'G', 3}, | |
{'H', 2}, {'I', 9}, {'J', 1}, {'K', 1}, {'L', 4}, {'M', 2}, {'N', 6}, | |
{'O', 8}, {'P', 2}, {'Q', 1}, {'R', 6}, {'S', 4}, {'T', 6}, {'U', 4}, | |
{'V', 2}, {'W', 2}, {'X', 1}, {'Y', 2}, {'Z', 1}, {'?', 2} | |
}; | |
int num_racks = 0; | |
for (int i0 = 0; i0 < NUM_TILES; ++i0) { | |
--tiles[i0][1]; | |
for (int i1 = i0; i1 < NUM_TILES; ++i1) { | |
if (tiles[i1][1] == 0) continue; | |
--tiles[i1][1]; | |
for (int i2 = i1; i2 < NUM_TILES; ++i2) { | |
if (tiles[i2][1] == 0) continue; | |
--tiles[i2][1]; | |
for (int i3 = i2; i3 < NUM_TILES; ++i3) { | |
if (tiles[i3][1] == 0) continue; | |
--tiles[i3][1]; | |
for (int i4 = i3; i4 < NUM_TILES; ++i4) { | |
if (tiles[i4][1] == 0) continue; | |
--tiles[i4][1]; | |
for (int i5 = i4; i5 < NUM_TILES; ++i5) { | |
if (tiles[i5][1] == 0) continue; | |
--tiles[i5][1]; | |
for (int i6 = i5; i6 < NUM_TILES; ++i6) { | |
if (tiles[i6][1] == 0) continue; | |
#if PRINT_RACKS | |
std::cout << tiles[i0][0] << tiles[i1][0] << tiles[i2][0] | |
<< tiles[i3][0] << tiles[i4][0] << tiles[i5][0] | |
<< tiles[i6][0] << std::endl; | |
#endif | |
++num_racks; | |
} | |
++tiles[i5][1]; | |
} | |
++tiles[i4][1]; | |
} | |
++tiles[i3][1]; | |
} | |
++tiles[i2][1]; | |
} | |
++tiles[i1][1]; | |
} | |
++tiles[i0][1]; | |
} | |
std::cout << num_racks << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment