[Question]
  [
# Introduction
This challenge consists in finding the greatest number removing *y* digits from the original number *n* which has *x* digits.
Assuming `y=2 n=5263 x=4`, the possible numbers removing *y=2* digits are:
```
[52, 56, 53, 26, 23, 63]
```
So, the greatest number is `63` which must be the output for this example.
---
Another logic would be: *for each y, search from left to right the digit which right next digit is greater, then remove it, else when no match, remove the last y-digits*.
Using `y=3 n=76751432 x=8` to explain:
```
y=3
76751432
-^------ remove 6 because right next 7 is greater
y=2
7751432
---^--- remove 1 because right next 4 is greater
y=1
775432
-----^ the search failed, then remove last y digits
result = 77543
```
Both methods explained above works.. of course, you can use another method too :)
# Challenge
The number *n* won't have more than 8 digits, and *y* will always be greater than zero and lower than *x*.
To avoid strict input format, you can use the values: `y n x` the way you prefer: as parameters in function, raw input, or any other valid way. Just don't forget to say how you did that in your answer.
The output should be the result number.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest answer in bytes wins.
# Example Input and Output
### Again: you do not need to be too strict :)
```
4 1789823 7 -> 983
1 54132 5   -> 5432
3 69314 5   -> 94
2 51794 5   -> 794
```
# Edit
I changed the input order to reflect the fact that some of you may not need the *x* value to solve the problem. *x* is now an optional value.
  
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 10 bytes
```
-jowXncUX>
```
This uses [version (9.2.1)](https://github.com/lmendo/MATL/releases/tag/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!**](http://matl.tryitonline.net/#code=LWp3WE5jVVg-&input=Nwo0CjE3ODk4MjM) (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)](https://github.com/lmendo/MATL/releases/tag/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
```
[Answer]
## [A-Ray](https://github.com/mannymang/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.
[Answer]
# Pyth - ~~11~~ ~~9~~ 8 bytes
```
eS.cz-QE
```
[Test Suite](http://pyth.herokuapp.com/?code=eS.cz-QE&test_suite=1&test_suite_input=5263%0A4%0A2%0A1789823%0A7%0A4%0A54132%0A5%0A1%0A69314%0A5%0A3&debug=0&input_size=3).
[Answer]
# Japt, 19 bytes
```
Vs ¬àW-U m¬mn n!- g
```
[Try it online!](http://ethproductions.github.io/japt?v=master&code=VnMgrOBXLVUgbaxtbiBuIS0gZw==&input=MiA1MjYzIDQ=)
### How it works
```
        // Implicit: U = y, V = n, W = x
Vs ¬    // Convert V into a string, then split into an array of chars.
àW-U    // Generate all combinations of length W-U.
m¬mn    // Join each pair back into a string, then convert each string to a number.
n!-     // Sort by backwards subtraction (b-a instead of a-b; highest move to the front).
g       // Get the first item in this list.
        // Implicit: output last expression
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 30 bytes
```
,{,[N:Y].hs?lL,Nl-Y=L}?:1forh.
```
Since OP has relaxed the constraints on IO, this expects `[Number, NumberOfDigitsRemoved]` as input and returns the answer as output, e.g. `brachylog_main([1789823,4], Z).`.
### Explanation
```
,{                   }?:1f     § Declare sub-predicate 1 and find all inputs which satisfy
                               § this sub-predicate with output = Input of the main predicate
                               § (i.e. [Number, Number of digits to remove])
                               § -- Sub-predicate 1 --
  ,[N:Y].                      § Output = [N, Y]
         hs?                   § Input = a subset of N
            lL,Nl-Y=L          § Length of Input = Length of N - Y
                          orh. § Order the list of answers, reverse it an return the first
                               § element (i.e. the biggest number of the list)
```
[Answer]
## Python 3, 69 bytes
This defines an anonymous function accepting all three arguments. Taking full advantage of the rule that "you can use the values: `y n x` the way you prefer", I have chosen to accept `y` and `x` as integers and `n` as a string. The return value is a string.
```
from itertools import*
lambda y,n,x:''.join(max(combinations(n,x-y)))
```
Just in case anyone feels that this is stretching the rules too far, this version takes all inputs as integers and is 74 bytes.
```
from itertools import*
lambda y,n,x:''.join(max(combinations(str(n),x-y)))
```
And just for kicks, I also wrote a two-argument version, taking `y` and `n` from the command line and printing the result to `STDOUT`. It's 92 bytes.
```
import sys,itertools as i
_,y,n=sys.argv
print(*max(i.combinations(n,len(n)-int(y))),sep='')
```
[Answer]
## ES6, 70 bytes
```
r=(y,n)=>y?r(y-1,Math.max(...`${n}`.replace(/./g," $`$'").split` `)):n
```
Returns a numeric result unless `y` is falsy and `n` is a string. I've convinced myself that doing the recursion the wrong way around still works (my solution isn't applicable to doing the correct recursion).
Also my first code golf where I use all three quote signs (although not all as quotes), which prevented me from trivially calculating the length.
[Answer]
# Julia, ~~128~~ 95 bytes
```
f(y,n,x)=maximum(i->parse(join(i)),filter(k->endof(k)==x-y,reduce(vcat,partitions(["$n"...]))))
```
This is a function that accepts the three values as parameters and returns an integer.
Ungolfed:
```
function f{T<:Integer}(y::T, n::T, x::T)
    # Get all ordered partitions of the digits of n
    p = reduce(vcat, partitions(["$n"...]))
    # Filter to groups of size x-y
    g = filter(k -> endof(k) == x - y, p)
    # Get the maximum resulting number
    return maximum(i -> parse(join(i)), g)
end
```
[Answer]
## Haskell, 64 bytes
```
import Data.List
y#x=maximum.filter((==x-y).length).subsequences
```
Usage example: `(4#7)"1789823"` -> `"983"`.
The original number `n` is takes as a string. (Not sure if I'm overstressing the "no strict input format" rule, but string input was required(!) in the first version).
How it works: make a list of all subsequences of `n`, keep those with length `x-y` and pick the maximum. 
[Answer]
# Ruby, 40 bytes
```
->y,n,x{n.chars.combination(x-y).max*''}
```
This is an anonymous function that takes `y` and `x` as integers and `n` as a string, and returns a string. You may call it for instance like this
```
->y,n,x{n.chars.combination(x-y).max*''}[2,"5263",4]
```
and it will return `"63"`.
[Answer]
# MATLAB 40 bytes
```
@(n,y)max(str2num(nchoosek(n,nnz(n)-y)))
```
Test:
```
ans('76751432',3)
ans = 77543
```
[Answer]
# Pyth, 45 bytes
```
=cz)Fk.P@z1-l@z1v@z0I:@z1j".*"k1I>vkZ=Zvk)))Z
```
[try it here](http://pyth.herokuapp.com/?code=%3Dcz%29Fk.P%40z1-l%40z1v%40z0I%3A%40z1j%22.%2a%22k1I%3EvkZ%3DZvk%29%29%29Z&input=3+69314+5%0A&debug=0)
[Answer]
# JavaScript (ES6), 78
A recursive function with 2 arguments y and d. `y` can be numeric or string, `d` must be a string. 
```
r=(y,d)=>y?Math.max(...[...d].map((x,i)=>r(y-1,d.slice(0,i)+d.slice(i+1)))):+d
```
Before the challenge changed it was 107 - ... with all input/output oddities ... 
```
x=>(r=(n,d)=>n?Math.max(...[...d].map((x,i)=> r(n-1,d.slice(0,i)+d.slice(i+1)))):+d)(...x.match(/\d+/g))+'\n'
```
**Test**
```
r=(y,d)=>y?Math.max(...[...d].map((x,i)=>r(y-1,d.slice(0,i)+d.slice(i+1)))):+d
function test() {
  [a,b]=I.value.match(/\d+/g)
  O.textContent=r(a,b)
}
test()
```
```
y,n: <input id=I value='4 1789823' oninput="test()">
<pre id=O></pre>
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), 6 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
àVnW)ñ
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWg&code=4FZuVynx&input=IjUyNjMiCjIKNA)
```
àVnW)ñ     :Implicit input of string U=n and integers V=y & W=x
à          :Combinations of U of length
 VnW       :  V subtracted from W
    )      :End combinations
     ñ     :Sort
           :Implicit output of last element
```
]