odd question
Karl Pech
KarlPech at users.sf.net
Wed Jul 14 21:01:01 CEST 2004
Hi,
I'm currently working on the following exercise:
---
You have given the following function:
def f2(i, j, k):
return ((i | j) & k) | (i & j)
Find a useful utilization for this function.
---
Actually I couldn't figure out so far, what exactly is
a "useful utilization". Can anybody of you help me?
Thanks!
Regards
Karl
[P.S. I have even written a small program, which should
show me, what this formula does with numbers, but I couldn't
find anything "interesting" or regular in the output-file.
This is the source of the program:
---
import string
def testit(i, j, k):
return ((i | j) & k) | (i & j)
q = []
results = [[], [], [], [], [], [], [], [], [], []]
fout = open("out.txt", "w")
for x in range(10):
for y in range(10):
for z in range(10):
a = [x, y, z]
a.sort()
if a in q:
continue
else:
results[testit(x, y, z)].append([x, y, z])
q.append(a)
for x in range(len(results)):
for y in range(len(results[x])):
fout.write(string.strip(str(results[x][y]), "[]")+" : "+str(x)+'\n')
---
I guess I just have to construct some kind of situation there this
function could be useful but I don't have any ideas. :(
More information about the Python-list
mailing list