Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
50
Task/Rep-string/BCPL/rep-string.bcpl
Normal file
50
Task/Rep-string/BCPL/rep-string.bcpl
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
get "libhdr"
|
||||
|
||||
// Returns the length of the longest rep-string
|
||||
// (0 if there are none)
|
||||
let repstring(s) = valof
|
||||
$( for i = s%0/2 to 1 by -1 do
|
||||
$( for j = 1 to i
|
||||
$( let k = i
|
||||
while j+k <= s%0 do
|
||||
$( unless s%(j+k)=s%j goto next
|
||||
k := k + i
|
||||
$)
|
||||
$)
|
||||
resultis i
|
||||
next: loop
|
||||
$)
|
||||
resultis 0
|
||||
$)
|
||||
|
||||
// Print first N characters of string
|
||||
let writefirst(s, n) be
|
||||
$( let x = s%0
|
||||
s%0 := n
|
||||
writes(s)
|
||||
s%0 := x
|
||||
$)
|
||||
|
||||
// Test string
|
||||
let rep(s) be
|
||||
$( let n = repstring(s)
|
||||
writef("%S: ",s)
|
||||
test n=0
|
||||
do writes("none")
|
||||
or writefirst(s,n)
|
||||
wrch('*N')
|
||||
$)
|
||||
|
||||
let start() be
|
||||
$( rep("1001110011")
|
||||
rep("1110111011")
|
||||
rep("0010010010")
|
||||
rep("1010101010")
|
||||
rep("1111111111")
|
||||
rep("0100101101")
|
||||
rep("0100100")
|
||||
rep("101")
|
||||
rep("11")
|
||||
rep("00")
|
||||
rep("1")
|
||||
$)
|
||||
Loading…
Add table
Add a link
Reference in a new issue