Skip to content

Instantly share code, notes, and snippets.

@hyper-neutrino
Created January 3, 2021 06:03
Show Gist options
  • Save hyper-neutrino/0c30db691e7647614f0c277cb056ac70 to your computer and use it in GitHub Desktop.
Save hyper-neutrino/0c30db691e7647614f0c277cb056ac70 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <functional>
#include <iostream>
#include <random>
#include <string.h>
using namespace std;
const default_random_engine generator;
const uniform_int_distribution<int> distribution(1, 6);
int main() {
int c[7];
srand(0);
auto dice = bind(distribution, generator);
int succ = 0;
for (int i = 0; i < 1000000; i++) {
fill(begin(c), end(c), 0);
int mv = 0;
for (int j = 0; j < 5; j++) mv = max(mv, ++c[dice()]);
for (int mi = 1; mi <= 6; mi++) {
if (c[mi] == mv) {
fill(begin(c), end(c), 0);
c[mi] = mv;
mv = 0;
for (int j = 0; j < 5 - c[mi]; j++) mv = max(mv, ++c[dice()]);
for (int mi = 1; mi <= 6; mi++) {
if (c[mi] == mv) {
fill(begin(c), end(c), 0);
c[mi] = mv;
mv = 0;
for (int j = 0; j < 5 - c[mi]; j++) mv = max(mv, ++c[dice()]);
if (mv == 5) succ++;
goto end;
}
}
}
}
end:;
}
cout << succ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment