39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES}
|
|
|
|
local fn Dictionary as CFArrayRef
|
|
CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" )
|
|
CFStringRef string = fn StringWithContentsOfURL( url, NSASCIIStringEncoding, NULL )
|
|
end fn = fn StringComponentsSeparatedByCharactersInSet( string, fn CharacterSetNewlineSet )
|
|
|
|
local fn ReverseString( inString as CFStringRef ) as CFStringRef
|
|
CFMutableStringRef outString = fn MutableStringNew
|
|
for long index = len(inString) - 1 to 0 step -1
|
|
MutableStringAppendString( outString, mid(inString,index,1) )
|
|
next
|
|
end fn = outString
|
|
|
|
void local fn Doit
|
|
CFMutableArrayRef pairs = fn MutableArrayNew
|
|
CFArrayRef words = fn Dictionary
|
|
NSUInteger count = len(words), i, index
|
|
for i = 0 to count - 2
|
|
CFStringRef wd1 = words[i]
|
|
CFStringRef wd2 = fn ReverseString( wd1 )
|
|
index = fn ArrayIndexOfObjectInRange( words, wd2, fn CFRangeMake( i+1, count-(i+1) ) )
|
|
if ( index != NSNotFound ) then MutableArrayAddObject( pairs, @{@"wd1":wd1,@"wd2":wd2} )
|
|
next
|
|
|
|
text ,,,,, 60
|
|
for i = 1 to 5
|
|
count = len(pairs)
|
|
index = rnd(count)-1
|
|
CFDictionaryRef dict = pairs[index]
|
|
print dict[@"wd1"],dict[@"wd2"]
|
|
MutableArrayRemoveObjectAtIndex( pairs, index )
|
|
next
|
|
end fn
|
|
|
|
fn DoIt
|
|
|
|
HandleEvents
|