Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
54
Task/Ordered-words/Free-Pascal-Lazarus/ordered-words.pas
Normal file
54
Task/Ordered-words/Free-Pascal-Lazarus/ordered-words.pas
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
Program Ordered_Words;
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
Uses
|
||||
Classes;
|
||||
|
||||
Const
|
||||
FILENAME = 'unixdict.txt';
|
||||
|
||||
Function IsOrdered(Const S: String): boolean;
|
||||
|
||||
Var
|
||||
I, Len: integer;
|
||||
Begin
|
||||
Len := Length(S);
|
||||
If Len < 2 Then
|
||||
Exit(True);
|
||||
For I := 2 To Len Do
|
||||
If S[I] < S[I - 1] Then
|
||||
Exit(False);
|
||||
Result := True;
|
||||
End;
|
||||
|
||||
Var
|
||||
WordList, OrderedWords: TStringList;
|
||||
CurrentWord: string;
|
||||
CurrentLength, LongestLength: integer;
|
||||
|
||||
Begin
|
||||
LongestLength := 0;
|
||||
WordList := TStringList.Create;
|
||||
OrderedWords := TStringList.Create;
|
||||
|
||||
WordList.LoadFromFile(FILENAME);
|
||||
For CurrentWord In WordList Do
|
||||
Begin
|
||||
CurrentLength := Length(CurrentWord);
|
||||
If CurrentLength >= LongestLength Then
|
||||
If IsOrdered(CurrentWord) Then
|
||||
If CurrentLength > LongestLength Then
|
||||
Begin
|
||||
LongestLength := CurrentLength;
|
||||
OrderedWords.Clear;
|
||||
OrderedWords.Add(CurrentWord);
|
||||
End
|
||||
Else If CurrentLength = LongestLength Then
|
||||
OrderedWords.Add(CurrentWord);
|
||||
End;
|
||||
For CurrentWord In OrderedWords Do
|
||||
WriteLn(CurrentWord);
|
||||
|
||||
WordList.Free;
|
||||
OrderedWords.Free;
|
||||
End.
|
||||
38
Task/Ordered-words/M2000-Interpreter/ordered-words.m2000
Normal file
38
Task/Ordered-words/M2000-Interpreter/ordered-words.m2000
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
module Ordered_Words {
|
||||
orderword=lambda ->{
|
||||
buffer a as integer*30
|
||||
=lambda a (s as string) -> {
|
||||
if len(s)*2>len(a) then buffer a as integer*len(s)
|
||||
return a, 0:=s
|
||||
if len(s)=1 then =true: exit
|
||||
for i=1 to len(s)-1
|
||||
if a[i-1]>a[i] then break
|
||||
next i
|
||||
=true
|
||||
}
|
||||
}()
|
||||
max=2
|
||||
res=stack
|
||||
document a$
|
||||
load.doc a$, "unixdict.txt"
|
||||
k=doc.par(a$)
|
||||
i=0
|
||||
m=Paragraph(a$, 0)
|
||||
if forward(a$, m) then
|
||||
while m
|
||||
i++
|
||||
if i mod 20=1 then Print Over round(i/k*100,2);"%" : refresh
|
||||
word=paragraph$(a$, (m))
|
||||
if orderword(word) then
|
||||
if max<len(word) then max=len(word): res=stack
|
||||
if max=len(word) then stack res {data word}
|
||||
end if
|
||||
end while
|
||||
print
|
||||
end if
|
||||
open "outtxt.txt" for output as #f
|
||||
Print #f, "words:", array(res)#str$(" ")
|
||||
close #f
|
||||
win dir$+"outtxt.txt"
|
||||
}
|
||||
Ordered_Words
|
||||
Loading…
Add table
Add a link
Reference in a new issue