Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Greedy search solution in Clear category for Greedy Number by juestr
from operator import itemgetter
def greedy_number(line: str, length: int) -> str:
def select_digits():
linelenp1 = len(line) + 1
second = itemgetter(1)
position = 0
for todo in range(length, 0, -1):
alternatives = enumerate(line[position:linelenp1 - todo], start=position + 1)
position, digit = max(alternatives, key=second)
yield digit
return ''.join(select_digits())
Nov. 25, 2021
Comments: