gpt-3.5-turbo-0125· openai
Suzhen/CodeChat
Using python itertools create all possible str with 10 digits then count how much of…
- User
Using python itertools create all possible str with 10 digits then count how much of them contain at least 3 same digit
- Assistant
from itertools import product # Create all possible string with 10 digits all_str = [''.join(p) for p in product('0123456789', repeat=10)] # Count how many strings contain at least 3 same digit count = sum(1 for s in all_str if any(s.count(d) >= 3 for d in set(s))) print(count)This code will generate all possible strings of 10 digits and then count how many of these strings contain at least 3 of the same digit.