Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Rep-string/Nim/rep-string.nim
Normal file
22
Task/Rep-string/Nim/rep-string.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import strutils
|
||||
|
||||
proc isRepeated(text: string): int =
|
||||
for x in countdown(text.len div 2, 0):
|
||||
if text.startsWith(text[x..text.high]): return x
|
||||
|
||||
const matchstr = """1001110011
|
||||
1110111011
|
||||
0010010010
|
||||
1010101010
|
||||
1111111111
|
||||
0100101101
|
||||
0100100
|
||||
101
|
||||
11
|
||||
00
|
||||
1"""
|
||||
|
||||
for line in matchstr.split():
|
||||
let ln = isRepeated(line)
|
||||
echo "'", line, "' has a repetition length of ", ln, " i.e ",
|
||||
(if ln > 0: "'" & line[0 ..< ln] & "'" else: "*not* a rep-string")
|
||||
Loading…
Add table
Add a link
Reference in a new issue