Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
45
Task/Ordered-words/FutureBasic/ordered-words.basic
Normal file
45
Task/Ordered-words/FutureBasic/ordered-words.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
local fn Words as CFArrayRef
|
||||
CFURLRef url = fn URLWithString( @"https://web.archive.org/web/20180611003215/http://www.puzzlers.org/pub/wordlists/unixdict.txt" )
|
||||
CFStringRef string = fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )
|
||||
end fn = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
|
||||
|
||||
|
||||
local fn IsOrderedWord( string as CFStringRef ) as BOOL
|
||||
BOOL flag = YES
|
||||
long i
|
||||
unichar chr, prevChr = 0
|
||||
|
||||
for i = 0 to len(string) - 1
|
||||
chr = fn StringCharacterAtIndex( string, i )
|
||||
if ( chr < prevChr )
|
||||
flag = NO : break
|
||||
end if
|
||||
prevChr = chr
|
||||
next
|
||||
end fn = flag
|
||||
|
||||
|
||||
void local fn DoIt
|
||||
CFStringRef string
|
||||
CFArrayRef words = fn Words
|
||||
long length, maxLen = 0
|
||||
CFMutableStringRef orderedWords = fn MutableStringWithCapacity(0)
|
||||
|
||||
for string in words
|
||||
length = len(string)
|
||||
if ( length < maxLen ) then continue
|
||||
if ( fn IsOrderedWord( string ) )
|
||||
if ( length > maxLen )
|
||||
MutableStringSetString( orderedWords, @"" )
|
||||
maxLen = length
|
||||
end if
|
||||
MutableStringAppendFormat( orderedWords, @"%@\n", string )
|
||||
end if
|
||||
next
|
||||
|
||||
print orderedWords
|
||||
end fn
|
||||
|
||||
fn DoIt
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue