Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = {}
- f[1] = 1
- f[2] = 1
- f[3] = 1
- f[9] = 1
- f[4] = 2
- f[11] = 2
- f[18] = 2
- f[19] = 2
- f[5] = 3
- f[12] = 3
- f[6] = 4
- f[7] = 4
- f[13] = 4
- f[14] = 4
- f[8] = 5
- f[15] = 5
- f[16] = 5
- f[23] = 5
- f[22] = 6
- f[29] = 6
- f[30] = 6
- f[10] = 7
- f[17] = 7
- f[24] = 7
- f[31] = 7
- f[25] = 8
- f[32] = 8
- f[20] = 9
- f[26] = 9
- f[27] = 9
- f[33] = 9
- f[21] = 10
- f[28] = 10
- f[34] = 10
- f[35] = 10
- g = {}
- g[1] = {colors.red, false}
- g[2] = {colors.lime, false}
- g[3] = {colors.orange, false}
- g[4] = {colors.blue, false}
- g[5] = {colors.brown, false}
- g[6] = {colors.magenta, false}
- g[7] = {colors.pink, false}
- g[8] = {colors.lightBlue, false}
- g[9] = {colors.green, false}
- g[10] = {colors.cyan, false}
- sol = {false, true, false, false, true, false, false, false, false, true}
- sol[1] = false
- sol[2] = true
- sol[3] = false
- sol[4] = false
- sol[5] = true
- sol[6] = false
- sol[7] = false
- sol[8] = false
- sol[9] = false
- sol[10] = true
- function pixel2coord(pixel)
- pixel = pixel-1
- y = math.floor(pixel / 7)
- x = pixel % 7
- return x+1, y+1
- end
- function coord2pixel(x, y)
- x = x-1
- y = y-1
- pixel = y * 7 + x
- return pixel+1
- end
- function hitAllPoints(pixel)
- for i=1, 35, 1 do
- if f[i] == f[pixel] then
- x,y = pixel2coord(i)
- if g[f[i]][2] then
- paintutils.drawPixel(x,y,colors.white)
- else
- paintutils.drawPixel(x,y,g[f[i]][1])
- end
- end
- end
- g[f[pixel]][2] = not g[f[pixel]][2]
- end
- function touched(x, y)
- pixel = coord2pixel(x,y)
- hitAllPoints(pixel)
- end
- function checkSolution()
- return not (g[1][2] or g[3][2] or g[4][2] or g[6][2] or g[7][2] or g[8][2] or g[9][2]) and g[2][2] and g[5][2] and g[10][2]
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- touched(x, y)
- if checkSolution() then
- redstone.setOutput("back", true)
- else
- redstone.setOutput("back", false)
- end
- end
Add Comment
Please, Sign In to add comment