Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
13
Task/Rep-string/REXX/rep-string-2.rexx
Normal file
13
Task/Rep-string/REXX/rep-string-2.rexx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*REXX pgm determines if a str is a repStr, returns minimum len. repStr.*/
|
||||
s=1001110011 1110111011 0010010010 1010101010 1111111111 0100101101 0100100 101 11 00 1
|
||||
/* [↑] a list of binary strings.*/
|
||||
do k=1 for words(s); _=word(s,k) /*process all the binary strings.*/
|
||||
say right(_,25) repString(_) /*show the original & the result.*/
|
||||
end /*k*/ /* [↑] "result" may be negatory.*/
|
||||
exit /*stick a fork in it, we're done.*/
|
||||
/*───────────────────────────────────REPSTRING subroutine───────────────*/
|
||||
repString: procedure; parse arg x; L=length(x); r@= ' rep string='
|
||||
do j=1 for L-1 while j<=L%2; p=left(x,j) /*WHILE tests max*/
|
||||
if left(copies(p,L),L)==x then return r@ left(p,15) '[length' j"]"
|
||||
end /*j*/ /* [↑] we have found a repString*/
|
||||
return ' (no repetitions)' /*(sigh)∙∙∙ a failure to find rep*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue