Back
Close

Create new strings by deleting letters

Statement
You are given a string of unique lowercase letters [[s]] and a number [[n]]. Your task is to create new strings by removing letters of the original string [[s]]. You can remove none, any or all of the letters. The order of those letters is preserved. Now create all strings following the rules above. Then sort the resulting list first by length, then alphabetically. Then output the [[n]]-th string of the list (starting from 1). <<Example:>> [[s]] is "cab", [[n]] is 6 Possible strings are: "", "a", "b", "c", "ab", "ca", "cb", "cab" Your output should be {{"ca"}}

Input description
<<First line:>> a string [[s]] consisting of lowercase letters <<Second line:>> a number [[n]]

Output description
The [[n]]-th string, surrounded by double quotes ({{"..."}})

Constraints
The string [[s]] has at most 7 different lowercase letters. 1 ≤ [[n]] ≤ 2^length([[s]])

Game modes
Shortest

Test cases
Test 1 Test
Input
cab 6
Output
"ca"

Validator 1 Validator
Input
faq 2
Output
"a"

Test 2 Test
Input
abc 1
Output
""

Validator 2 Validator
Input
learn 1
Output
""

Test 3 Test
Input
zerg 10
Output
"zg"

Validator 3 Validator
Input
winter 42
Output
"wtr"

Test 4 Test
Input
clash 32
Output
"clash"

Validator 4 Validator
Input
codin 32
Output
"codin"

Test 5 Test
Input
packers 77
Output
"ckes"

Validator 5 Validator
Input
qwertzy 99
Output
"wtzy"

Solution language

Solution

Stub generator input