Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'python.': 0.02; 'solution,': 0.09; 'tackle': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '>>': 0.16; 'ah,': 0.16; 'boolean': 0.16; 'discusses': 0.16; 'equations': 0.16; 'googled': 0.16; 'hint': 0.16; 'subject:Programming': 0.16; 'thought.': 0.16; '\xc2\xa0-': 0.16; 'wrote:': 0.18; '(not': 0.18; 'code.': 0.18; 'coding': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'own.': 0.24; 'guys': 0.24; 'mon,': 0.24; 'question': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'appreciated': 0.26; 'this:': 0.26; 'post': 0.26; 'nicht': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'along': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; 'url:05': 0.31; 'url:2008': 0.31; 'figure': 0.32; 'url:python': 0.33; 'implemented': 0.33; 'maybe': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'advice': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'das': 0.36; "i'll": 0.36; 'possible': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'two': 0.37; 'ends': 0.38; 'needed': 0.38; 'sure': 0.39; 'und': 0.40; 'url:mail': 0.40; 'how': 0.40; 'even': 0.60; 'easy': 0.60; 'solve': 0.60; 'most': 0.60; 'first': 0.61; 'group,': 0.63; 'thomas': 0.65; 'hours': 0.66; 'here': 0.66; 'attention.': 0.68; 'unsere': 0.68; 'electrical': 0.74; 'circuit': 0.84; 'college,': 0.84; 'gates.': 0.84; 'karl': 0.84; 'played': 0.84; 'heute': 0.91; 'joel': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=IOb+VrvXR5WMenoTHzZ3fSpDHa+ao9AmIxrWKD4Rf5Q=; b=Kcn6yvu9Hx4/zxEuxaPgazNlDxdjWP5ZdxgQ9FDY/ESwMHXgvJUF6oX1nh6IVZescQ ScFHu8YFaLNprEPzC0LPa+EPlZyO+AebpT2yVQPeLk2k5y3oRYG0mCegSCo8kRS6XjOe paFsYtUuxS1MRGfliuO6C5uu1S6L8RmgmE8w57868JWyGaXiDbVmXsz5FXKVAXuK8Csw x59xC9N0dYCo1AC55pB31e/0tUUWOrqAaQf3DTGZ25bDi2S4/jp4mywKlN16Quvgsghv AnBr6u2e1CQ1RqtdD/YQgHSOnpKO9BP0SZ7SBQxs5I2KwnZGG8vKeYvqE7GdqSNcAiH6 UsnA== MIME-Version: 1.0 X-Received: by 10.220.186.202 with SMTP id ct10mr11990994vcb.14.1386620365544; Mon, 09 Dec 2013 12:19:25 -0800 (PST) In-Reply-To: References: Date: Mon, 9 Dec 2013 15:19:25 -0500 Subject: Re: Programming puzzle with boolean circuits From: Joel Goldstick To: Johannes Bauer Content-Type: multipart/alternative; boundary=047d7b676fd053d2cb04ed1fb696 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 130 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386620372 news.xs4all.nl 2839 [2001:888:2000:d::a6]:40083 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61409 --047d7b676fd053d2cb04ed1fb696 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Dec 9, 2013 at 6:49 AM, Johannes Bauer wrote= : > Hi group, > > it's somewhat OT here, but I have a puzzle to which I would like a > solution -- but I'm unsure how I should tackle the problem with Python. > But it's a fun puzzle, so maybe it'll be appreciated here. > > The question is: How do you design a boolean circuit that contains at > most 2 NOT gates, but may contain as many AND or OR gates that inverts > three inputs? IOW: Build three inverters by using only two inverters > (and an infinite amount of AND/OR). > > Surprisingly, this is possible (and I even know the solution, but won't > give it away just yet). > > I found this puzzle again and was thinking about: How would I code a > brute-force approach to this problem in Python? And to my surprise, it > isn't as easy as I thought. So I'm looking for some advice from you guys > (never huts to improve ones coding skills). > > Best regards, > Johannes > > I studied Electrical Engineering in college, so this puzzle grabbed my attention. For a couple of hours I played around thinking about how to attack this problem My first thought was that if you had two inverters (NOT gates), you needed to create an inverter with and and or gates. That goes nowhere. So, I googled around and found this: http://www.thelowlyprogrammer.com/2008/05/not-puzzle-solution.html (spoiler alert). It discusses how you can solve the problem, but it doesn't give python code. As it ends up I implemented that solution in 18 lines of code So, my hint is that it can be solved by creating several simultaneous equations I'll send my code along if someone asks, but I don't want to post it here because I'm sure others will want to figure it out on their own. > -- > >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > > Zumindest nicht =C3=B6ffentlich! > Ah, der neueste und bis heute genialste Streich unsere gro=C3=9Fen > Kosmologen: Die Geheim-Vorhersage. > - Karl Kaos =C3=BCber R=C3=BCdiger Thomas in dsa > -- > https://mail.python.org/mailman/listinfo/python-list > --=20 Joel Goldstick http://joelgoldstick.com --047d7b676fd053d2cb04ed1fb696 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Mon, Dec 9, 2013 at 6:49 AM, Johannes Bauer <dfns= onfsduifb@gmx.de> wrote:
Hi group,

it's somewhat OT here, but I have a puzzle to which I would like a
solution -- but I'm unsure how I should tackle the problem with Python.=
But it's a fun puzzle, so maybe it'll be appreciated here.

The question is: How do you design a boolean circuit that contains at
most 2 NOT gates, but may contain as many AND or OR gates that inverts
three inputs? IOW: Build three inverters by using only two inverters
(and an infinite amount of AND/OR).

Surprisingly, this is possible (and I even know the solution, but won't=
give it away just yet).

I found this puzzle again and was thinking about: How would I code a
brute-force approach to this problem in Python? And to my surprise, it
isn't as easy as I thought. So I'm looking for some advice from you= guys
(never huts to improve ones coding skills).

Best regards,
Johannes

I studied Electrical Engineering in college, so this puzzle grabbed my at= tention.=C2=A0 For a couple of hours I played around thinking about how to = attack this problem=C2=A0 My first thought was that if you had two inverter= s (NOT gates), you needed to create an inverter with and and or gates.=C2= =A0 That goes nowhere.=C2=A0 So, I googled around and found this: htt= p://www.thelowlyprogrammer.com/2008/05/not-puzzle-solution.html (spoile= r alert).=C2=A0 It discusses how you can solve the problem, but it doesn= 9;t give python code.=C2=A0 As it ends up I implemented that solution in 18= lines of code

So, my hint is that it can be solved by creating several sim= ultaneous equations

I'll send my code alo= ng if someone asks, but I don't want to post it here because I'm su= re others will want to figure it out on their own.

=C2=A0
--
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht =C3=B6ffentlich!
Ah, der neueste und bis heute genialste Streich unsere gro=C3=9Fen
Kosmologen: Die Geheim-Vorhersage.
=C2=A0- Karl Kaos =C3=BCber R=C3=BCdiger Thomas in dsa <hidbv3$om2$1@speranza.aioe.org>
--
https://mail.python.org/mailman/listinfo/python-list



--
--047d7b676fd053d2cb04ed1fb696--