Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- pat = read() --paternal --localize
- mat = read() --maternal --localize
- pat = pat:sub(1,#pat-(#pat%2))
- mat = mat:sub(1,#mat-(#mat%2))
- split = function(txt,splitPt) --such a useful function
- local output = {}
- local buffer = ""
- for a = 1, #txt do
- if (txt:sub(a,a) == "\n") or (#buffer >= splitPt) then
- output[#output+1] = buffer
- buffer = ""
- end
- buffer = (buffer..txt:sub(a,a)):gsub("\n","")
- if a == #txt then
- output[#output+1] = buffer
- end
- end
- return output
- end
- everyOther = function(txt,step) --localize
- local output = ""
- for a = 1, #txt, step or 2 do
- output = output..txt:sub(a,a)
- end
- return output
- end
- foilArrange = function(str,step)
- step = step or 2
- local output = {}
- local genes = split(str,2)
- for g = 1, #genes do
- for a = 1, #genes[g] do
- for b = 1, #genes[g] do
- if a ~= b then
- output[#output+1] = genes[g]:sub(a,a)..genes[g]:sub(b,b)
- end
- end
- end
- end
- return output
- end
- spliceStr = function(txt1,txt2) --localize
- assert(#txt1 == #txt2, "strings must be same length, you dullard")
- local output = ""
- for a = 1, #txt1 do
- output = output..txt1:sub(a,a)..txt2:sub(a,a)
- end
- return output
- end
- pGenes = foilArrange(pat) --localize
- mGenes = foilArrange(mat) --localize
- grid = {} --localize
- for p = 1, #pat do
- grid[p] = {}
- for m = 1, #mat do
- grid[p][m] = spliceStr(pGenes[p],mGenes[m])
- end
- end
- writeBlocks = function(len,col) --localize
- local pCol = term.getBackgroundColor()
- term.setBackgroundColor(col or colors.white)
- term.write((" "):rep(len or 1))
- term.setBackgroundColor(pCol)
- end
- renderGrid = function(g,sx,sy)
- sx, sy = sx or 2, sy or 2
- term.setCursorPos(sx,sy)
- writeBlocks(1+((#g[1])^2)+#g[1])
- for y = 1, #g do
- term.setCursorPos(sx,sy+(y*2)-1)
- writeBlocks(1)
- for x = 1, #g[y] do
- term.write(grid[y][x])
- writeBlocks(1)
- end
- term.setCursorPos(sx,sy+(y*2))
- writeBlocks(1+((#g[1])^2))
- end
- end
- local cx,cy = term.getCursorPos()
- renderGrid(grid,2,cy+2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement