Remove digits, retaining greater number

MATL, 10 bytes

-jowXncUX>

This uses version (9.2.1) of the language/compiler, which is earlier than this challenge.

It takes three inputs from stdin in this order: string length, number of removed characters, string.

Example

>> matl
 > -jowXncUX>
 > 
> 7
> 4
> 1789823
983

EDIT: Try it online! (the code in the link has XN instead of Xn to conform to changes in the language after this challenge; also, o is not needed anymore)

Explanation

(This still costs 2 bytes more than it should due to Octave's and Matlab's nchoosek function behaving differently. Fixed in the next release of the compiler.)

-        % implicitly input two numbers, and subtract them
jo       % input string, and convert to ASCII codes
wXn      % swap inputs. Generate all combinations, each in a row
c        % convert to char array
U        % convert each row to a number
X>       % get maximum. Implicitly display

Answer to original challenge (stricter input requirements): 16 bytes

jYbZ)b-wowXncUX>

Uses current version (9.2.1) of the language/compiler.

Example

>> matl jYbZ)b-wowXncUX>
> 4 1789823 7
983

Explanation

(This should have been 4 bytes less, but I need that wow...c because Octave's nchoosek function, unlike Matlab's, doesn't work with character input. Will be fixed for next release of the compiler.)

j              % input string
YbZ)           % split at spaces into strings
b-             % subtract first and third (1-digit) strings
wow            % convert middle string into ASCII codes
Xn             % get all combinations, each in a row
c              % convert to char array
U              % convert each row to a number
X>             % get maximum. Implicitly display

Pyth - 11 9 8 bytes

eS.cz-QE

Test Suite.


A-Ray, 9 7 bytes

My new language! According to meta, this is allowed, but if this is not accepted, then I will remove it.

pM:i-II

Explanation:

  :i-II       Gets all permutations possible for the given number converted to an array,
                      with the length of y-x, which is the -II part
 M            Gets the maximum of the result above
p             Prints the resulting array above, with no separators

Example input (number, x, y):

1736413 7 4

Output:

764

You can test this with the .jar file given in the github link.