verwijder mijn topic
There are 10 digits 0-9.
If you have 6 of them, thatās 106.
What exactly do you mean by double digits? Do you mean 2 digits the same next to each other or just 2 (or more?) digits the same?
no I mean itās a 6 digit PIN. I completely forgot about him. it is a code combination from 1 to 9 but I think it started with 1, 3, 7 or 9. I just understood from a friend that you canāt just use the Python software that I need someone who has this skill! is this correct? Iām not that smartā¦ Iām almost ashamed, and I have no other option than to seek help here
The original question was:
How many 6-digit numbers containing only the digits 1-9, where no adjacent digits are equal, exist?
Here is a brute-force solution to generate all such numbers:
def six_digits_1_9(starts_with=None):
start = 111111
stop = 999999
starts_with = range(1, 10) if starts_with is None else starts_with
for d in range(start, stop + 1):
if "0" in str(d):
continue
if any(i == j for i, j in zip(str(d), str(d)[1:])):
continue
if int(str(d)[0]) not in starts_with:
continue
yield d
list(six_digits_1_9()) # 294912 possibilities
list(six_digits_1_9([1, 3, 7, 9])) # 131072 possibilities
A post was split to a new topic: Is Python used for mobile game dev?