Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,25 +0,0 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
procedure SelfDesc is
|
||||
subtype Desc_Int is Long_Integer range 0 .. 10**10-1;
|
||||
|
||||
function isDesc (innum : Desc_Int) return Boolean is
|
||||
subtype S_Int is Natural range 0 .. 10;
|
||||
type S_Int_Arr is array (0 .. 9) of S_Int;
|
||||
ref, cnt : S_Int_Arr := (others => 0);
|
||||
n, digit : S_Int := 0; num : Desc_Int := innum;
|
||||
begin
|
||||
loop
|
||||
digit := S_Int (num mod 10);
|
||||
ref (9 - n) := digit; cnt (digit) := cnt (digit) + 1;
|
||||
num := num / 10; exit when num = 0; n := n + 1;
|
||||
end loop;
|
||||
return ref (9 - n .. 9) = cnt (0 .. n);
|
||||
end isDesc;
|
||||
|
||||
begin
|
||||
for i in Desc_Int range 1 .. 100_000_000 loop
|
||||
if isDesc (i) then
|
||||
Put_Line (Desc_Int'Image (i));
|
||||
end if;
|
||||
end loop;
|
||||
end SelfDesc;
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
function Test-SelfDescribing ([int]$Number)
|
||||
{
|
||||
[int[]]$digits = $Number.ToString().ToCharArray() | ForEach-Object {[Char]::GetNumericValue($_)}
|
||||
[int]$sum = 0
|
||||
|
||||
for ($i = 0; $i -lt $digits.Count; $i++)
|
||||
{
|
||||
$sum += $i * $digits[$i]
|
||||
}
|
||||
|
||||
$sum -eq $digits.Count
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
Test-SelfDescribing -Number 2020
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
11,2020,21200,321100 | ForEach-Object {
|
||||
[PSCustomObject]@{
|
||||
Number = $_
|
||||
IsSelfDescribing = Test-SelfDescribing -Number $_
|
||||
}
|
||||
} | Format-Table -AutoSize
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
Function IsSelfDescribing(n)
|
||||
IsSelfDescribing = False
|
||||
Set digit = CreateObject("Scripting.Dictionary")
|
||||
For i = 1 To Len(n)
|
||||
k = Mid(n,i,1)
|
||||
If digit.Exists(k) Then
|
||||
digit.Item(k) = digit.Item(k) + 1
|
||||
Else
|
||||
digit.Add k,1
|
||||
End If
|
||||
Next
|
||||
c = 0
|
||||
For j = 0 To Len(n)-1
|
||||
l = Mid(n,j+1,1)
|
||||
If digit.Exists(CStr(j)) Then
|
||||
If digit.Item(CStr(j)) = CInt(l) Then
|
||||
c = c + 1
|
||||
End If
|
||||
ElseIf l = 0 Then
|
||||
c = c + 1
|
||||
Else
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
If c = Len(n) Then
|
||||
IsSelfDescribing = True
|
||||
End If
|
||||
End Function
|
||||
|
||||
'testing
|
||||
start_time = Now
|
||||
s = ""
|
||||
For m = 1 To 100000000
|
||||
If IsSelfDescribing(m) Then
|
||||
WScript.StdOut.WriteLine m
|
||||
End If
|
||||
Next
|
||||
end_time = Now
|
||||
WScript.StdOut.WriteLine "Elapse Time: " & DateDiff("s",start_time,end_time) & " seconds"
|
||||
Loading…
Add table
Add a link
Reference in a new issue