diff options
Diffstat (limited to 'mat')
-rw-r--r-- | mat/advent/1.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mat/advent/1.c b/mat/advent/1.c new file mode 100644 index 0000000..3a50f34 --- /dev/null +++ b/mat/advent/1.c @@ -0,0 +1,26 @@ +#include <stdlib.h> +#include <stdio.h> +int main (void) { + unsigned vseh = 0; + unsigned zmagajočih = 0; + while (1) { + int točke[40] = { 11, 10, 4, 3, 2, 11, 10, 4, 3, 2, 11, 10, 4, 3, 2, 11, 10, 4, 3, 2 }; + long p = random(); + while (p >= 2147483640) + p = random(); + p %= 40; + long d = random(); + while (d >= 2147483640) + d = random(); + d %= 40; + long t = random(); + while (t >= 2147483640) + t = random(); + t %= 40; + vseh++; + if (točke[p] + točke[d] + točke[t] > 0) + zmagajočih++; + if (!(vseh % 1024) && vseh > 1e5) + printf("\rvseh %u\tzmagajočih %u\tverjetnost %f\t", vseh, zmagajočih, (double) zmagajočih / (double) vseh); + } +} |