Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn LookAndSay( testWord as CFStringRef ) as CFStringRef
|
||||
NSUInteger i, length, times
|
||||
CFMutableStringRef result = fn MutableStringWithCapacity(0)
|
||||
|
||||
unichar repeat = fn StringCharacterAtIndex( testWord, 0 )
|
||||
times = 1
|
||||
testWord = fn StringWithFormat( @"%@ ", fn StringSubstringFromIndex( testWord, 1 ) )
|
||||
length = len(testWord)
|
||||
|
||||
for i = 0 to length - 1
|
||||
unichar actual = fn StringCharacterAtIndex( testWord, i )
|
||||
if ( actual != repeat )
|
||||
MutableStringAppendFormat( result, @"%d%c", times, repeat )
|
||||
times = 1
|
||||
repeat = actual
|
||||
else
|
||||
times++
|
||||
end if
|
||||
next
|
||||
end fn = fn StringWithString( result )
|
||||
|
||||
void local fn DoIt
|
||||
NSUInteger i
|
||||
CFStringRef numStr = @"1"
|
||||
|
||||
for i = 1 to i <= 15
|
||||
NSLog( @"%@", numStr )
|
||||
numStr = fn LookAndSay( numStr )
|
||||
next
|
||||
end fn
|
||||
|
||||
fn DoIt
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue