id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

set_card_game


In the card game SET, you try to find three cards that make a set. Each card has four attributes: number of objects (1, 2, or 3), color (Red, Green, or Purple, which we abbreviate R,G,P); solidity (outline, filled, or striped, abbreviated O,F,S); and shape (oval, diamond or squiggle, abbreviated O,D,S). Three cards form a set if each of the four attributes are either all the same or all different, and is not a set if any attribute has two cards that are the same and one that is different. For example, the three cards "3RFD", "2RFD", "1RFD" (which corresponds to 3, 2, and 1 red filled diamonds) is a set because they are all different numbers, and all the same on the other three attributes. But ['3RFD', '2GFO', '1PFO'] is not a set, because of the fourth attribute: there is one diamond (D) and two ovals (O). Write the function is_set(cards) which takes a list of three cards and returns True if the cards are a set.


set_card_game(['3RFD', '2RFD', '1RFD']) → True
set_card_game(['3RFD', '2GFD', '1PFD']) → True
set_card_game(['3RFD', '2GFO', '1PFO']) → False

...Save, Compile, Run (ctrl-enter)

def set_card_game(cards):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 300 Post-solution available

Copyright Nick Parlante 2017 - privacy