Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/ABC-problem/PureBasic/abc-problem-1.basic
Normal file
32
Task/ABC-problem/PureBasic/abc-problem-1.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
EnableExplicit
|
||||
#LETTERS = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM "
|
||||
|
||||
Procedure.s can_make_word(word.s)
|
||||
Define letters.s = #LETTERS, buffer.s
|
||||
Define index1.i, index2.i
|
||||
Define match.b
|
||||
For index1=1 To Len(word)
|
||||
index2=1 : match=#False
|
||||
Repeat
|
||||
buffer=StringField(letters,index2,Space(1))
|
||||
If FindString(buffer,Mid(word,index1,1),1,#PB_String_NoCase)
|
||||
letters=RemoveString(letters,buffer+Chr(32),0,1,1)
|
||||
match=#True
|
||||
Break
|
||||
EndIf
|
||||
index2+1
|
||||
Until index2>CountString(letters,Space(1))
|
||||
If Not match : ProcedureReturn word+#TAB$+"FALSE" : EndIf
|
||||
Next
|
||||
ProcedureReturn word+#TAB$+"TRUE"
|
||||
EndProcedure
|
||||
|
||||
OpenConsole()
|
||||
PrintN(can_make_word("a"))
|
||||
PrintN(can_make_word("BaRK"))
|
||||
PrintN(can_make_word("BOoK"))
|
||||
PrintN(can_make_word("TREAt"))
|
||||
PrintN(can_make_word("cOMMON"))
|
||||
PrintN(can_make_word("SqUAD"))
|
||||
PrintN(can_make_word("COnFUSE"))
|
||||
Input()
|
||||
20
Task/ABC-problem/PureBasic/abc-problem-2.basic
Normal file
20
Task/ABC-problem/PureBasic/abc-problem-2.basic
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#LETTERS = "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM "
|
||||
|
||||
Macro test(t)
|
||||
Print(t+#TAB$+#TAB$+"= ") : If can_make_word(t) : PrintN("True") : Else : PrintN("False") : EndIf
|
||||
EndMacro
|
||||
|
||||
Procedure.s residue(s$,n.i)
|
||||
ProcedureReturn Left(s$,Int(n/3)*3)+Mid(s$,Int(n/3)*3+4)
|
||||
EndProcedure
|
||||
|
||||
Procedure.b can_make_word(word$,letters$=#LETTERS)
|
||||
n=FindString(letters$,Left(word$,1),1,#PB_String_NoCase)
|
||||
If Len(word$) And n : ProcedureReturn can_make_word(Mid(word$,2),residue(letters$,n)) : EndIf
|
||||
If Not Len(word$) : ProcedureReturn #True : Else : ProcedureReturn #False : EndIf
|
||||
EndProcedure
|
||||
|
||||
OpenConsole()
|
||||
test("a") : test("BaRK") : test("BOoK") : test("TREAt")
|
||||
test("cOMMON") : test("SqUAD") : test("COnFUSE")
|
||||
Input()
|
||||
Loading…
Add table
Add a link
Reference in a new issue