Programming puzzle with boolean circuits

Chris Angelico rosuav at gmail.com
Mon Dec 9 20:41:46 EST 2013


On Tue, Dec 10, 2013 at 12:25 AM, Chris Angelico <rosuav at gmail.com> wrote:
> Unfortunately I haven't been able to prove that the code works,
> because even with some changes it's taking way too long. But hey, it's
> a crazy fun piece to work with!

Well... it eventually solved the problem. I don't know how many CPU
hours it took but it threw a SolutionFound exception eventually.

Unfortunately I didn't parenthesize the display. The solution seems to
involve using a NOT gate and then splitting its output, so you'll see
more than two instances of 'not' in the output. This is definitely not
an optimal solution, but hey, you asked for a brute-force solver!

~$1 = $4 or not $1 and $2 or $4 and $1 or $2 and $4 and not $1 and $2
or $4 and $1 or $2 or $2 or not $1 and $2 or $4 and $1 or $2 and $2
and not $1 and $2 or $4 and $1 or $2 or not $2 or $1 or $4 and $2 and
$1 and $4 or not $1 and $2 or $4 and $1 or $2
~$2 = $4 or not $1 and $2 or $4 and $1 or $2 and $4 and not $1 and $2
or $4 and $1 or $2 or $1 or not $1 and $2 or $4 and $1 or $2 and $1
and not $1 and $2 or $4 and $1 or $2 or not $2 or $1 or $4 and $2 and
$1 and $4 or not $1 and $2 or $4 and $1 or $2
~$4 = $2 or not $1 and $2 or $4 and $1 or $2 and $2 and not $1 and $2
or $4 and $1 or $2 or $1 or not $1 and $2 or $4 and $1 or $2 and $1
and not $1 and $2 or $4 and $1 or $2 or not $2 or $1 or $4 and $2 and
$1 and $4 or not $1 and $2 or $4 and $1 or $2

ChrisA



More information about the Python-list mailing list