Skip to main content
Commonmark migration
Source Link

#Lua - 506 380 - bytes

Lua - 506 380 - bytes

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read"*l"n=a:match("%d+")+0 m=a:match"[a-z]+"o=""for i=1,n do for k=1,n^2,n do o=o..m:sub(i+k-1,i+k-1)end end q={m,o}for g=1,n^2 do for u=1,2 do l=q[u]:sub(g,g)for r=1,n do i=1 t=0 e=0 while i do s,e=q[u]:find(l:rep(r),e+1)if s then x=s-(e-s)-i-1 print(s,i,r,n,r)if x==n or x==n-2 or t==0 then t=t+1 i=s end else i=nil end end if t*r==n then print(l)os.exit()end end end end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll look to golf my code for what it's worth.

Update: golfed in honour of those who will rise above us. While I was at it I had to fix my code to recognized path going from right to left. Oops.

#Lua - 506 380 - bytes

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read"*l"n=a:match("%d+")+0 m=a:match"[a-z]+"o=""for i=1,n do for k=1,n^2,n do o=o..m:sub(i+k-1,i+k-1)end end q={m,o}for g=1,n^2 do for u=1,2 do l=q[u]:sub(g,g)for r=1,n do i=1 t=0 e=0 while i do s,e=q[u]:find(l:rep(r),e+1)if s then x=s-(e-s)-i-1 print(s,i,r,n,r)if x==n or x==n-2 or t==0 then t=t+1 i=s end else i=nil end end if t*r==n then print(l)os.exit()end end end end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll look to golf my code for what it's worth.

Update: golfed in honour of those who will rise above us. While I was at it I had to fix my code to recognized path going from right to left. Oops.

Lua - 506 380 - bytes

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read"*l"n=a:match("%d+")+0 m=a:match"[a-z]+"o=""for i=1,n do for k=1,n^2,n do o=o..m:sub(i+k-1,i+k-1)end end q={m,o}for g=1,n^2 do for u=1,2 do l=q[u]:sub(g,g)for r=1,n do i=1 t=0 e=0 while i do s,e=q[u]:find(l:rep(r),e+1)if s then x=s-(e-s)-i-1 print(s,i,r,n,r)if x==n or x==n-2 or t==0 then t=t+1 i=s end else i=nil end end if t*r==n then print(l)os.exit()end end end end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll look to golf my code for what it's worth.

Update: golfed in honour of those who will rise above us. While I was at it I had to fix my code to recognized path going from right to left. Oops.

deleted 107 characters in body
Source Link
AndoDaan
  • 2.4k
  • 15
  • 13

#Lua - 506 (not yet golfed)506 380 - bytes

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read("*l")
n=tonumber(string.read"*l"n=a:match(a, "%d+"))
m=string.match(a,"[a+0 m=a:match"[a-z]+")
o=""
forz]+"o=""for i=1,n do
  for k=1,n^2,n do

    o=o..m:sub(i+k-1,i+k-1)
 end

  end

  q={m,o}
 for g=1,n^2 do
        for u=1,2 do
        l=q[u]:sub(g,g)
        for r=1,n do
            i=1
            t=0
            e=0
            while i do
                s,e=q[u]:find(string.l:rep(l,r), e+1)

                if s then
                    if sx=s-(e-s)-i-1==n or t==0 then
                1 print(s,i,r,n,r)if x==n or x==n-2 or t==0 then t=t+1
                        i=s
                    end
                else
                    i=nil
                end

            end
            if t*r==n then  print(l) os.exit()end
        end
    end
  end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll lookIf a wild challenger appears, I'll look to golf my code for what it's worth.

Update: golfed in honour of those who will rise above us. While I was at it I had to golffix my code for what it's worthto recognized path going from right to left. Oops.

#Lua - 506 (not yet golfed)

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read("*l")
n=tonumber(string.match(a, "%d+"))
m=string.match(a,"[a-z]+")
o=""
for i=1,n do
 for k=1,n^2,n do

    o=o..m:sub(i+k-1,i+k-1)
 end

 end

 q={m,o}
 for g=1,n^2 do
        for u=1,2 do
        l=q[u]:sub(g,g)
        for r=1,n do
            i=1
            t=0
            e=0
            while i do
                s,e=q[u]:find(string.rep(l,r), e+1)

                if s then
                    if s-(e-s)-i-1==n or t==0 then
                        t=t+1
                        i=s
                    end
                else
                    i=nil
                end

            end
            if t*r==n then  print(l) os.exit()end
        end
    end
 end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll look to golf my code for what it's worth.

#Lua - 506 380 - bytes

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read"*l"n=a:match("%d+")+0 m=a:match"[a-z]+"o=""for i=1,n do for k=1,n^2,n do o=o..m:sub(i+k-1,i+k-1)end end q={m,o}for g=1,n^2 do for u=1,2 do l=q[u]:sub(g,g)for r=1,n do i=1 t=0 e=0 while i do s,e=q[u]:find(l:rep(r),e+1)if s then x=s-(e-s)-i-1 print(s,i,r,n,r)if x==n or x==n-2 or t==0 then t=t+1 i=s end else i=nil end end if t*r==n then print(l)os.exit()end end end end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll look to golf my code for what it's worth.

Update: golfed in honour of those who will rise above us. While I was at it I had to fix my code to recognized path going from right to left. Oops.

Source Link
AndoDaan
  • 2.4k
  • 15
  • 13

#Lua - 506 (not yet golfed)

I felt kinda bad that you hadn't received any submission for your well thought out challenge, so I threw this together. It was quit fun inferring what the minimum distinguishable properties the path must have from the information you gave. I hope I got it right... AND correctly implemented it.

a=io.read("*l")
n=tonumber(string.match(a, "%d+"))
m=string.match(a,"[a-z]+")
o=""
for i=1,n do
for k=1,n^2,n do

    o=o..m:sub(i+k-1,i+k-1)
end

end

q={m,o}
for g=1,n^2 do
        for u=1,2 do
        l=q[u]:sub(g,g)
        for r=1,n do
            i=1
            t=0
            e=0
            while i do
                s,e=q[u]:find(string.rep(l,r), e+1)

                if s then
                    if s-(e-s)-i-1==n or t==0 then
                        t=t+1
                        i=s
                    end
                else
                    i=nil
                end

            end
            if t*r==n then  print(l) os.exit()end
        end
    end
end

It can be tested with:

lua divisorPath.lua "input"

If a wild challenger appears, I'll look to golf my code for what it's worth.