Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
32
Task/Rep-string/V-(Vlang)/rep-string.v
Normal file
32
Task/Rep-string/V-(Vlang)/rep-string.v
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
fn rep(s string) int {
|
||||
for x := s.len / 2; x > 0; x-- {
|
||||
if s.starts_with(s[x..]) {
|
||||
return x
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
const m = '
|
||||
1001110011
|
||||
1110111011
|
||||
0010010010
|
||||
1010101010
|
||||
1111111111
|
||||
0100101101
|
||||
0100100
|
||||
101
|
||||
11
|
||||
00
|
||||
1'
|
||||
|
||||
fn main() {
|
||||
for s in m.fields() {
|
||||
n := rep(s)
|
||||
if n > 0 {
|
||||
println("$s $n rep-string ${s[..n]}")
|
||||
} else {
|
||||
println("$s not a rep-string")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue