Data update
This commit is contained in:
parent
ed705008a8
commit
0df55f9f24
2196 changed files with 32999 additions and 3075 deletions
40
Task/Rep-string/C-sharp/rep-string.cs
Normal file
40
Task/Rep-string/C-sharp/rep-string.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
|
||||
public class RepString
|
||||
{
|
||||
static readonly string[] input = {"1001110011", "1110111011", "0010010010",
|
||||
"1010101010", "1111111111", "0100101101", "0100100", "101", "11",
|
||||
"00", "1", "0100101"};
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
foreach (string s in input)
|
||||
Console.WriteLine($"{s} : {repString(s)}");
|
||||
}
|
||||
|
||||
static string repString(string s)
|
||||
{
|
||||
int len = s.Length;
|
||||
for (int part = len / 2; part > 0; part--)
|
||||
{
|
||||
int tail = len % part;
|
||||
if (tail > 0 && !s.Substring(0, tail).Equals(s.Substring(len - tail)))
|
||||
continue;
|
||||
bool isRepeated = true;
|
||||
for (int j = 0; j < len / part - 1; j++)
|
||||
{
|
||||
int a = j * part;
|
||||
int b = (j + 1) * part;
|
||||
int c = (j + 2) * part;
|
||||
if (!s.Substring(a, part).Equals(s.Substring(b, part)))
|
||||
{
|
||||
isRepeated = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isRepeated)
|
||||
return s.Substring(0, part);
|
||||
}
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
28
Task/Rep-string/EasyLang/rep-string.easy
Normal file
28
Task/Rep-string/EasyLang/rep-string.easy
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
func$ repstr s$ .
|
||||
sl = len s$ div 2 + 1
|
||||
while sl > 1
|
||||
r$ = substr s$ sl 999
|
||||
if r$ = substr s$ 1 len r$
|
||||
return substr r$ 1 (sl - 1)
|
||||
.
|
||||
sl -= 1
|
||||
.
|
||||
return ""
|
||||
.
|
||||
repeat
|
||||
s$ = input
|
||||
until s$ = ""
|
||||
print s$ & " -> " & repstr s$
|
||||
.
|
||||
input_data
|
||||
1001110011
|
||||
1110111011
|
||||
0010010010
|
||||
1010101010
|
||||
1111111111
|
||||
0100101101
|
||||
0100100
|
||||
101
|
||||
11
|
||||
00
|
||||
1
|
||||
34
Task/Rep-string/Refal/rep-string.refal
Normal file
34
Task/Rep-string/Refal/rep-string.refal
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
$ENTRY Go {
|
||||
, ('1001110011') ('1110111011') ('0010010010')
|
||||
('1010101010') ('1111111111') ('0100101101')
|
||||
('0100100') ('101') ('11') ('00') ('1'): e.Tests
|
||||
= <Each Show e.Tests>;
|
||||
};
|
||||
|
||||
Each {
|
||||
s.F = ;
|
||||
s.F t.I e.R = <Mu s.F t.I> <Each s.F e.R>;
|
||||
};
|
||||
|
||||
Show {
|
||||
(e.S), <RepString e.S>: e.R = <Prout e.S ' => ' e.R>;
|
||||
};
|
||||
|
||||
RepString {
|
||||
() e.S = ;
|
||||
(e.R) e.S, <Lengthen (e.R) e.S>: e.S e.X = e.R;
|
||||
(e.R s.C) e.S = <RepString (e.R) e.S>;
|
||||
e.S, <Lenw e.S>: s.L e.S,
|
||||
<First <Div s.L 2> e.S>: (e.F) e.X
|
||||
= <RepString (e.F) e.S>;
|
||||
};
|
||||
|
||||
Lengthen {
|
||||
(e.A) e.B, <Lenw e.A>: s.LA e.A,
|
||||
<Lenw e.B>: s.LB e.B,
|
||||
<Compare s.LA s.LB>: '-'
|
||||
= <Lengthen (e.A e.A) e.B>;
|
||||
(e.A) e.B, <Lenw e.B>: s.LB e.B,
|
||||
<First s.LB e.A>: (e.FA) e.RA
|
||||
= e.FA;
|
||||
};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import "/fmt" for Fmt
|
||||
import "./fmt" for Fmt
|
||||
|
||||
var repString = Fn.new { |s|
|
||||
var reps = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue