Pairing

ABC 378

Problem 38 of 50

Easy

What to do

Given a list of 4 ball colors (as integers), find the maximum number of pairs you can form. A pair is two balls of the same color. For example, [2,1,2,1] → 2 pairs (one pair of 1s, one pair of 2s).

Key Concepts

arrays or lists counting basic math loops

Examples

Input: colors = [2, 1, 2, 1]

Output: 2

Input: colors = [4, 4, 4, 1]

Output: 1

Tips for Beginners

  • Focus on understanding the logic, not memorizing syntax
  • Use print statements to debug your code
  • Don't worry about input parsing - the function handles that for you
  • If stuck, try writing out your solution on paper first

Python Editor

Loading Python...