summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonsykkel <jonrevold@gmail.com>2020-04-05 01:53:35 +0200
committerjonsykkel <jonrevold@gmail.com>2020-04-05 01:53:35 +0200
commit15df55d10b01aef56936ff1d651e2abc7ff500ae (patch)
tree6d8b44a5289e471505c759a4f6f8cd5be2b5f575
parentd7aab7fb313d25b8a870ce3ca9c10d26859fd806 (diff)
downloadct_sequence-15df55d10b01aef56936ff1d651e2abc7ff500ae.tar.gz
mor vork
-rw-r--r--src/main.c61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/main.c b/src/main.c
index 53a65be..0d40355 100644
--- a/src/main.c
+++ b/src/main.c
@@ -4,18 +4,20 @@
#include <string.h>
#include <okelib2/okelib2.h>
-#define U32_MAX ((1ULL<<32)-1)
-#define I32_MAX ((1ULL<<31)-1)
+#define U32_MAX ((1ULL<<32)-1)
+#define I32_MAX ((1ULL<<31)-1)
-#define BITS 36
+#define BITS 36
-static ftimer_t ft;
-static uint8_t *h;
-static uint64_t t;
-static uint64_t n;
-static uint64_t agurk;
-static uint64_t outer;
-static uint64_t last;
+static ftimer_t ft;
+static uint8_t *h;
+static uint64_t t;
+static uint64_t n;
+static uint64_t agurk;
+static uint64_t outer;
+static uint64_t last;
+
+static void (*loop)(uint64_t,uint64_t);
static void fuk(char const *str){
printf("error!( %s\n",str);
@@ -40,6 +42,15 @@ static void init(uint64_t n){
h = malloc(size);
if(!h) fuk("memory");
memset(h,0x00,size);
+
+ t = 0;
+ agurk = n/100;
+ outer = n/agurk+1;
+ last = n%agurk;
+ if(last == 0){
+ last = agurk;
+ outer--;
+ }
}
static uint64_t load_store(uint64_t t,uint64_t i){
@@ -66,13 +77,16 @@ static uint64_t load_store(uint64_t t,uint64_t i){
return r;
}
-static void numper(void){
- for(uint64_t x = 1;x < n;x++){
+static void loop_36(uint64_t x0,uint64_t x1){
+ for(uint64_t x = x0;x < x1;x++){
uint64_t z;
-
z = load_store(t,x);
t = z == 0 ? 0 : x-z;
}
+}
+
+static void numper(void){
+ loop(1,n);
perse(100);
}
@@ -83,13 +97,7 @@ static void numper_perse(void){
uint64_t end = beg+(y == outer-1 ? last : agurk);
if(y == 0) beg++;
- for(uint64_t x = beg;x < end;x++){
- uint64_t z;
-
- z = load_store(t,x);
- t = z == 0 ? 0 : x-z;
- }
-
+ loop(beg,end);
perse((y+1)*100/outer);
}
}
@@ -104,18 +112,9 @@ int main(int argc,char **argv){
printf("n = %llu\n",n); fflush(stdout);
init(n);
- t = 0;
- agurk = n/100;
- outer = n/agurk+1;
- last = n%agurk;
- if(last == 0){
- last = agurk;
- outer--;
- }
-
+ loop = loop_36;
ftimer_init(&ft);
- numper_perse();
-
+ numper();
printf("result = %llu\n",t); fflush(stdout);
return 0;