ABC problem: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 4,518: | Line 4,518: | ||
include "NSLog.incl" |
include "NSLog.incl" |
||
local fn |
local fn CanSpell( w as CFStringRef ) as CFStringRef |
||
NSUInteger i, j, length, count |
|||
'~'1 |
|||
Boolean letterFound |
|||
NSUInteger i, j |
|||
CFStringRef result = @"YES" |
|||
CFMutableArrayRef blocks |
|||
⚫ | |||
@[@"N", @"A"], @[@"G", @"T"], @[@"R", @"E"], @[@"T", @"G"], @[@"Q", @"D"], @[@"F", @"S"],¬ |
|||
@[@"J", @"W"], @[@"H", @"U"], @[@"V", @"I"], @[@"A", @"N"], @[@"O", @"B"], @[@"E", @"R"],¬ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
letterFound = NO |
|||
⚫ | |||
CFStringRef subString = mid( testWord, i, 1 ) |
|||
// NSLog( @"%@\n", subString ) |
|||
⚫ | |||
NSLog( @"%@; %@ %@", subString, tempArr[0], tempArr[1] ) |
|||
if not letterFound and ( subString == tempArr[0] ) or ( substring == tempArr[1] ) |
|||
//tempArr[0] = -1 |
|||
//tempArr[1] = -1 |
|||
letterFound = YES |
|||
⚫ | |||
⚫ | |||
if ( not letterFound ) then result = @"NO" : exit fn |
|||
⚫ | |||
⚫ | |||
blocks = fn MutableArrayWithArray( @[@"BO", @"XK", @"DQ", @"CP",¬ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
NSLog( @"treat: %@\n", fn CanSpell( @"treat" ) ) |
|||
⚫ | |||
NSLog( @"squad: %@\n", fn CanSpell( @"squad" ) ) |
|||
NSLog( @"cnfuse: %@\n", fn CanSpell( @"cnfuse" ) ) |
|||
⚫ | |||
⚫ | |||
CFStringRef charStr = mid( cfStr, i, 1 ) |
|||
⚫ | |||
CFStringRef testStr1 = mid( compareStr, 0, 1 ) |
|||
CFStringRef testStr2 = mid( compareStr, 1, 1 ) |
|||
if ( fn StringIsEqual( charStr, testStr1 ) == YES ) |
|||
cFinal = fn StringByAppendingString( cFinal, testStr1 ) : MutableArrayReplaceObjectAtIndex( blocks, @" ", j ) : exit for |
|||
⚫ | |||
if ( fn StringIsEqual( charStr, testStr2 ) == YES ) |
|||
cFinal = fn StringByAppendingString( cFinal, testStr2 ) : MutableArrayReplaceObjectAtIndex( blocks, @" ", j ) : exit for |
|||
end if |
|||
⚫ | |||
⚫ | |||
if fn StringIsEqual( cFinal, cfStr ) == YES then result = @"YES" |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
NSLog( @"TrEaT: Can blocks spell? %@", fn CanBlocksSpell( @"TrEaT" ) ) |
|||
⚫ | |||
NSLog( @"Squad: Can blocks spell? %@", fn CanBlocksSpell( @"Squad" ) ) |
|||
NSLog( @"conFUse: Can blocks spell? %@", fn CanBlocksSpell( @"conFUse" ) ) |
|||
HandleEvents |
HandleEvents |
||
Line 4,569: | Line 4,572: | ||
conFUse: Can blocks spell? YES |
conFUse: Can blocks spell? YES |
||
</pre> |
</pre> |
||
=={{header|Gambas}}== |
=={{header|Gambas}}== |