Ctrl K

Average of Even Multiples of Three

Easy
You are given a list of positive integers values. Pick the numbers that are both even and divisible by 3, and return their average rounded down to a whole number. If there are no such numbers, return 0.
Example 1
values=[5, 12, 9, 18, 4, 30] → 20

12, 18 and 30 qualify (9 is odd, 4 is not divisible by 3): (12 + 18 + 30) / 3 = 20.

Example 2
values=[6, 24, 3] → 15

6 and 24 qualify: (6 + 24) / 2 = 15.

Example 3
values=[3, 8, 15] → 0

No number is both even and divisible by 3, so the answer is 0.

Constraints
  • 1 ≤ length of values ≤ 1000
  • 1 ≤ values[i] ≤ 1000
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsAdd One to a Digit Array EasyThe Lost Ticket EasyCorner Stamps on a Table EasyBest Product of Three EasyThe Biggest Triangle on the Board Easy
loading Python…
Input
values=[5, 12, 9, 18, 4, 30]
Expected
20

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