Maximum Number with Limited Digits X26324


Statement
 

pdf   zip   main.py

html

Write a function maxlim(m, k) that finds the largest number that can be written with at most k digits taken from m, and written in the same order as they appear in m. Both m and k are nonnegative integers.

Observation

The digits of all numbers are assumed to be as written in base 10.

Sample session
>>> maxlim(1234, 1)
4
>>> maxlim(3234, 2)
34
>>> maxlim(32749, 2)
79
>>> maxlim(1917, 2)
97
>>> maxlim(32749, 18)
32749
>>> maxlim(2668037, 5)
68037
Information
Author
Jordi Delgado / José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python