本帖最后由 匿名 于 2021-10-28 19:49 编辑
SET is a card game where each card has 3 attributes (0,1,2), each of which can take on 3 different values(0,1,2).
A "valid SET" is 3 cards such that each attribute is either (a) all the same or (b) all different.
ex.
card1 = {0,1,2,0}
card2 = {0,0,1,1}
card3 = {0,2,0,2}
is a valid set.
Write a function is_set(cards) to determine if a collection of 3 cards is a valid SET.
follow up 1 : card now has N attribute instead of 4 attributes, how will you write "valid set" function?
follow up 2 : card has 4 attributes. You have N cards right now, find the valid set.