Rare numbers: Difference between revisions

→‎Turbo: Updated to incorporate improvements suggested by Enter your username.
No edit summary
(→‎Turbo: Updated to incorporate improvements suggested by Enter your username.)
Line 2,361:
===Turbo===
{{trans|C++}}
A smallsmallish turbo anyway :)
 
The following, which is a translation of the C++ 10 to 19 digits program and includes improvements suggested by Enter your username (see Talk page), completes in justaround over 2115.25 minutes which is aboutmore than 23.5 times faster than the 'quicker' version above.
 
Curiously, the C++ program itself when compiled with g++ 7.5.0 (-std=c++17 -O3) on the same machine (and incorporating the same improvements) completes in just over 3021 minutes though I understand that when using other C++ compilers (clang, mingw) it's much faster than this.
<lang go>package main
 
Line 2,461:
f := func() [][2]int64 {
var w [][2]int64
for g0 < 107 {
nn := g3*l3 + g2*l2 + g1*l1 + g0*l0
gg := -1000*g3 - 100*g2 - 10*g1 - g0
Line 2,476:
} else {
g1 = -9
if g0 == 1 {
g0 = 3
}
g0++
}
Line 2,503 ⟶ 2,506:
}
}
g0 := int64(14)
var g1, g2, g3 int64
l0, l1, l2, l3 := pow10[n-5], pow10[n-6], pow10[n-7], pow10[n-8]
Line 2,523 ⟶ 2,526:
} else {
g1 = 0
if g0 == 6 || g0 == 9 {
g0 += 3
}
g0++
}
Line 2,602 ⟶ 2,608:
nth := 3 // i.e. count of rare numbers < 10 digits
fmt.Println("nth rare number digs block time total time")
for nd := 10; nd <= 2019; nd++ {
rares := rare(nd)
if len(rares) > 0 {
Line 2,628 ⟶ 2,634:
4 2,022,652,202
5 2,042,832,002 10: 00:00:00.002 00:00:00.002
11: 00:00:00.008 00:00:00.010011
6 868,591,084,757
7 872,546,974,178
8 872,568,754,178 12: 00:00:00.022 00:00:00.032033
9 6,979,302,951,885 13: 00:00:00.144097 00:00:00.177131
10 20,313,693,904,202
11 20,313,839,704,202
Line 2,639 ⟶ 2,645:
14 20,333,875,702,202
15 40,313,893,704,200
16 40,351,893,720,200 14: 00:00:00.378265 00:00:00.555396
17 200,142,385,731,002
18 204,238,494,066,002
Line 2,648 ⟶ 2,654:
23 403,058,392,434,500
24 441,054,594,034,340
25 816,984,566,129,618 15: 00:00:0201.423774 00:00:02.979170
26 2,078,311,262,161,202
27 2,133,786,945,766,212
Line 2,663 ⟶ 2,669:
38 8,191,376,864,400,818
39 8,650,327,689,541,457
40 8,650,349,867,341,457 16: 00:00:0605.862407 00:00:0907.841578
41 22,542,040,692,914,522
42 67,725,910,561,765,640
43 86,965,750,494,756,968 17: 00:00:4535.868401 00:00:5542.709979
44 225,342,456,863,243,522
45 225,342,458,663,243,522
Line 2,686 ⟶ 2,692:
61 865,721,270,017,296,468
62 871,975,098,681,469,178
63 898,907,259,301,737,498 18: 00:0201:1142.861745 00:0302:0725.571725
64 2,042,401,829,204,402,402
65 2,060,303,819,041,450,202
Line 2,698 ⟶ 2,704:
73 8,197,906,905,009,010,818
74 8,200,756,128,308,135,597
75 8,320,411,466,598,809,138 19: 00:1712:5948.503590 00:2115:0714.075316
</pre>
 
9,492

edits