Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91405

Re: Logic problem: need better logic for desired thruth table.

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.05; '#include': 0.07; '++i)': 0.09; '-------': 0.09; 'logic': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'output': 0.15; 'enough:': 0.16; 'main(void)': 0.16; 'rc;': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.16; 'subject:need': 0.18; 'input': 0.18; 'language': 0.19; 'lawrence': 0.22; 'subject:problem': 0.22; '2015': 0.23; "i've": 0.24; 'seems': 0.24; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'coding': 0.27; 'cat': 0.29; 'table': 0.32; 'language.': 0.32; 'problem': 0.33; 'int': 0.33; 'true.': 0.33; 'behind': 0.35; 'skip:( 30': 0.35; 'to:addr:python-list': 0.35; 'false': 0.35; 'follows:': 0.35; 'there': 0.36; 'two': 0.37; 'subject:: ': 0.37; 'desired': 0.37; 'received:org': 0.38; 'test': 0.39; 'to:addr:python.org': 0.39; 'mark': 0.40; 'hello,': 0.40; 'success': 0.61; 'simple': 0.61; 'our': 0.64; 'charset:windows-1252': 0.65; 'thursday': 0.66; 'pythonistas,': 0.84; 'seen.': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Logic problem: need better logic for desired thruth table.
Date Thu, 28 May 2015 23:56:11 +0100
References <3794b$55678d83$5419aafe$56138@news.ziggo.nl> <YOM9x.125121$AJ4.46857@fx02.iad>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-78-146-3-69.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To <YOM9x.125121$AJ4.46857@fx02.iad>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.148.1432853790.5151.python-list@python.org> (permalink)
Lines 84
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1432853790 news.xs4all.nl 2858 [2001:888:2000:d::a6]:60929
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:91405

Show key headers only | View raw


On 28/05/2015 23:39, Lew Pitcher wrote:
> On Thursday May 28 2015 17:50, in comp.lang.c, "Skybuck Flying"
> <skybuck2000@hotmail.com> wrote:
>
>> Hello,
>>
>> I was just coding and ran into a little logic problem which is as follows:
>>
>> There are two booleans/variables which can be either false or true.
>>
>> The desired thrutle table is:
>>
>> A = input
>> B = input
>> C = output
>>
>> A B C:
>> -------
>> F F T
>> F T F
>> T F T
>> T T T
>
> Seems simple enough: C == A || !B
>
> 18:38 $ cat testlogic.c
> #include <stdio.h>
> #include <stdlib.h>
>
> /*
> ** A = input
> ** B = input
> ** C = output
> **
> ** A B C:
> ** -------
> ** F F T
> ** F T F
> ** T F T
> ** T T T
> */
>
> int testlogic(int a, int b)
> {
>    return (a || !b);
> }
>
> int main(void)
> {
>                        /* A B C */
>    int ttable[4][3] = {  {0,0,1},        /* F F T */
>                          {0,1,0},        /* F T F */
>                          {1,0,1},        /* T F T */
>                          {1,1,1}         /* T T T */
>                       };
>    int rc = EXIT_SUCCESS;
>    int i, max;
>
>    for (i = 0, max = sizeof(ttable) / sizeof(ttable[0]); i < max ; ++i)
>      if (testlogic(ttable[i][0],ttable[i][1]) != ttable[i][2])
>      {
>        printf("testlogic failed on test %d\n",i);
>        rc = EXIT_FAILURE;
>      }
>
>    if (rc == EXIT_SUCCESS) puts("SUCCESS");
>
>    return rc;
> }
> 18:39 $ cc -o testlogic testlogic.c
> 18:39 $ ./testlogic
> SUCCESS
>
>

Strangest looking Python I've ever seen.  Or is it a case of "Get thee 
behind me, Satan" :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Logic problem: need better logic for desired thruth table. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-28 23:50 +0200
  Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-28 23:55 +0200
    Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 00:07 +0200
      Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 00:08 +0200
        Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 00:12 +0200
          Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 04:45 +0200
            Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 04:56 +0200
        Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:13 +0000
          Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:15 +0000
  Re: Logic problem: need better logic for desired thruth table. sohcahtoa82@gmail.com - 2015-05-28 14:58 -0700
    Re: Logic problem: need better logic for desired thruth table. Michael Torrie <torriem@gmail.com> - 2015-05-28 16:16 -0600
      Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:54 +0000
        Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 23:03 +0000
          Re: Logic problem: need better logic for desired thruth table. Michael Torrie <torriem@gmail.com> - 2015-05-28 18:52 -0600
      Re: Logic problem: need better logic for desired thruth table. sohcahtoa82@gmail.com - 2015-05-28 17:15 -0700
    Re: Logic problem: need better logic for desired thruth table. Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-28 23:25 +0000
      Re: Logic problem: need better logic for desired thruth table. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 04:46 +0200
  Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:01 +0000
    Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:11 +0000
  Re: Logic problem: need better logic for desired thruth table. Tim Chase <python.list@tim.thechases.com> - 2015-05-28 17:02 -0500
  Re: Logic problem: need better logic for desired thruth table. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-05-29 01:13 +0300
  Re: Logic problem: need better logic for desired thruth table. Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-05-28 18:39 -0400
    Re: Logic problem: need better logic for desired thruth table. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-28 23:56 +0100
  Re: Logic problem: need better logic for desired thruth table. Paul <nospam@needed.com> - 2015-05-28 19:21 -0400
  Re: Logic problem: need better logic for desired thruth table. M Philbrook <jamie_ka1lpa@charter.net> - 2015-05-29 19:07 -0400

csiph-web