programming logical functions: myand, myor and mynot

Gernot headroom02 at gmx.de
Sat Nov 17 13:21:06 EST 2001


"Paul Sidorsky" <paulsid at home.com> schrieb im Newsbeitrag
news:mailman.1005795261.24480.python-list at python.org...
> Gernot wrote:
>
[deleted]
> Assuming this is for a CS problem, I don't know what the instructor has in
> mind, of course, but I expect he/she would consider the above approach (if
it
> had worked) as missing the point.  It's more likely the instructor wants
(or
> would be more impressed by) a generic solution that would work in any
language,
> especially if this is for a "fundamentals of programming" course.

Yes, it is for CS, and this is a course called "Praktische Informatik 1"
(practical cs 1). It is no programming course in its sense, we have to learn
general concepts of programming, and to learn it, we use the languages
Python and Haskell.

>
> The way I would approach this problem (as I understand it) is to convert
each
> ASCII character of the strings to a number using ord() and then use
> mathematical and relational operators (+, -, <, >, ==, etc.), assuming
they're
> allowed.  (I would think they would have to be.)  The conversion is easy
with
> list comprehensions (Python 2.0 and up):
>
> xlist = [ord(i) for i in x]
> ylist = [ord(i) for i in y]
>
> This will give you two lists of numbers, the elements of which you can
then use
> the other operators on to mimic the logical operators.  Exactly how to do
that
> I won't say because I expect that's what the instructor really wants you
to
> figure out.
>
> I hope that's a push in the right direction.  But of course I don't know
> exactly what the goal and specific restrictions are here so I may be way
off
> base.

Thank you for your tip, it has interesting contents, but It is not really
defined what the input for  x and y can be, and it is necessary to find out
the expression is true or not. Therefore I am sure this would be really hard
to implement, if it is possible.

greets

Gernot







More information about the Python-list mailing list