summaryrefslogtreecommitdiffstats
path: root/mat/advent
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2022-12-15 00:38:24 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2022-12-15 00:38:24 +0100
commit341308c0714028484c4e1ae828c82e8d72ebf2e0 (patch)
treebb2d3b6fcba3804042ffcca705225e41c18f048b /mat/advent
parentknjižnica (diff)
downloadsola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.tar
sola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.tar.gz
sola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.tar.bz2
sola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.tar.lz
sola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.tar.xz
sola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.tar.zst
sola-gimb-4-341308c0714028484c4e1ae828c82e8d72ebf2e0.zip
Diffstat (limited to 'mat/advent')
-rw-r--r--mat/advent/1.c26
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);
+ }
+}