Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
36
Task/Rep-string/DuckDB/rep-string.duckdb
Normal file
36
Task/Rep-string/DuckDB/rep-string.duckdb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
create or replace function repString(s) as (
|
||||
if (length(s) < 2, null,
|
||||
(with recursive size_t as (select length(s) as size),
|
||||
cte as
|
||||
(select ((size % 2) + (size // 2)) as len, '' as t, false as found
|
||||
from size_t
|
||||
union all
|
||||
select len-1 as len,
|
||||
s[1:len] as t,
|
||||
s == (repeat(s[1:len], (size // len))
|
||||
|| coalesce(t[1:(size % len)], ''))
|
||||
as found
|
||||
from cte, size_t
|
||||
where len > 0 and found = false
|
||||
)
|
||||
select first(t)
|
||||
from cte
|
||||
where found
|
||||
))
|
||||
);
|
||||
|
||||
select s, repString(s)
|
||||
from unnest(
|
||||
[
|
||||
'1001110011',
|
||||
'1110111011',
|
||||
'0010010010',
|
||||
'1010101010',
|
||||
'1111111111',
|
||||
'0100101101',
|
||||
'0100100',
|
||||
'101',
|
||||
'11',
|
||||
'00',
|
||||
'1'
|
||||
]) _(s);
|
||||
Loading…
Add table
Add a link
Reference in a new issue