It's not as good as I wanted it to be, am pretty sure it was possible to solve in a nicer way with regex. But had to do it quickly between meetings so 🤷♀️ Am satisfied though
matches = 0 for number in range(min, max + 1): is_increasing = True has_double = False previous = [] for character in str(number): if len(previous) > 0: if character < previous[-1]: is_increasing = False break if previous.count(character) > 0: has_double = True previous.append(character) if is_increasing and has_double and 2 in Counter(previous).values(): matches += 1 print(matches)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's not as good as I wanted it to be, am pretty sure it was possible to solve in a nicer way with regex. But had to do it quickly between meetings so 🤷♀️ Am satisfied though