ABC problem: Difference between revisions

m
No edit summary
Line 4,518:
include "NSLog.incl"
 
local fn CanBlocksSpellCanSpell( w as CFStringRef ) as CFStringRef
NSUInteger i, j, length, count
'~'1
Boolean letterFound
NSUInteger i, j
CFStringRef cFinal = @"",CFStringRef result = @"NOYES"
CFMutableArrayRef blocks
@"NA", CFArrayRef blocks = @[@[@"GTB", @"REO"], @[@"TGX", @"QDK"], @[@"FSD", @"JWQ"], @[@"HUC", @"VIP"]
@[@"N", @"A"], @[@"G", @"T"], @[@"R", @"E"], @[@"T", @"G"], @[@"Q", @"D"], @[@"F", @"S"],¬
@[@"J", @"W"], @[@"H", @"U"], @[@"V", @"I"], @[@"A", @"N"], @[@"O", @"B"], @[@"E", @"R"],¬
@[@"ANF", @"OBS"], @[@"ERL", @"FSY"], @[@"LYP", @"PCC"], @[@"ZMZ"], )@"M"]]
CFStringRef cfStrtestWord = fn StringUppercaseString( w )
NSUInteger length = fn StringLength( cfStrtestWord )
NSUInteger count = fn ArrayCount( blocks )
for i = 0 to length - 1
letterFound = NO
for j = 0 to count - 1
CFStringRef subString = mid( testWord, i, 1 )
// NSLog( @"%@\n", subString )
CFStringRef compareStr CFArrayRef tempArr = fn ArrayObjectAtIndex( blocks, j )
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
end if
next
if ( not letterFound ) then result = @"NO" : exit fn
next
end fn = result
 
blocks = fn MutableArrayWithArray( @[@"BO", @"XK", @"DQ", @"CP",¬
@"NA", @"GT", @"RE", @"TG", @"QD", @"FS", @"JW", @"HU", @"VI",¬
@"AN", @"OB", @"ER", @"FS", @"LY", @"PC", @"ZM"] )
 
NSLog( @"a: Can blocks spell? %@\n", fn CanBlocksSpellCanSpell( @"a" ) )
CFStringRef cfStr = fn StringUppercaseString( w )
NSLog( @"Bark: Can blocks spell? %@\n", fn CanBlocksSpellCanSpell( @"Bark" ) )
NSUInteger length = fn StringLength( cfStr )
NSLog( @"BOOKbOok: Can blocks spell? %@\n", fn CanBlocksSpellCanSpell( @"BOOKbOok" ) )
NSUInteger count = fn ArrayCount( blocks )
NSLog( @"treat: %@\n", fn CanSpell( @"treat" ) )
NSLog( @"COMMON: Can blocks spell? %@\n", fn CanBlocksSpellCanSpell( @"COMMON" ) )
NSLog( @"squad: %@\n", fn CanSpell( @"squad" ) )
NSLog( @"cnfuse: %@\n", fn CanSpell( @"cnfuse" ) )
 
for i = 0 to length - 1
for j = 0 to count - 1
CFStringRef charStr = mid( cfStr, i, 1 )
CFStringRef compareStr = fn ArrayObjectAtIndex( blocks, j )
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
end if
if ( fn StringIsEqual( charStr, testStr2 ) == YES )
cFinal = fn StringByAppendingString( cFinal, testStr2 ) : MutableArrayReplaceObjectAtIndex( blocks, @" ", j ) : exit for
end if
next
next
if fn StringIsEqual( cFinal, cfStr ) == YES then result = @"YES"
end fn = result
 
NSLog( @"a: Can blocks spell? %@", fn CanBlocksSpell( @"a" ) )
NSLog( @"Bark: Can blocks spell? %@", fn CanBlocksSpell( @"Bark" ) )
NSLog( @"BOOK: Can blocks spell? %@", fn CanBlocksSpell( @"BOOK" ) )
NSLog( @"TrEaT: Can blocks spell? %@", fn CanBlocksSpell( @"TrEaT" ) )
NSLog( @"COMMON: Can blocks spell? %@", fn CanBlocksSpell( @"COMMON" ) )
NSLog( @"Squad: Can blocks spell? %@", fn CanBlocksSpell( @"Squad" ) )
NSLog( @"conFUse: Can blocks spell? %@", fn CanBlocksSpell( @"conFUse" ) )
 
HandleEvents
Line 4,569 ⟶ 4,572:
conFUse: Can blocks spell? YES
</pre>
 
 
 
 
=={{header|Gambas}}==
715

edits