Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
30
Task/Rep-string/Seed7/rep-string.seed7
Normal file
30
Task/Rep-string/Seed7/rep-string.seed7
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const func integer: repeatLength (in string: text) is func
|
||||
result
|
||||
var integer: length is 0;
|
||||
local
|
||||
var integer: pos is 0;
|
||||
begin
|
||||
for pos range succ(length(text) div 2) downto 1 until length <> 0 do
|
||||
if startsWith(text, text[pos ..]) then
|
||||
length := pred(pos);
|
||||
end if;
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var string: line is "";
|
||||
var integer: length is 0;
|
||||
begin
|
||||
for line range [] ("1001110011", "1110111011", "0010010010", "1010101010",
|
||||
"1111111111", "0100101101", "0100100", "101", "11", "00", "1") do
|
||||
length := repeatLength(line);
|
||||
if length = 0 then
|
||||
writeln("No rep-string for " <& literal(line));
|
||||
else
|
||||
writeln("Longest rep-string for " <& literal(line) <& ": " <& literal(line[.. length]));
|
||||
end if;
|
||||
end for;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue