Making three-digit numbers
Write code · Medium · §7.1 Trying them all
cards holds the digits written on number cards. You pick three of the cards, each card at most once, and put them in a row to make a three-digit number. The first digit cannot be 0.
Complete the function solution, which returns how many different three-digit numbers you can make. Several cards may have the same digit.
Function
solution(cards)
Constraints
- The length of
cardsis from 3 to 10. - The digit on each card is an integer from 0 to 9.
Examples
| cards | result |
|---|---|
[1, 2, 3] | 6 |
[0, 1, 1] | 2 |
Starter code
def solution(cards):
answer = 0
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.