|
Here's the code, it allows a param to specify the level, default is 100.
uint16384_t allows computation to slightly above level 40000.
#include <chrono>
#include <ctime>
#include <boost multiprecision="" cpp_int.hpp="">
// g++ xxx.cpp -std=c++11 -march=corei7
using namespace std;
using namespace boost::multiprecision;
typedef number<cpp_int_backend<1024 *="" 16,="" 1024="" unsigned_magnitude,="" unchecked,="" void=""> > uint16384_t;
uint32_t maxLevel = 100;
static chrono::time_point<chrono::system_clock> start, timeFinished;
const uint32_t levelSize[] = { 4, 7, 12, 12, 4, 5, 12, 6, 8, 10, // 1-10
10, 14, 12, 14, 18, 42, 42, 26, 14, 28, // 11-20
14, 24, 24, 5, 7, 10, 10, 8, 2, 9, // 21-30
9, 23, 2, 6, 32, 32, 8, 3, 5, 6, // 31-40
10, 18, 18, 6, 10, 8, 7, 8, 12, 20, // 41-50
34, 34, 20, 10, 7, 7, 11, 13, 21, 17, // 51-60
2, 1, 4, 7, 14, 14, 7, 4, 6, 8, // 61-70
10, 16, 28, 28, 9, 12, 12, 16, 18, 24, // 71-80
23, 16, 6, 5, 15, 6, 10, 10, 3, 27, // 81-90
27, 5 }; // 91-92
vector<uint32_t> levelEvolution[] = {
{63},
{64, 62},
{65},
{66},
{68}, // 1-5
{69},
{84, 55},
{70},
{71},
{76}, // 6-10
{77},
{82},
{78},
{79},
{80}, // 11-15
{81, 29, 91},
{81, 29, 90},
{81, 30},
{75, 29, 92},
{75, 32}, // 16-20
{72},
{73},
{74},
{83},
{86}, // 21-25
{87},
{88},
{89, 92},
{1},
{3}, // 26-30
{4},
{2, 61, 29, 85},
{5},
{28},
{24, 33, 61, 29, 91}, // 31-35
{24, 33, 61, 29, 90},
{7},
{8},
{9},
{10}, // 36-40
{21},
{22},
{23},
{11},
{19}, // 41-45
{12},
{13},
{14},
{15},
{18}, // 46-50
{16},
{17},
{20},
{6, 61, 29, 92},
{26}, // 51-55
{27},
{25, 29, 92},
{25, 29, 67},
{25, 29, 85},
{25, 29, 68, 61, 29, 89}, // 56-60
{61},
{33},
{40},
{41},
{42}, // 61-65
{43},
{38, 39},
{44},
{48},
{54}, // 66-70
{49},
{50},
{51},
{52},
{47, 38}, // 71-75
{47, 55},
{47, 56},
{47, 57},
{47, 58},
{47, 59}, // 76-80
{47, 60},
{47, 33, 61, 29, 92},
{45},
{46},
{53}, // 81-85
{38, 29, 89},
{38, 30},
{38, 31},
{34},
{36}, // 86-90
{35},
{37} // 91-92
};
uint16384_t levelCounts[92];
uint16384_t evolvedLevelCounts[92];
int main(int argc, char** argv)
{
if (argc != 1)
{
maxLevel = atoi(argv[1]);
if (maxLevel < 9)
{
maxLevel = 10;
}
}
start = chrono::system_clock::now();
time_t start_time = chrono::system_clock::to_time_t(start);
cout << "Starting run of " << maxLevel << " levels at " << ctime(&start_time) << endl;
for (auto& sequence: levelEvolution)
{
for (auto& seq: sequence )
{
--seq; // Adjust indices for 0-based array
}
}
for (uint32_t i = 0; i < 92; ++i)
{
levelCounts[i] = 0;
}
// Prime the counts for the starting level (9).
levelCounts[23] = 1;
levelCounts[38] = 1;
uint16384_t * workingCounts = levelCounts;
uint16384_t * evolvedCounts = evolvedLevelCounts;
for (uint32_t i = 9; i <= maxLevel; ++i)
{
for (uint32_t j = 0; j < 92; ++j)
{
evolvedCounts[j] = 0;
}
for (uint32_t j = 0; j < 92; ++j)
{
if (workingCounts[j] != 0)
{
for (auto& level: levelEvolution[j])
{
evolvedCounts[level] += workingCounts[j];
}
}
}
uint16384_t totals = 0;
for (uint32_t j = 0; j < 92; ++j)
{
if (evolvedCounts[j] != 0)
{
totals += evolvedCounts[j] * levelSize[j];
}
}
cout << i << " " << totals << endl;
swap(workingCounts, evolvedCounts);
}
timeFinished = chrono::system_clock::now();
chrono::duration<double> elapsed_seconds = timeFinished - start;
time_t end_time = chrono::system_clock::to_time_t(timeFinished);
cout << "finished computation at " << ctime(&end_time)
<< "elapsed time: " << elapsed_seconds.count() << "secs" << endl;
}
|
|
|
|