Ctrl K

Even Codes From Digit Cards

Easy
You have a set of digit cards cards. Three different cards can be laid out to form a three-digit number; each card is used at most once per number, although several cards may show the same digit. The number cannot start with zero. How many **distinct even** three-digit numbers can you lay out?
Example 1
cards=[2, 5, 8] → 4

An even card must go last: 258, 528, 582 and 852, four numbers.

Example 2
cards=[0, 4, 4] → 2

Zero cannot lead, so only 404 and 440 are possible.

Example 3
cards=[3, 7, 9] → 0

There is no even digit, so no even number can be built.

Constraints
  • 3 ≤ len(cards) ≤ 10
  • 0 ≤ cards[i] ≤ 9
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThree Addends and a Later Total EasyEven Numbers From Digit Cards EasyEvenly Spaced Triples EasySmallest Number From Two Digit Sets EasyBalanced Cuts After One Replacement Hard
loading Python…
Input
cards=[2, 5, 8]
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.