Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Rep-string/PureBasic/rep-string.basic
Normal file
22
Task/Rep-string/PureBasic/rep-string.basic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
a$="1001110011"+#CRLF$+"1110111011"+#CRLF$+"0010010010"+#CRLF$+"1010101010"+#CRLF$+"1111111111"+#CRLF$+
|
||||
"0100101101"+#CRLF$+"0100100" +#CRLF$+"101" +#CRLF$+"11" +#CRLF$+"00" +#CRLF$+
|
||||
"1" +#CRLF$
|
||||
|
||||
OpenConsole()
|
||||
|
||||
Procedure isRepStr(s1$,s2$)
|
||||
If Int(Len(s1$)/Len(s2$))>=2 : ProcedureReturn isRepStr(s1$,s2$+s2$) : EndIf
|
||||
If Len(s1$)>Len(s2$) : ProcedureReturn isRepStr(s1$,s2$+Left(s2$,Len(s1$)%Len(s2$))) : EndIf
|
||||
If s1$=s2$ : ProcedureReturn #True : Else : ProcedureReturn #False : EndIf
|
||||
EndProcedure
|
||||
|
||||
For k=1 To CountString(a$,#CRLF$)
|
||||
s1$=StringField(a$,k,#CRLF$) : s2$=Left(s1$,Len(s1$)/2)
|
||||
While Len(s2$)
|
||||
r=isRepStr(s1$,s2$)
|
||||
If Not r : s2$=Left(s2$,Len(s2$)-1) : Else : Break : EndIf
|
||||
Wend
|
||||
If Len(s2$) And r : PrintN(LSet(s1$,15,Chr(32))+#TAB$+"longest sequence: "+s2$) : EndIf
|
||||
If Not Len(s2$) : PrintN(LSet(s1$,15,Chr(32))+#TAB$+"found nothing.") : EndIf
|
||||
Next
|
||||
Input()
|
||||
Loading…
Add table
Add a link
Reference in a new issue