Oct-10-2019, 05:44 AM
The 'check' function should return True or False regarding win.
Some ideas that might be useful: use set() or all() to determine whether there is 'all-spam' situation:
Some ideas that might be useful: use set() or all() to determine whether there is 'all-spam' situation:
>>> m = ['spam spam spam'.split(), 'spam ham spam'.split()] >>> m [['spam', 'spam', 'spam'], ['spam', 'ham', 'spam']] >>> for row in m: ... print(set(row) == {'spam'}) ... True False >>> for row in m: ... print(all(mark == 'spam' for mark in row)) ... True FalseTo make it more useful any() could be added - to determine is there at least one row with 'all-spam':
>>> any(set(row) == {'spam'} for row in m) True >>> any(all(mark == 'spam' for mark in row) for row in m) True
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.