Data update
This commit is contained in:
parent
61b93a2cd1
commit
5af6d93694
858 changed files with 20572 additions and 2082 deletions
30
Task/ABC-problem/FutureBasic/abc-problem-1.basic
Normal file
30
Task/ABC-problem/FutureBasic/abc-problem-1.basic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn CanBlocksSpell( w as CFStringRef ) as CFStringRef
|
||||
NSUInteger i, j
|
||||
CFStringRef s = @"", t1, t2 : if fn StringIsEqual( w, @"" ) then exit fn = @"YES" else w = ucase(w)
|
||||
|
||||
mda(0) = {@"BO",@"XK",@"DQ",@"CP",@"NA",@"GT",@"RE",@"TG",@"QD",¬
|
||||
@"FS",@"JW",@"HU",@"VI",@"AN",@"OB",@"ER",@"FS",@"LY",@"PC",@"ZM"}
|
||||
|
||||
for i = 0 to len(w) - 1
|
||||
for j = 0 to mda_count - 1
|
||||
t1 = mid( mda(j), 0, 1 ) : t2 = mid( mda(j), 1, 1 )
|
||||
if ( fn StringIsEqual( mid( w, i, 1 ), t1 ) ) then s = fn StringByAppendingString( s, t1 ) : mda(j) = @" " : break
|
||||
if ( fn StringIsEqual( mid( w, i, 1 ), t2 ) ) then s = fn StringByAppendingString( s, t2 ) : mda(j) = @" " : break
|
||||
next
|
||||
next
|
||||
if fn StringIsEqual( s, w ) then exit fn = @"YES"
|
||||
end fn = @"NO"
|
||||
|
||||
NSUInteger i
|
||||
CFArrayRef words
|
||||
CFStringRef w
|
||||
words = @[@"", @"a",@"Bark",@"BOOK",@"TrEaT",@"COMMON",@"Squad",@"conFUse",@"ABBA",@"aUtO"]
|
||||
for w in words
|
||||
printf @"Can blocks spell %7s : %@", fn StringUTF8String( w ), fn CanBlocksSpell( w )
|
||||
next
|
||||
|
||||
NSLog( @"%@", fn WindowPrintViewString( 1 ) )
|
||||
|
||||
HandleEvents
|
||||
18
Task/ABC-problem/FutureBasic/abc-problem-2.basic
Normal file
18
Task/ABC-problem/FutureBasic/abc-problem-2.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
local fn blocks( wordList as str255 )
|
||||
sint16 found, r, x = 3, y = -9 : str63 ch, blocks : ch = " " : blocks = " "
|
||||
for r = 1 to len$( wordList ) +1
|
||||
found = instr$( 1, blocks, ch )
|
||||
select found
|
||||
case > 3: mid$( blocks, found and -2, 2 ) = "__" : text , , fn ColorYellow
|
||||
rect fill ( x, y + 5.5, 15, 15 ), fn ColorBrown
|
||||
case 0: text , , fn ColorLightGray
|
||||
case < 4: blocks=" ,;BOXKDQCPNAGTRETGQDFSJWHUVIANOBERFSLYPCZM": x=3: y+=26: ch=""
|
||||
end select
|
||||
text @"Courier New Bold", 16 : print %( x + 2.5, y ) ch : x += 17
|
||||
ch = ucase$( mid$( wordList, r, 1 ) )
|
||||
next
|
||||
end fn
|
||||
|
||||
window 1, @"ABC problem in FutureBasic", ( 0, 0, 300, 300 )
|
||||
fn blocks( "a baRk booK;treat,COMMON squad Confused comparable incomparable nondeductibles" )
|
||||
handleevents
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
local fn CanBlocksSpell( w as CFStringRef ) as CFStringRef
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue