Finding 3-Digit Even Numbers
Real-world version: Three-Digit Even Numbers From the TilesThe statement here is our own: the same inputs, outputs and technique.
A tray holds tiles, each stamped with a single digit, given as tiles.
Form three-digit numbers by choosing three tiles and laying them out in some order. No tile may be used more often than the tray holds it, the number may not begin with a zero, and the number must be even.
Return every distinct number obtainable, in increasing order.
Examples
Example 1
- Input
- tiles = [1, 2, 4]
- Output
- [124, 142, 214, 412]
The three tiles must all be used. Of the six orders, only those ending on 2 or 4 are even, which gives four numbers.
Example 2
- Input
- tiles = [0, 0, 0]
- Output
- []
Every tile is a zero, so any three-tile number would begin with a zero.
Example 3
- Input
- tiles = [4, 4, 4]
- Output
- [444]
Three tiles all stamped 4, so the only number is 444, which is even and does not begin with a zero.
Constraints
- 3 <= tiles.length <= 100
- 0 <= tiles[i] <= 9
The signature
The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def find_even_numbers(tiles: list[int]) -> list[int]:public int[] findEvenNumbers(int[] tiles)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 15 test cases: 15 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's