Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,45 +0,0 @@
|
|||
' Mian-Chowla sequence - VBScript - 15/03/2019
|
||||
Const m = 100, mm=28000
|
||||
ReDim r(mm), v(mm * 2)
|
||||
Dim n, t, i, j, l, s1, s2, iterate_t
|
||||
ReDim seq(m)
|
||||
t0=Timer
|
||||
s1 = "1": s2 = ""
|
||||
seq(1) = 1: n = 1: t = 1
|
||||
Do While n < m
|
||||
t = t + 1
|
||||
iterate_t = False
|
||||
For i = 1 to t * 2
|
||||
v(i) = 0
|
||||
Next
|
||||
i = 1
|
||||
Do While i <= t And Not iterate_t
|
||||
If r(i) = 0 Then
|
||||
j = i
|
||||
Do While j <= t And Not iterate_t
|
||||
If r(j) = 0 Then
|
||||
l = i + j
|
||||
If v(l) = 1 Then
|
||||
r(t) = 1
|
||||
iterate_t = True
|
||||
End If
|
||||
If Not iterate_t Then v(l) = 1
|
||||
End If
|
||||
j = j + 1
|
||||
Loop
|
||||
End If
|
||||
i = i + 1
|
||||
Loop
|
||||
If Not iterate_t Then
|
||||
n = n + 1
|
||||
seq(n) = t
|
||||
if n<= 30 then s1 = s1 & " " & t
|
||||
if n>=91 and n<=100 then s2 = s2 & " " & t
|
||||
End If
|
||||
Loop
|
||||
wscript.echo "t="& t
|
||||
wscript.echo "The Mian-Chowla sequence for elements 1 to 30:"
|
||||
wscript.echo s1
|
||||
wscript.echo "The Mian-Chowla sequence for elements 91 to 100:"
|
||||
wscript.echo s2
|
||||
wscript.echo "Computation time: "& Int(Timer-t0) &" sec"
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
' Mian-Chowla sequence - VBScript - March 19th, 2019
|
||||
|
||||
Function Find(x(), val) ' finds val on a pre-sorted list
|
||||
Dim l, u, h : l = 0 : u = ubound(x) : Do : h = (l + u) \ 2
|
||||
If val = x(h) Then Find = h : Exit Function
|
||||
If val > x(h) Then l = h + 1 Else u = h - 1
|
||||
Loop Until l > u : Find = -1
|
||||
End Function
|
||||
|
||||
' adds next item from a() to result (r()), adds all remaining items
|
||||
' from b(), once a() is exhausted
|
||||
Sub Shuffle(ByRef r(), a(), b(), ByRef i, ByRef ai, ByRef bi, al, bl)
|
||||
r(i) = a(ai) : ai = ai + 1 : If ai > al Then Do : i = i + 1 : _
|
||||
r(i) = b(bi) : bi = bi + 1 : Loop until bi = bl
|
||||
End Sub
|
||||
|
||||
Function Merger(a(), b(), bl) ' merges two pre-sorted lists
|
||||
Dim res(), ai, bi, i : ReDim res(ubound(a) + bl) : ai = 0 : bi = 0
|
||||
For i = 0 To ubound(res)
|
||||
If a(ai) < b(bi) Then Shuffle res, a, b, i, ai, bi, ubound(a), bl _
|
||||
Else Shuffle res, b, a, i, bi, ai, bl, ubound(a)
|
||||
Next : Merger = res
|
||||
End Function
|
||||
|
||||
Const n = 100 : Dim mc(), sums(), ts(), sp, tc : sp = 1 : tc = 0
|
||||
ReDim mc(n - 1), sums(0), ts(n - 1) : mc(0) = 1 : sums(sp - 1) = 2
|
||||
Dim sum, i, j, k, st : st = Timer
|
||||
wscript.echo "The Mian-Chowla sequence for elements 1 to 30:"
|
||||
wscript.stdout.write("1 ")
|
||||
For i = 1 To n - 1 : j = mc(i - 1) + 1 : Do
|
||||
mc(i) = j : For k = 0 To i
|
||||
sum = mc(k) + j : If Find(sums, sum) >= 0 Then _
|
||||
tc = 0 : Exit For Else ts(tc) = sum : tc = tc + 1
|
||||
Next : If tc > 0 Then
|
||||
nu = Merger(sums, ts, tc) : ReDim sums(ubound(nu))
|
||||
For e = 0 To ubound(nu) : sums(e) = nu(e) : Next
|
||||
tc = 0 : Exit Do
|
||||
End If : j = j + 1 : Loop
|
||||
if i = 90 then wscript.echo vblf & vbLf & _
|
||||
"The Mian-Chowla sequence for elements 91 to 100:"
|
||||
If i < 30 or i >= 90 Then wscript.stdout.write(mc(i) & " ")
|
||||
Next
|
||||
wscript.echo vblf & vbLf & "Computation time: "& Timer - st &" seconds."
|
||||
Loading…
Add table
Add a link
Reference in a new issue