Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
32
Task/Rep-string/Dyalect/rep-string.dyalect
Normal file
32
Task/Rep-string/Dyalect/rep-string.dyalect
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
func rep(s) {
|
||||
var x = s.Length() / 2
|
||||
while x > 0 {
|
||||
if s.StartsWith(s.Substring(x)) {
|
||||
return x
|
||||
}
|
||||
x -= 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
let m = [
|
||||
"1001110011",
|
||||
"1110111011",
|
||||
"0010010010",
|
||||
"1010101010",
|
||||
"1111111111",
|
||||
"0100101101",
|
||||
"0100100",
|
||||
"101",
|
||||
"11",
|
||||
"00",
|
||||
"1"
|
||||
]
|
||||
|
||||
for s in m {
|
||||
if (rep(s) is n) && n > 0 {
|
||||
print("\(s) \(n) rep-string \(s.Substring(n))")
|
||||
} else {
|
||||
print("\(s) not a rep-string")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue