Have an R script for calculating button configurations, but I didn't fix it to account for certain lights being stuck on after the last button is flipped. If anyone can fix it, let me know.
Base = rep(0,20);A = rep(0,20);B = rep(0,20);C = rep(0,20);D = rep(0,20);E = rep(0,20);G = rep(0,20);H = rep(0,20)
#Input lit lanterns below
Base[c(3,4,12,16,17)] = 1
A[c(2,7)] = 1
B[c(5,8,9,11,12,17,18,20)] = 1
C[c(11,12,13,15,17,18,20)] = 1
D[c(1,6,12,14,17,19)] = 1
E[c(2,6,7,10,12,13,15,17)] = 1
G[c(1,14,19)] = 1
H[c(2,3,4,5,7,8,9,12,16,17)] = 1
bigmatrix = cbind(Base, A, B, C, D, E, G, H)
combinationmatrix = t(expand.grid(1,c(0,1),c(0,1),c(0,1),c(0,1),c(0,1),c(0,1),c(0,1)))
attempts = (bigmatrix %*% combinationmatrix) %% 2
attempttot = colSums(attempts)
x = as.matrix(combinationmatrix[,match(max(attempttot),attempttot)])
rownames(x) = c("N/A", "A", "B", "C", "D", "E", "G", "H")
bigmatrix
cat("Button configuration:")
x
cat("Max lanterns: ", max(attempttot))
# If max lanterns < 20 then something went wrong
Output looks something like this:
http://i.imgur.com/BW9dFWC.png