Comment

Comment by chaoxu

This problem can be generalized to the following graph light out game: Given a graph where each vertex is labeled 0 or 1. Each move flips all the bits on a vertex and all its neighbors. If you are given the end label configuration, find a set of moves that reaches the end configuration. (why a set of moves? you can show that you never need to make a move on a vertex twice, and the order doesn't matter).

So the question is, which vertices do I have to touch once?

It's easy to solve the problem by solving a system of linear equation(in F_2, not in R). Ax=b, where A is the adjacency matrix, and (b[i]= (current bit on vertex i != desired bit on vertex i)).

Naively, for the light out game on a nxn board, this implies a O(n^6) using Gaussian elimination algorithm. Or O((n^2)^ω)) (where ω is the matrix multiplication constant) by finding a matrix pseudoinverse and then multiply.

The graph light out game can be solved in O(n^(ω/2)) time for planar graphs! Because most matrix operations can be done much faster on the adjacency matrix of a planar graph due to nested dissection. http://en.wikipedia.org/wiki/Nested_dissection

In particular, the current game is a planar grid graph. So there exist a O(n^ω) algorithm.

parent chaoxu 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton