ABC problem: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) |
No edit summary |
||
Line 4,512: | Line 4,512: | ||
SQUAD true |
SQUAD true |
||
CONFUSE true</pre> |
CONFUSE true</pre> |
||
=={{header|FutureBasic}}== |
|||
<lang futurebasic> |
|||
include "NSLog.incl" |
|||
local fn CanBlocksSpell( w as CFStringRef ) as CFStringRef |
|||
'~'1 |
|||
NSUInteger i, j |
|||
CFStringRef cFinal = @"", result = @"NO" |
|||
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"] ) |
|||
CFStringRef cfStr = fn StringUppercaseString( w ) |
|||
NSUInteger length = fn StringLength( cfStr ) |
|||
NSUInteger count = fn ArrayCount( blocks ) |
|||
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 |
|||
</lang> |
|||
{{output}} |
|||
<pre> |
|||
a: Can blocks spell? YES |
|||
Bark: Can blocks spell? YES |
|||
BOOK: Can blocks spell? NO |
|||
TrEaT: Can blocks spell? YES |
|||
COMMON: Can blocks spell? NO |
|||
Squad: Can blocks spell? YES |
|||
conFUse: Can blocks spell? YES |
|||
</pre> |
|||
=={{header|Gambas}}== |
=={{header|Gambas}}== |