[Community Puzzle] Fair Numbering

I just checked and there’s no mistake.
Try to find the error in your solution.

1 Like

yes my mistake ))) now all good )))

finally passed. Damn this took a while! I got to the unoptimized version pretty quick, but finding the faster one was tricky!

Anyone can please guide me how to optimize solution to this puzzle?

Hi, I optimized my solution, I’m stuck at validator 4 tho. I passed all the tests, so dunno where’s the problem. I’ll be looking into this more, but do you know what might be a case? @java_coffee_cup

Validator 4 is similar to its related test case. Both are randomly generated within a similar range.
If your code fails by error (not time out) I cannot exactly tell what can cause your code to fail.

Possible causes of error is overflow of integer and precision error if you use float-point numbers (js tends to use float-point even for integers)

You can generate your own input data and your calculated answer to post here. It is useful to others for debugging, and people can also help to cross check the correctness of your in-outs.

Hi, so as you suggested, I’ve generated 100 inputs and provided 100 outputs respectively. I set the starting value to be in range (3934, 91627) and the ending value to be from range (2025236, 4075607). Just some numbers from test 4 that seems kinda OK.

My solution is written in Python, so overflow of integer should not be a case. BTW I rewrited it in C++ and it keeps getting stucked at validator 4. I thought it might be something about precision, truncating numbers etc. so I’d be very glad if someone will compare my outputs to their.

Inputs:

100
80011 2441014
34645 2160419
49954 2757200
7276 2904517
51247 2614456
53069 3355159
89960 3405449
67087 3219575
18934 3654711
78188 3887121
33005 2262930
39593 2501508
40551 2349371
56539 2947090
76663 3860151
14680 3625405
60642 2703793
60276 3529838
34119 2292457
73053 3823989
81521 3458319
72694 3147796
56382 3446855
16963 2403838
30344 3504079
31741 2410581
6467 2669600
53804 4035480
29731 2976463
61711 4007246
46693 2118674
56573 2725838
88270 2538208
75452 2498664
88153 3271612
34524 3813674
57316 2117365
63191 2191616
77407 3401300
43332 3125100
37556 2516649
53298 2796535
87192 2732569
26387 3578774
8790 2156356
39247 2662863
76294 3592332
90032 2316276
56044 2486787
36588 3509977
34927 2521144
10218 2786429
47125 2076060
8233 2821972
28031 3912991
40845 4005504
86685 2474873
74189 2770592
75510 2684538
66820 2045867
16025 3171656
79493 3243928
29803 2151233
46008 2466071
73589 3508771
89532 2786998
51845 2372240
20654 2537218
59807 3494062
4043 3709712
39582 2530402
33266 3693290
48814 3238118
24296 2854146
9533 3412044
82003 2341898
37098 3151003
4388 3292219
35630 2370859
42117 3563222
63737 2684145
87835 2790214
24789 2108832
6416 3280819
84925 3137189
49139 2671383
52551 3005337
6170 2607084
32700 2326358
40970 3965763
14461 2215166
49445 2246033
14322 3592108
40574 2783147
51879 3230850
70020 2422323
78348 2596448
22779 2891549
11583 2105739
4280 3071623

Outputs:

1327653
1171153
1475011
1533622
1404101
1775103
1813424
1712318
1912688
2050055
1221823
1343465
1267738
1572308
2036026
1896516
1452125
1865017
1236984
2016655
1836845
1678431
1822134
1286548
1841447
1295197
1415932
2115526
1577420
2104233
1154584
1461694
1379199
1354850
1745860
1997737
1157723
1196947
1806866
1656596
1350308
1495873
1475995
1877381
1159974
1424019
1901984
1268863
1341980
1846626
1351616
1475434
1133431
1492623
2045077
2095910
1346966
1490363
1447807
1125368
1670122
1728925
1164831
1328037
1859238
1504045
1283207
1354556
1846961
1935296
1357908
1937096
1715063
1514321
1788030
1278806
1667321
1726648
1276725
1875223
1443406
1505047
1141840
1721527
1677495
1431812
1600007
1384590
1253428
2076084
1191318
1219246
1879739
1484635
1712524
1314739
1404776
1532480
1135577
1616319

Would you split the input and output into two blocks so that allowing direct copy and paste without further editing?

There you go, edited previous post!

Oh, you missed to put 100 as the first line in input.
Found that your list of answers are all correct.

Try my set of IN/OUT

Inputs

200
16 7680620
27 4468632
73 6971177
94 2218828
98 3488454
87 8909376
73 1038989
99 2608752
50 9693412
97 3476424
17 4446850
6 6754015
87 3230774
9 6589310
68 5973808
17 1507100
54 1847121
85 1510786
31 967857
55 6712639
89 5580718
11 4782551
28 4289631
46 107677
23 7867147
86 2764253
48 4958337
50 3274189
21 647397
79 7304612
86 7546010
1 5941133
17 1287511
5 8979874
45 3949014
59 6859019
9 7904155
13 7985676
12 3137050
86 6532105
27 3561572
29 2568459
82 9458094
24 4607137
97 5950621
16 4671630
6 5734098
97 863876
56 3223654
98 1365243
707 359395
927 9242551
81 3501762
276 2701155
468 4332344
65 3291912
831 7718694
903 1006130
169 5779471
950 7542223
589 5094374
810 2028593
250 4596754
132 3840003
985 3093462
368 3796558
813 7375320
177 1282961
76 783687
565 8350902
26 8471715
301 7708277
292 3806031
382 2138103
253 3716162
358 8751726
92 3141628
179 3081102
752 1425869
389 8794195
306 6943325
169 5075971
508 5516095
367 5204684
660 1894645
972 3137464
373 3380156
150 2976931
142 8636742
985 7648266
880 1073321
950 9247488
588 8406461
937 9822166
354 2322217
820 7607291
552 7120584
481 5747301
118 9482690
673 2831252
370 8442774
6452 1126828
5719 4047422
1204 9050532
4257 2697066
591 3885761
7540 6415683
1328 6463780
7261 7187654
188 4738189
8546 789163
2212 9225868
6359 857718
1226 7552323
5104 6875092
567 3040042
9550 646245
7647 2006067
3173 5625404
1821 5680328
2366 2075276
4687 3920011
7264 1448257
6157 124991
492 5584576
2384 9274183
9205 8597892
2747 6988913
9735 9639840
8578 8918316
6302 2178204
7448 7316572
9766 112354
7379 9357494
7940 3289601
1246 979602
2721 9838017
9672 4643994
7409 6693888
5792 678669
662 8577614
2543 1267566
6220 3829468
7462 1610855
8754 9196632
8745 6966573
9047 1320016
1999 8958255
8224 9185217
6477 1629920
11218 1202952
1990 3637515
96674 8564119
88553 5793905
4082 8223318
30780 1214772
28142 4320911
16026 7007673
82397 4912143
4540 5546229
60246 4878913
99082 4084418
36159 801068
41855 2710990
73598 4141710
53880 4167485
33092 8223485
72982 4747224
98997 3877555
92952 5018407
25781 1013055
51402 846676
3721 7981555
25855 5598058
32672 5171347
33208 4757786
80476 6066906
44209 6698965
2146 5753363
77327 2862307
46878 5960101
17137 8203009
2729 4180103
13329 3313468
33116 9082373
79564 974409
33562 2480126
3083 3659920
446 8583179
86698 4406892
2266 671872
66330 960600
39894 9737894
35866 1737289
20848 4734503
71459 3680490
92763 5646159
8961 8955519
45136 6307989
99446 3646947

Outputs

3919676
2313683
3564962
1188791
1823604
4534064
532013
1383753
4926076
1817589
2302791
3456372
1694763
3374020
3066277
805069
1002932
807230
493191
3435691
2869735
2470640
2224183
55725
4012940
1461502
2558539
1716465
332959
3731681
3852381
3049931
676975
4569301
2053877
3508881
4031442
4072203
1647890
3345428
1860153
1363597
4808422
2382935
3054688
2415181
2946413
441212
1691198
722332
189123
4700830
1830256
1429993
2245628
1725329
3938881
513051
2969128
3850671
2626669
1093826
2377787
1999386
1626298
1977714
3767190
674354
401114
4254928
4315225
3933559
1982434
1148490
1937491
4455296
1650190
1619946
757861
4476537
3551084
2617378
2837513
2681777
1026820
1648296
1769514
1567854
4397758
3903700
552240
4703304
4282713
4990640
1240541
3883177
3639766
2953110
4820726
1495126
4300822
585299
2104630
4604895
1429034
2022363
3289281
3311554
3675186
2448491
406596
4692851
440144
3855797
3518289
1599499
335472
1084503
2892893
2919969
1117599
2040629
773070
68457
2871750
4717057
4380861
3574526
4901986
4540894
1170187
3739699
62318
4760140
1726354
499382
4999071
2404045
3428346
350431
4368305
666094
1995796
867985
4680102
3565070
698857
4558983
4674243
878778
631395
1898611
4395156
3007149
4192110
646441
2249077
3588131
2564069
2853696
2539543
2156166
423933
1449014
2175710
2181556
4202132
2478247
2052704
2620971
526690
453088
4071125
2886833
2675913
2469323
3140765
3443842
2956579
1537341
3075363
4186195
2170116
1740065
4631584
528689
1330620
1910126
4371041
2312980
345857
516270
4961765
953362
2453268
1944337
2934780
4559605
3248685
1937560

My program says:

Different outputs: 0

PS added input number in one of previous posts for future generations :slight_smile:

@java_coffee_cup

Do validator 4 have some output before truncating with decimal part of the number bigger than 999_999_999_999_999_8?

EDIT: actually the problem occurs when decimal part forms a string : ‘9999999999999999…’

Because I tested it in Python and after this point int() or floor() actually returns ceil. And casting to string also returns ceiled number. I didn’t figured out the way around that yet - if that’s a case ofc.

I do not work in python and have no idea why a decimal point is needed in integer calculation. If you could create a test triggering this mishaps situation I am glad to add it to a test case.