June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,17 @@
all$ = "1001110011 1110111011 0010010010 1010101010 1111111111 0100101101 0100100 101 11 00 1"
FOR word$ IN all$
FOR x = LEN(word$)/2 DOWNTO 1
ex$ = EXPLODE$(word$, x)
FOR st$ IN UNIQ$(ex$)
IF NOT(REGEX(HEAD$(ex$, 1), "^" & st$)) THEN CONTINUE 2
NEXT
PRINT "Repeating string: ", word$, " -> ", HEAD$(ex$, 1)
CONTINUE 2
NEXT
PRINT "Not a repeating string: ", word$
NEXT

View file

@ -1,34 +1,23 @@
function list_reps{T<:String}(r::T)
function repstring(r::AbstractString)
n = length(r)
replst = T[]
for m in 1:n>>1
s = r[1:chr2ind(r,m)]
(s^(div(n,m)+1))[1:chr2ind(r,n)] == r || continue
replst = String[]
for m in 1:n÷2
s = r[1:chr2ind(r, m)]
if (s ^ cld(n, m))[1:chr2ind(r, n)] != r continue end
push!(replst, s)
end
return replst
end
tests = {"1001110011",
"1110111011",
"0010010010",
"1010101010",
"1111111111",
"0100101101",
"0100100",
"101",
"11",
"00",
"1",
"\u2200\u2203\u2200\u2203\u2200\u2203\u2200\u2203"}
tests = ["1001110011", "1110111011", "0010010010", "1010101010", "1111111111",
"0100101101", "0100100", "101", "11", "00", "1",
"\u2200\u2203\u2200\u2203\u2200\u2203\u2200\u2203"]
for r in tests
replst = list_reps(r)
rlen = length(replst)
print(@sprintf(" %s ", r))
if rlen == 0
println("is not a rep-string.")
replst = repstring(r)
if isempty(replst)
println("$r is not a rep-string.")
else
println("is a rep-string of ", join(replst, ", "), ".")
println("$r is a rep-string of ", join(replst, ", "), ".")
end
end

View file

@ -0,0 +1,34 @@
# Project : Rep-string
# Date : 2017/10/14
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
test = ["1001110011",
"1110111011",
"0010010010",
"1010101010",
"1111111111",
"0100101101",
"0100100",
"101",
"11",
"00",
"1"]
for n = 1 to len(test)
strend = ""
for m=1 to len(test[n])
strbegin = substr(test[n], 1, m)
strcut = right(test[n], len(test[n]) - m)
nr = substr(strcut, strbegin)
if nr=1 and len(test[n]) > 1
strend = strbegin
ok
next
if strend = ""
see "" + test[n] + " -> (none)" + nl
else
see "" + test[n] + " -> " + strend + nl
ok
next