β back to unit
Medium
# puzzle gauntlet medium
Count the Twins
Every two matching cards form a twin-pair β and a value appearing three times makes THREE different pairs (count the ways!). π΄
You get the cards. Print the total number of matching pairs. Feel free to check every pair β or tally first and do pair-math.
Example:
Input: cards = [3, 5, 3, 5, 3]
Output: 4
3 appears 3 times, making 3 Γ 2 Γ· 2 = 3 pairs; 5 appears 2 times, making 1 pair β 3 + 1 = 4 pairs total.
π‘ need a hint?
pg-count-the-twins.pyπ given lines are locked β write your code in between
loading...