ABC problem: Difference between revisions
Content added Content deleted
Line 4,518: | Line 4,518: | ||
include "NSLog.incl" |
include "NSLog.incl" |
||
local fn |
local fn CanBlocksSpell( w as CFStringRef ) as CFStringRef |
||
NSUInteger |
NSUInteger i, j |
||
⚫ | |||
Boolean letterFound |
|||
CFMutableArrayRef blocks |
|||
⚫ | |||
blocks = fn MutableArrayWithArray( @[@"BO", @"XK", @"DQ", @"CP",¬ |
|||
@"NA", @"GT", @"RE", @"TG", @"QD", @"FS", @"JW", @"HU", @"VI",¬ |
|||
@"AN", @"OB", @"ER", @"FS", @"LY", @"PC", @"ZM"] ) |
|||
@[@"F", @"S"], @[@"L", @"Y"], @[@"P", @"C"], @[@"Z", @"M"]] |
|||
CFStringRef |
CFStringRef cfStr = fn StringUppercaseString( w ) |
||
NSUInteger length = fn StringLength( cfStr ) |
|||
NSUInteger count = fn ArrayCount( blocks ) |
|||
count = fn ArrayCount( blocks ) |
|||
for i = 0 to length - 1 |
for i = 0 to length - 1 |
||
letterFound = NO |
|||
for j = 0 to count - 1 |
for j = 0 to count - 1 |
||
CFStringRef |
CFStringRef charStr = mid( cfStr, i, 1 ) |
||
CFStringRef compareStr = fn ArrayObjectAtIndex( blocks, j ) |
|||
// NSLog( @"%@\n", subString ) |
|||
CFStringRef testStr1 = mid( compareStr, 0, 1 ) |
|||
CFStringRef testStr2 = mid( compareStr, 1, 1 ) |
|||
if |
if ( fn StringIsEqual( charStr, testStr1 ) == YES ) |
||
cFinal = fn StringByAppendingString( cFinal, testStr1 ) : MutableArrayReplaceObjectAtIndex( blocks, @" ", j ) : exit for |
|||
//tempArr[0] = -1 |
|||
end if |
|||
if ( fn StringIsEqual( charStr, testStr2 ) == YES ) |
|||
cFinal = fn StringByAppendingString( cFinal, testStr2 ) : MutableArrayReplaceObjectAtIndex( blocks, @" ", j ) : exit for |
|||
end if |
end if |
||
next |
next |
||
if ( not letterFound ) then result = @"NO" : exit fn |
|||
next |
next |
||
if fn StringIsEqual( cFinal, cfStr ) == YES then result = @"YES" |
|||
end fn = result |
end fn = result |
||
NSLog( @"a: Can blocks spell? %@", fn CanBlocksSpell( @"a" ) ) |
|||
NSLog( @" |
NSLog( @"Bark: Can blocks spell? %@", fn CanBlocksSpell( @"Bark" ) ) |
||
NSLog( @" |
NSLog( @"BOOK: Can blocks spell? %@", fn CanBlocksSpell( @"BOOK" ) ) |
||
NSLog( @" |
NSLog( @"TrEaT: Can blocks spell? %@", fn CanBlocksSpell( @"TrEaT" ) ) |
||
NSLog( @" |
NSLog( @"COMMON: Can blocks spell? %@", fn CanBlocksSpell( @"COMMON" ) ) |
||
NSLog( @" |
NSLog( @"Squad: Can blocks spell? %@", fn CanBlocksSpell( @"Squad" ) ) |
||
NSLog( @" |
NSLog( @"conFUse: Can blocks spell? %@", fn CanBlocksSpell( @"conFUse" ) ) |
||
NSLog( @"cnfuse: %@\n", fn CanSpell( @"cnfuse" ) ) |
|||
HandleEvents |
HandleEvents |