Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
40
Task/Rep-string/FutureBasic/rep-string.basic
Normal file
40
Task/Rep-string/FutureBasic/rep-string.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn RepeatingStrings
|
||||
NSUInteger i
|
||||
CFArrayRef testCases = @[@"1001110011", @"1110111011", @"0010010010", @"1010101010",
|
||||
@"1111111111", @"0100101101", @"0100100", @"101", @"11", @"00", @"1"]
|
||||
|
||||
for CFStringRef string in testCases
|
||||
NSUInteger length = len(string)
|
||||
CFMutableArrayRef repeats = fn MutableArrayNew
|
||||
|
||||
for NSUInteger prefixLen = 1 to length / 2
|
||||
BOOL repeatsPrefix = YES
|
||||
|
||||
for i = prefixLen to length - 1
|
||||
if ( fn StringCharacterAtIndex( string, i ) != fn StringCharacterAtIndex( string, (i % prefixLen) ) )
|
||||
repeatsPrefix = NO
|
||||
break
|
||||
end if
|
||||
next
|
||||
|
||||
if ( repeatsPrefix )
|
||||
MutableArrayAddObject( repeats, fn StringSubstringToIndex( string, prefixLen ) )
|
||||
end if
|
||||
next
|
||||
|
||||
CFStringRef outputStr
|
||||
if ( fn ArrayCount(repeats) > 0 )
|
||||
outputStr = fn ArrayComponentsJoinedByString( repeats, @", " )
|
||||
outputStr = fn StringByTrimmingCharactersInSet( outputStr, fn CharacterSetWhitespaceSet )
|
||||
else
|
||||
outputStr = @"(no repeat)"
|
||||
end if
|
||||
NSLog( @"%10s : %@", fn StringUTF8String(string), outputStr )
|
||||
next
|
||||
end fn
|
||||
|
||||
fn RepeatingStrings
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue