Fixed a major issue in the stergios.c where LIMIT was int32_t instead of int128_t and also implented a version where a user can run the stergios step counter from a file (example format being in the example file).

This commit is contained in:
metallaxis committed 2026-06-28 00:03:49 +03:00
1 parent 9d7b7016d2
commit 7decb09e2f
31 files changed
+65367 -14

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# Editor files
*.swp
# Environment files
.env
flake.lock
# Build/Test files
obj/
build/
bin/
test/
+1 -1
View File
@@ -30,7 +30,7 @@ INCLUDE_FLAGS = -Iinclude
# Linux-specific information
LINUX_CC = gcc
LINUX_CFLAGS = -O3 $(INCLUDE_FLAGS) -MMD -MP -Wall -Wextra -Werror -pedantic
LINUX_LDFLAGS = -O3 $(INCLUDE_FLAGS)
LINUX_LDFLAGS = -O3 $(INCLUDE_FLAGS) -lreadline
# Windows-specific information
WINDOWS_CC = x86_64-w64-mingw32-gcc
+33
View File
@@ -0,0 +1,33 @@
# Stergios - A Math Problem
## Cloning
```sh
git clone https://gitea.metallaxis.net/metallaxis/stergios.git
```
## Compiling
After cloning the repository run the following command:
```sh
make help (For the help menu)
make (Will compile for the OS you are on (works only for windows and linux))
make build linux/windows
make debug linux/windows (Compile with debug flags in the c code)
make --debug linux/windows (Compile with Makefile debug information)
```
## Running
```sh
make && ./bin/stergios (Normal version)
make && echo -e "2\n2\n" | time ./bin/stergios (Run the version for the expontial being 7 and low info printing and time the amount of time it takes to execute)
```
## Nix Flakes
For anyone using nix flakes to enter the developemnt environment with everything required run (while on the main folder):
```sh
nix develop .
```
## Contributing
## Sources
[Stergios Information](https://progintro.github.io/assets/pdf/stergios.pdf)
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1,3 +1,7 @@
# Exponential
20
# Values
0
162494245745398336
354799481300862976
+73
View File
@@ -0,0 +1,73 @@
# Exponential
3
# Values
0
31
76
102
146
178
196
221
256
265
276
284
286
2146
2148
2156
2167
2176
2211
2236
2254
2286
2330
2356
2401
2432
2496
2533
2596
2726
2806
2860
2951
3069
3136
3324
3476
3562
3706
3996
4171
4288
4655
4876
5270
5586
5764
6061
6656
7252
7998
8446
9243
9881
10240
12036
13234
14732
15631
19228
22826
25225
28224
37222
44421
55220
73219
109218
217217
+143
View File
@@ -0,0 +1,143 @@
# Exponential
4
# Values
0
346
856
1156
1596
1676
2068
2296
2509
2626
2816
2871
3136
3286
3367
3496
3612
3704
3796
3916
3976
4046
4056
4081
4090
4096
18496
18502
18511
18536
18546
18616
18676
18796
18888
18980
19096
19225
19306
19456
19721
19776
19966
20083
20296
20524
20916
20996
21436
21736
22246
22592
22701
22914
23296
23698
23941
24376
25256
25756
26596
27160
28106
28296
28939
29326
30016
31171
31944
32186
32657
33496
34372
35836
37716
38776
40546
41728
43701
44096
45430
46231
47656
51620
52116
54796
56584
59566
62177
63386
65536
69121
71512
76296
78988
83476
91458
92456
97846
101440
107431
112674
115101
119416
131404
140996
146392
155386
171377
173376
184171
191368
213860
227356
251350
270546
281344
299341
335336
371332
416328
443326
491323
529721
551320
659316
731314
821312
875311
1091308
1307306
1451305
1631304
2171302
2603301
3251300
4331299
6491298
12971297
+249
View File
@@ -0,0 +1,249 @@
# Exponential
5
# Values
0
2576
3676
9136
12376
14185
15457
17176
18056
20016
20851
22408
24976
27406
28756
30976
31626
33068
34226
34816
36676
37702
39376
40936
41791
42224
43176
43576
44821
45496
46576
47554
48076
48336
48896
49126
49540
50176
50716
50986
51376
51476
51672
51801
51856
51976
52003
163549
163576
163696
163751
163880
164076
164176
164566
164836
165376
166012
166426
166656
167216
167476
167998
168976
170056
170731
171976
172376
173328
173761
174616
176176
177850
178876
180736
181326
182484
183926
184576
186796
188146
190576
193144
194701
195536
197496
198376
200095
201367
203176
206416
211876
212976
215552
216706
218956
222976
227188
229726
234256
235676
238442
241851
243376
248536
251641
257176
262960
264771
268296
272636
274576
281134
285076
292096
303826
306176
311664
314116
318886
327376
336232
341551
351016
353976
359733
363973
369976
380656
398476
410368
414086
421316
430206
434176
447580
455626
469936
493801
498576
509720
514696
524371
541576
559504
589396
595376
615562
627676
649216
685126
709072
716556
731106
748991
756976
783928
800101
828856
868175
886376
908748
918736
972676
1008640
1068586
1080576
1121044
1145326
1188496
1260451
1308424
1323416
1352561
1404376
1458352
1548316
1627038
1663476
1708262
1728256
1836226
1908208
2028181
2052176
2133160
2181751
2268136
2508100
2538096
2700076
2808064
2988046
3145532
3218426
3308019
3348016
3564001
3707992
3995976
4157968
4427956
4907938
4967936
5291926
5507920
5867911
6182904
6328701
6587896
7307884
7883876
8207872
8747866
9707857
9827856
10475851
10907848
12257840
13067836
14507830
15659826
16307824
17387821
19547816
21707812
24407808
26027806
28907803
31211801
32507800
38987796
43307794
48707792
51947791
64907788
77867786
86507785
97307784
129707782
155627781
194507780
259307779
388907778
777707777
+402
View File
@@ -0,0 +1,402 @@
# Exponential
6
# Values
0
4453
26656
38056
63536
74431
84206
94816
128656
147610
160966
179056
188336
209056
217906
225841
234448
237660
253656
261856
287956
302536
326656
333756
349576
362356
368896
383456
389656
401212
409321
420256
438256
443531
448246
453344
455242
464656
469456
480096
484606
488631
492976
506656
514189
519436
526456
530016
537856
541156
547240
548408
554156
557056
566056
570916
574255
578656
580856
585616
587581
589306
591136
595056
596656
599518
601426
603856
607456
608406
609211
610032
610324
611656
612256
613376
613756
614296
614656
1478656
1479016
1479556
1479936
1481056
1481656
1482988
1483280
1484101
1484906
1485856
1489456
1491886
1493794
1496656
1498256
1502176
1504006
1505731
1507696
1512456
1514656
1519057
1522396
1527256
1536256
1539156
1544904
1546072
1552156
1555456
1563296
1566856
1573876
1579123
1586656
1600336
1604681
1608706
1613216
1623856
1628656
1638070
1639968
1645066
1649781
1655056
1673056
1683991
1692100
1703656
1709856
1724416
1730956
1743736
1759556
1766656
1790776
1805356
1831456
1839656
1855652
1858864
1867471
1875406
1884256
1904976
1914256
1932346
1945702
1964656
1998496
2009106
2018881
2029776
2055256
2066656
2088859
2093312
2105236
2128456
2169856
2213128
2239156
2253056
2285536
2300056
2328316
2349145
2363106
2378656
2431216
2462806
2519056
2536656
2570898
2577760
2596126
2613031
2631856
2675816
2695456
2733661
2761804
2801656
2872576
2894756
2937896
2990956
3014656
3069984
3094696
3142756
3228256
3317392
3345261
3370906
3399456
3466096
3495856
3553726
3596338
3624881
3656656
3763936
3828331
3942856
3978656
4048265
4062208
4099516
4172056
4261236
4301056
4435480
4516156
4659616
4704456
4791636
4855819
4898806
4946656
5058320
5108176
5205106
5377456
5557024
5613146
5664781
5722256
5856376
5916256
6032671
6118372
6239656
6455296
6814756
6886656
7054432
7129336
7274956
7453946
7533856
7803568
7965406
8253136
8343056
8517866
8646550
8732731
8828656
9052488
9152416
9346681
9692056
10051840
10164276
10382856
10651516
10771456
11176264
11419156
11850976
12441377
12570706
12714656
13050544
13200496
13492006
13850301
14010256
14550112
14874031
15449896
15629856
15979701
16237228
16601656
17049572
17249536
18329356
19049248
19274216
19711556
20249086
20489056
21298960
21784906
22648816
23829954
24088681
24376656
25048600
25348576
25931731
26968456
28048384
29848276
30208256
31423192
32152156
33048114
33448096
35608006
37047952
37497936
38372706
39447871
39927856
41547808
42519781
44247736
46610180
47703656
49047628
49647616
52887556
55047520
58647466
59367456
61797424
63255406
65047385
65847376
70167331
73047304
73947296
75696881
78807256
82047232
87447196
92172168
94359156
97047142
98247136
104727106
109047088
116247061
117687056
122547040
125463031
130647016
145046980
146846976
156566956
163046944
173846926
183296912
187670906
193046899
195446896
208406881
217046872
234326856
244046848
260246836
289046818
292646816
312086806
325046800
346646791
365546784
374294781
389846776
433046764
467606756
487046752
519446746
577046737
584246736
623126731
649046728
730046720
778646716
865046710
934166706
973046704
1037846701
1167446696
1297046692
1459046688
1556246686
1729046683
1867286681
1945046680
2333846676
2593046674
2917046672
3111446671
3889046668
4666646666
5185046665
5833046664
7777046662
9332246661
11665046660
15553046659
23329046658
46657046657
+602
View File
@@ -0,0 +1,602 @@
# Exponential
7
# Values
0
45406
271936
388336
648736
760186
860236
968896
1009484
1211936
1315936
1510660
1648036
1834336
1930016
2143936
2235436
2317546
2406688
2439976
2605936
2691136
2881536
2962936
3035961
3115216
3222541
3367936
3442536
3509443
3609136
3680311
3744136
3813376
3839218
3967936
4033936
4157272
4181216
4244086
4300436
4361536
4555936
4613186
4664476
4720064
4740796
4843936
4896736
5014336
5064436
5109286
5157856
5175960
5265936
5311936
5397634
5457736
5538736
5580096
5595499
5671936
5710936
5745781
5783440
5797456
5834161
5866936
5902336
5980736
6013936
6075496
6118426
6175936
6205136
6269536
6296686
6320836
6346816
6356452
6403936
6427936
6472108
6480576
6502636
6522186
6543136
6607936
6626436
6642766
6660192
6666616
6697936
6713536
6747136
6760936
6773011
6785776
6790448
6802471
6812936
6823936
6843457
6856336
6865061
6872536
6880256
6883030
6895936
6901936
6911944
6913696
6917986
6921436
6924736
6930336
6931936
6933556
13626316
13627936
13629536
13635136
13638436
13641886
13646176
13647928
13657936
13663936
13676842
13679616
13687336
13694811
13703536
13716415
13735936
13746936
13757401
13769424
13774096
13786861
13798936
13812736
13846336
13861936
13893256
13899680
13917106
13933436
13951936
14016736
14037686
14057236
14079296
14087764
14131936
14155936
14203420
14213056
14239036
14263186
14290336
14354736
14383936
14441446
14484376
14545936
14579136
14657536
14692936
14725711
14762416
14776432
14814091
14848936
14887936
14964373
14979776
15021136
15102136
15162238
15247936
15293936
15383912
15402016
15450586
15495436
15545536
15663136
15715936
15819076
15839808
15895396
15946686
16003936
16198336
16259436
16315786
16378656
16402600
16525936
16591936
16720654
16746496
16815736
16879561
16950736
17050429
17117336
17191936
17337331
17444656
17523911
17596936
17678336
17868736
17953936
18119896
18153184
18242326
18324436
18415936
18629856
18725536
18911836
19049212
19243936
19347936
19550388
19590976
19699636
19799686
19911136
20171536
20287936
20514466
20559872
20681416
20793311
20917936
21339136
21470936
21592261
21727376
21778768
21916321
22042936
22183936
22458247
22513216
22660336
22946536
23157370
23298636
23455936
23987296
24153486
24306436
24476736
24874336
25051936
25397356
25466560
25651756
25822186
26011936
26454896
26652736
27037486
27320824
27721936
27935936
28352090
28435456
28658536
28863811
29092336
29411767
29625736
29863936
30327121
30419904
30668176
31150936
32009536
32277936
32799816
32904352
33184066
33441436
33727936
34396576
34695136
35275636
35703028
35989286
36307936
37383616
37719836
38029186
38373536
39177136
39535936
40233526
40373248
40747096
41091061
41473936
42367416
42766336
43541911
44112880
44533731
44920936
45351936
46189869
46357696
46806736
47679736
48322414
48752836
49231936
50349920
50849056
51819436
53544736
54083936
55132196
55342144
55903876
56420686
56995936
58338256
58937536
60102586
60960232
61534611
62173936
64331776
65006136
65626561
66317136
67282213
67928536
68647936
70046491
70326592
71076016
72532936
74323676
75123136
77821408
78664646
79440436
80303936
82318816
83218336
84967036
86254300
87116386
88075936
90314928
91314496
93257686
96712336
97791936
99890706
100311040
101435656
102470311
103621936
106309096
107508736
109840861
111557584
113986936
118305856
119655536
122279336
124210762
125504236
126943936
130303264
131802976
134718436
138301806
139901536
145300672
146987916
148540186
150267936
154299376
156099136
159597886
162173368
163898161
165817936
170297432
172297216
176184811
181155695
183096136
185255936
189454601
190295488
192545296
196918936
202294516
204694336
212793760
217653436
226292896
228992736
234241236
238104724
240692086
243571936
250291600
253291456
259123186
266290871
269490736
280290304
283665176
286770061
290225936
298289656
301889536
308887711
314039152
321328936
330288684
334288576
352006878
355888036
360207936
370287712
374787616
383535436
394287226
399087136
415286848
425006686
442286416
447686336
458183786
465911080
471086011
476845936
490285768
496285696
507949561
528685336
550285120
557035056
570156936
586284796
593484736
617784544
632364436
650284310
658284256
693721532
701483986
710123936
730283824
739283776
756779686
778283581
787883536
820283392
839723311
874283176
885083136
906078261
921533008
943402936
970282852
982282816
1047082636
1090282528
1103782496
1130026436
1162282366
1176682336
1225282240
1254442186
1290282123
1306282096
1377156984
1392681961
1409961936
1450281880
1468281856
1503273811
1565481736
1630281664
1738281556
1759881536
1832781472
1876521436
1930281394
1954281376
2083881286
2170281232
2197281216
2249769186
2314281151
2343081136
2440281088
2498601061
2602281016
2744030960
2809640936
2890280908
2926280896
3120680836
3250280800
3466280746
3509480736
3655280704
3742760686
3850280665
3898280656
4157480611
4330280584
4384280576
4489256561
4675880536
4870280512
5194280476
5477780448
5609000436
5770280422
5842280416
6231080386
6490280368
6922280341
7008680336
7300280320
7475240311
7786280296
8650280260
8758280256
9341480236
9730280224
10378280206
10945280192
11207720186
11530280179
11674280176
12451880161
12970280152
14007080136
14590280128
15562280116
17290280098
17506280096
18672680086
19450280080
20746280071
21880280064
22405160061
23338280056
25930280044
28003880036
29170280032
31114280026
34570280017
35002280016
37335080011
38890280008
43750280000
46666279996
51850279990
55997479986
58330279984
62218279981
69994279976
77770279972
87490279968
93322279966
103690279963
111984679961
116650279960
139978279956
155530279954
174970279952
186634279951
233290279948
279946279946
311050279945
349930279944
466570279942
559882279941
699850279940
933130279939
1399690279938
2799370279937
+864
View File
@@ -0,0 +1,864 @@
# Exponential
8
# Values
0
459316
2751616
3930016
4988269
6567616
7697116
8711416
9813376
10225096
12279616
13335616
15313960
15698816
16710616
17619116
18606016
19580096
19944001
21759616
22692616
23530276
24440128
24780016
25673491
26475616
27346816
27672250
29295616
30129616
30878266
31691296
31994976
32793166
33509616
34287616
35055216
35744158
36771616
37505866
38164816
38880256
39147436
40479616
41163616
41777371
42443632
42692416
43346116
43932616
44569216
44806904
45991616
46599616
47199116
47736856
48320384
48538216
49623616
50180416
50388247
51423616
51954616
52430716
52947136
53139856
53645941
54099616
54591616
55510804
55689216
56157616
56577366
56618991
57032416
57480576
57647746
58479616
58905616
59287186
59700640
59854816
60259366
60621616
61014016
61160308
61887616
62259616
62592541
62952976
63087296
63439516
63754616
64095616
64430816
64730575
65175616
65492116
65775016
66080896
66194776
66759616
67047616
67582648
67686016
67956616
68198116
68458816
68555760
68809411
69035616
69279616
69518616
69731596
69961152
70046416
70269241
70467616
70681216
70760494
71151616
71349616
71525566
71714656
71784736
71967466
72129616
72303616
72623242
72684416
72843616
72984491
72998366
73135216
73281536
73335556
73599616
73731616
73847881
73971664
74017216
74135116
74238616
74348416
74388712
74583616
74679616
74851336
74883456
74965816
75037116
75111616
75182016
75207493
75327616
75384616
75432916
75482176
75499696
75543391
75579616
75615616
75673180
75682816
75705616
75722866
75738016
75742688
75752326
75757616
75759616
127599616
127601616
127606906
127616544
127621216
127636366
127653616
127676416
127686052
127743616
127779616
127815841
127859536
127877056
127926316
127974616
128031616
128151739
128177216
128247616
128322116
128393416
128475776
128507896
128679616
128775616
128970520
129010816
129120616
129224116
129342016
129387568
129511351
129627616
129759616
130023676
130077696
130224016
130360866
130374741
130515616
130674816
130735990
131055616
131229616
131391766
131574496
131644576
131833666
132009616
132207616
132598738
132678016
132891616
133089991
133312816
133398080
133627636
133840616
134079616
134323616
134549821
134803472
134900416
135161116
135402616
135673216
135776584
136311616
136599616
137164456
137278336
137584216
137867116
138183616
138628657
138928416
139263616
139604616
139919716
140271936
140406256
140766691
141099616
141471616
142198924
142345216
142737616
143099866
143504416
143658592
144072046
144453616
144879616
145711486
145878656
146326816
146740241
146781866
147201616
147670016
147848428
148767616
149259616
149713291
150219376
150412096
150928516
151404616
151935616
152970985
153178816
153735616
154821016
155038848
155622376
156160116
156759616
157367616
158552328
158790016
159426616
160013116
160666816
160915600
161581861
162195616
162879616
164211796
164478976
165194416
165853366
166587616
167615074
168304016
169071616
169849616
170566066
171364256
171667936
172480966
173229616
174063616
175686982
176012416
176883616
177685741
178579216
178919104
179828956
180666616
181599616
183415231
183779136
184753216
185740116
186648616
187660416
188045272
190023616
191079616
193134136
193545856
194647816
195662116
196791616
198370963
199429216
200607616
202899916
203359232
204588496
205719866
205833641
206979616
208255616
210737540
211234816
212565616
213790366
215154016
215672608
217060426
218337616
219759616
222525226
223079296
224562016
225926491
227445616
229569220
230991816
232575616
234179616
235655641
237298896
237923776
239595916
241134616
242847616
246178723
246846016
248631616
252103816
252799360
254660536
256373116
258279616
262729376
264716416
266728616
268580116
270641216
271424944
273522031
275451616
277599616
281776156
282612736
284851216
286910866
289203616
292408102
294554416
296943616
301588966
302519424
305009056
307299741
307530066
309849616
312431616
317451714
318457216
321147616
323622991
326378416
327426112
330229396
332808616
335679616
341261461
342379456
345370816
351186616
355468168
358335716
361527616
364759616
371043176
372301696
375669016
378767116
382215616
387035065
390262816
393855616
400840516
402239488
405982576
409426366
413259616
422204496
426198016
430241616
433961866
438102816
439677280
443889886
447765616
452079616
460466446
462146176
466640416
470775241
475377616
481809484
486117016
490911616
500232691
502099520
507094336
512151716
516804616
521983616
532051937
534068416
539463616
549952216
552052864
557673256
562844116
568599616
582029536
588025216
599681116
608261392
614007666
614585421
620403616
626879616
639469236
641990656
648736816
654943366
661851616
671505778
677971216
685167616
699157666
701959552
709456096
716352991
724029616
741942056
749938816
758035616
765484741
773776016
776928448
785362876
793122616
801759616
818550151
821912896
830910016
848400616
861275800
869898316
879495616
901889568
911886976
922009416
931322116
941687616
956173099
965874016
976671616
997662316
1001866240
1013113936
1023461866
1034979616
1061854576
1073852416
1097176366
1114345504
1125843641
1126999706
1138641616
1151599616
1176790106
1181835136
1195333216
1207751491
1221573616
1240889572
1253825416
1268223616
1296213841
1301819584
1316817856
1345974616
1381810836
1397809216
1414007616
1445497416
1451804032
1468677496
1484201116
1501479616
1541796256
1559794816
1594784116
1620540208
1637788966
1656987616
1701784592
1721783296
1742032016
1760660866
1781395616
1810371670
1829776816
1851375616
1893363766
1901772928
1924271776
1944970741
1968009616
2021767096
2045766016
2092419991
2126762560
2152074036
2175360616
2201279616
2251666221
2261757376
2288756416
2341242616
2379878344
2405752516
2434551616
2501749600
2531748736
2590067116
2661745226
2664635777
2693744416
2726143616
2789127716
2801741824
2835491056
2866540366
2901099616
2981737936
3017737216
3087719866
3139234912
3173734291
3212133616
3301732104
3341731456
3382230816
3419490241
3460961616
3518916268
3557728216
3600927616
3684907291
3701726272
3746725696
3834204616
3941723356
3989722816
4151721088
4202345576
4248920116
4300759616
4421718496
4475718016
4580693116
4657966480
4709716066
4767315616
4901714608
4961714176
5078353366
5221712421
5227493634
5285712016
5350511616
5476482066
5501710720
5569210336
5631309991
5700429616
5861708776
5933708416
6073675741
6176707264
6322506616
6501705860
6581705536
6662705216
6820168616
6936079192
7013703916
7100103616
7301702944
7391702656
7566662116
7781701486
7877701216
8201700352
8302950096
8396099866
8499779616
8741699056
8849698816
9059650366
9214198048
9317697841
9432897616
9701697112
9821696896
10054976491
10353258500
10469695816
10599295616
10851237641
10901695168
11036694976
11299134616
11621694196
11765694016
12251693440
12543293116
12901692738
13061692576
13223692416
13538620116
13770441904
13925691766
14098491616
14501691280
14681691136
15031610866
15461690551
15653690416
16301689984
16504189856
16690489741
16897849616
17381689336
17597689216
18017592991
18326688832
18764088616
19301688364
19541688256
20604812808
20837687716
21096887616
21701687392
21971687296
22496567116
23141686906
23429686816
24401686528
24984886366
25701686177
26021686096
26345686016
26975541866
27439185760
27749685691
28095285616
28901685448
29261685376
29961525241
31205685016
32501684800
32906684736
33694004616
34661684476
35093684416
36551684224
37426484116
38501683990
38981683936
41107933712
41573683666
42092083616
43301683504
43841683456
44891443366
46181683261
46757683216
48701683072
49868082991
51941682856
52589682816
53849394741
54776682688
56088882616
57701682532
58421682496
62309682316
64901682208
65711682176
67286322116
69221682046
70085682016
73001681920
74751281866
76901681803
77861681776
82114181664
83045681641
84082481616
86501681560
87581681536
89681201491
93413681416
97301681344
103781681236
105077681216
109451681152
112076081116
115301681074
116741681056
124517680966
129701680912
131321680896
134470960866
138341680831
140069680816
145901680768
149400880741
155621680696
164126680640
168063280616
172901680588
175061680576
186725680516
194501680480
207461680426
210053680416
218801680384
224050480366
230501680345
233381680336
248933680291
259301680264
262541680256
268840240241
280037680216
291701680192
311141680156
328151680128
336024880116
345701680102
350021680096
373349680066
388901680048
414821680021
420005680016
437501680000
447999279991
466661679976
518501679940
524981679936
559973679916
583301679904
622181679886
656201679872
671948079866
691301679859
699941679856
746597679841
777701679832
839909679816
874901679808
933221679796
1036901679778
1049861679776
1119845679766
1166501679760
1244261679751
1312301679744
1343794479741
1399781679736
1555301679724
1679717679716
1749701679712
1866341679706
2073701679697
2099621679696
2239589679691
2332901679688
2624501679680
2799461679676
3110501679670
3359333679666
3499301679664
3732581679661
4199141679656
4665701679652
5248901679648
5598821679646
6220901679643
6718565679641
6998501679640
8398181679636
9331301679634
10497701679632
11197541679631
13996901679628
16796261679626
18662501679625
20995301679624
27993701679622
33592421679621
41990501679620
55987301679619
83980901679618
167961701679617
File diff suppressed because it is too large. Load diff
+26
View File
@@ -0,0 +1,26 @@
{
description = "Stergios C project dev shell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in {
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
gcc
gnumake
readline
gdb
];
shellHook = ''
echo "Stergios C dev environment loaded"
'';
};
};
}
+13
View File
@@ -3,6 +3,19 @@
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
/**
* @brief Reads a line from the given stream, dynamically allocating memory for the line.
* The line is terminated by a newline character or EOF. If a '#' character is encountered, the rest of the line is ignored (treated as a comment).
* @param stream The input stream to read from (e.g., stdin or a file).
* @param msgptr Pointer to a char pointer that will hold the address of the allocated string. If *msgptr is NULL, memory will be allocated for the string.
* @param n Pointer to a size_t variable that will hold the size of the allocated string. If *msgptr is NULL, *n will be set to 128 initially and will be doubled as needed.
* @return 0 on success, 1 on error (e.g., if msgptr or n is NULL, or if memory allocation fails). If the end of the file is reached before any characters are read, it also returns 1.
*/
bool read_line(FILE* stream, char** msgptr, size_t* n);
/*
* @brief Reads three 128 bit integers from the user with a prompt
* @param prompt The message to display to the user before reading input
-1
View File
@@ -1 +0,0 @@
make && echo -e "2\n2\n" | time ./bin/stergios
View File
File renamed without changes.
+8
View File
@@ -0,0 +1,8 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
gcc $SCRIPT_DIR/calc_i.c -o $SCRIPT_DIR/calc_i
for i in $(seq 3 20); do
echo -e "# Exponential\n$i\n\n# Values" > $SCRIPT_DIR/../exponentials-values/exponential-$i.txt
$SCRIPT_DIR/calc_i $i 0 | sort -n >> $SCRIPT_DIR/../exponentials-values/exponential-$i.txt
done
rm $SCRIPT_DIR/calc_i
+43 -2
View File
@@ -1,7 +1,48 @@
#include "io.h"
#include <stdio.h>
#include <stdlib.h>
bool read_line(FILE* stream, char** msgptr, size_t* n) {
if (msgptr == NULL || n == NULL) return 1;
if (*msgptr == NULL) {
*n = 128;
*msgptr = malloc(*n);
if (*msgptr == NULL) return 1;
}
while (1) {
size_t pos = 0;
int32_t c;
while ((c = fgetc(stream)) != EOF) {
/* If the string dosent fit, double the size */
if (pos + 1 >= *n) {
size_t new_size = *n * 2;
char* new_ptr = realloc(*msgptr, new_size);
if (new_ptr == NULL) return 1;
*msgptr = new_ptr;
*n = new_size;
}
if (c == '\n' || c == '#') {
/* Skip the info after comments */
if (c == '#') {
/* Read and discard the rest of the line until a newline or EOF */
while ((c = fgetc(stream)) != EOF && c != '\n');
}
break; /* Stop reading for this line. */
}
(*msgptr)[pos++] = (char)c; /* Add the corresponding characters */
}
if (pos == 0) {
if (c == EOF) return 1;
else continue;
}
(*msgptr)[pos] = '\0'; /* Add null byte */
return 0;
}
}
int read_int128_triplet(const char* prompt, int128_t* a, int128_t* b, int128_t* c) {
char sa[256], sb[256], sc[256];
+4 -4
View File
@@ -71,13 +71,13 @@ void generate_factor_pairs(int128_t* sum, int32_t prime_index, int32_t* exponent
int128_t r2a = values[1] / gcd2, r2b = values[2] / gcd2, r2c = val2 / gcd2;
if (is_new_root(r1a, r1b, r1c)) {
int128_t greater = values[2] >= val1 ? values[2] : val1;
LIMIT = values[1] >= greater ? values[1] * greater / (2 * gcd1 * gcd1) : values[2] * val1 / (2 * gcd1 * gcd1);
int128_t greater = r1b >= r1c ? r1b : r1c;
LIMIT = r1a >= greater ? r1a * greater / 2 : r1b * r1c / 2;
run_bfs(sum, r1a, r1b, r1c, print_mode);
}
if (val2 >= 0 && is_new_root(r2a, r2b, r2c)) {
int128_t greater = values[2] >= val2 ? values[2] : val2;
LIMIT = values[1] >= greater ? values[1] * greater / (2 * gcd2 * gcd2) : values[2] * val2 / (2 * gcd2 * gcd2);
int128_t greater = r2b >= r2c ? r2b : r2c;
LIMIT = r2a >= greater ? r2a * greater / 2 : r2b * r2c / 2;
run_bfs(sum, r2a, r2b, r2c, print_mode);
}
}
+50 -6
View File
@@ -8,8 +8,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
int32_t LIMIT = 0;
int128_t LIMIT = 0;
typedef struct GlobalEntry {
int128_t a, b, c;
@@ -50,22 +52,45 @@ void clear_global_table() {
int main() {
/* Make default setup information */
int32_t max_nodes = 160000000;
int32_t max_nodes = 200000000;
node_pool_init(max_nodes);
queue_init(max_nodes);
int mode = 0, print_mode = 0;
int128_t a0 = 10, b0 = 6, c0 = 0, sum = 0;
/* File Specific Settings */
FILE* file = NULL;
char* input = NULL;
size_t size = 0;
while (mode == 0) {
if (printf("1: manual\n") < 0) return 1;
if (printf("2: auto\n") < 0) return 1;
if (printf("3: Read file\n") < 0) return 1;
if (printf("Choose what mode you want to enter: ") < 0) return 1;
if (scanf(" %i", &mode) != 1) {
fprintf(stderr, "Input error.\n");
return 1;
}
if (mode != 1 && mode != 2) mode = 0;
if (mode != 1 && mode != 2 && mode != 3) mode = 0;
}
if (mode == 3) {
char* file_path = NULL;
while (!file_path || *file_path == '\0') {
file_path = readline("Enter file path: ");
}
int i = 0;
while (file_path[i] != '\0') i++;
if (file_path[i-1] == ' ') file_path[i-1] = '\0';
if (!(file = fopen(file_path, "r"))) {
fprintf(stderr, "File not found.\n");
free(file_path);
return 1;
}
free(file_path);
}
while (print_mode == 0) {
@@ -99,8 +124,7 @@ int main() {
LIMIT = a >= greater ? a * greater : b * c;
run_bfs(&sum, a, b, c, print_mode);
}
else if (mode == 2) {
} else if (mode == 2) {
clear_global_table(); /* Reset unique root tracker */
int32_t p = 7;
int32_t exponents[3] = {2*p + 2, p, p};
@@ -109,7 +133,27 @@ int main() {
printf("Total sum is: ");
print_int128(sum); printf("\n");
}
} else if (mode == 3) {
clear_global_table(); /* Reset unique root tracker */
if (read_line(file, &input, &size)) return 1;
int p = atoi(input);
a0 = power(a0, p);
b0 = power(b0, p);
while (!read_line(file, &input, &size)) {
c0 = str_to_int128(input);
int128_t gcd = gcd3(a0, b0, c0);
int128_t ra = a0 / gcd, rb = b0 / gcd, rc = c0 / gcd;
if (is_new_root(ra, rb, rc)) {
int128_t greater = rb >= rc ? rb : rc;
LIMIT = ra >= greater ? ra * greater / 2 : rb * rc / 2;
run_bfs(&sum, ra, rb, rc, print_mode);
}
}
printf("Total sum is: ");
print_int128(sum); printf("\n");
}
queue_destroy();
node_pool_destroy();
BIN
View File
Binary file not shown.