Words from neighbour ones: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: unique words) |
(Initial FutureBasic task solution added) |
||
Line 710: | Line 710: | ||
terminado... |
terminado... |
||
</pre> |
|||
=={{header|FutureBasic}}== |
|||
<syntaxhighlight lang="futurebasic"> |
|||
#plist NSAppTransportSecurity @{NSAllowsArbitraryLoads:YES} |
|||
local fn WordList as CFArrayRef |
|||
CFURLRef url = fn URLWithString( @"http://wiki.puzzlers.org/pub/wordlists/unixdict.txt" ) |
|||
CFStringRef string = lcase(fn StringWithContentsOfURL( url, NSUTF8StringEncoding, NULL )), testStr |
|||
CFArrayRef wordArr = fn StringComponentsSeparatedByString( string, @"\n" ) |
|||
CFMutableArrayRef wordsToKeep = fn MutableArrayNew |
|||
for testStr in wordArr |
|||
if len(testStr) > 8 then MutableArrayAddObject( wordsToKeep, testStr ) |
|||
next |
|||
end fn = fn ArrayWithArray( wordsToKeep ) |
|||
local fn TestWords |
|||
CFArrayRef wordArr = fn WordList |
|||
NSInteger i = 0, j = 0, count = len( wordArr ) |
|||
CFMutableStringRef mutStr = fn MutableStringNew |
|||
CFMutableArrayRef mutArr = fn MutableArrayNew |
|||
for i = 0 to count - 9 |
|||
CFMutableStringRef tempMutStr = fn MutableStringNew |
|||
for j = 0 to 8 |
|||
MutableStringAppendString( tempMutStr, mid( wordArr[i + j], j, 1 ) ) |
|||
next |
|||
if fn ArrayContainsObject( wordArr, tempMutStr ) then MutableArrayAddObject( mutArr, fn StringWithFormat( @"%@", tempMutStr ) ) |
|||
next |
|||
CFArrayRef noDuplicates = fn OrderedSetArray( fn OrderedSetWithArray( mutArr ) ) |
|||
MutableStringSetString( mutStr, @"" ) |
|||
for i = 0 to len(noDuplicates) - 1 |
|||
MutableStringAppendString( mutStr, fn StringWithFormat( @"%2ld. %@\n", i, noDuplicates[i] ) ) |
|||
next |
|||
printf @"%@", mutStr |
|||
end fn |
|||
fn TestWords |
|||
HandleEvents |
|||
</syntaxhighlight> |
|||
{{output}} |
|||
<pre style="height:20ex;"> |
|||
0. applicate |
|||
1. architect |
|||
2. astronomy |
|||
3. christine |
|||
4. christoph |
|||
5. committee |
|||
6. composite |
|||
7. constrict |
|||
8. construct |
|||
9. different |
|||
10. extensive |
|||
11. greenwood |
|||
12. implement |
|||
13. improvise |
|||
14. intercept |
|||
15. interpret |
|||
16. interrupt |
|||
17. philosoph |
|||
18. prescript |
|||
19. receptive |
|||
20. telephone |
|||
21. transcend |
|||
22. transport |
|||
23. transpose |
|||
</pre> |
</pre> |
||