Commits

Go Yamada  committed 19266b6

add is_three_cards

  • Participants
  • Parent commits d8179eb

Comments (0)

Files changed (1)

 
 # 手札のセットはテストで判定するので、とりあえずは不要
 def set_cards():
-    cards = [13,13,1,10,9]
+    cards = [13,13,13,10,9]
     return cards
 
 
 # テスト: 札5枚のうち2枚が同じ札である場合はFalse、3枚が同じ札かつ残り2枚がペアでない場合はTrueを返す関数である事を確認
 # 変数: グルーピングされた札の枚数を表すvalue、グルーピングされてvalueが2のpair、グルーピングされてvalueが3のthree_cards
 # 
-#def is_three_cards(cards):
-
+def is_three_cards(cards):
+    card_dict = grouping_cards(cards)
+    pair = 0
+    three_cards = 0
+    for value in card_dict.values():
+        if value == 2: # count pair
+            pair += 1
+        elif value == 3: # count three_cards
+            three_cards += 1
+    if pair == 0: # is not pair
+        if three_cards == 1: # is three_cards
+            return True
+    return False
 
 
 def main():
     cards = set_cards()
-    count_result = is_one_pair(cards)
+    #count_result = is_one_pair(cards)
+    count_result = is_three_cards(cards)
     if count_result:
         print "Cards is one pair."
     else: