Back
Close

A lazy banker

Statement

 Goal

"Congratulations for the hiring in the Central Bank of Frespalie, a little but charming country of the European Union. Your main job will be to serve all our clients asking for cash. But don't forget, client goes first ! So, if possible, serve them all the notes and coins they asked for, and start with the biggest note or coin available. No need to remind you that in Euro Zone, we use 1€ and 2€ coins, and 5€, 10€, 20€, 50€, 100€, 200€ and 500€ notes. Be ready, we'll open in 15 minutes."

As a hobbyist programmer, and a lazy person, you don't want to make all the calculations by hand for each client. 15 minutes is all you need to program a little tool that will make your life much easier.
Input
Line 1 : A line noteTypes for all the banknotes or coins that the client wants to be paid in. Values are separated by space and are in increasing order.
Line 2 : An integer N for the amount wanted by the client.
Output
Line 1 : A line with the total of all the note types in the form {0}x{1} where {0} is the total of the current type and {1} is the current type. Note types must be ordered in decreasing order.
Constraints
1 ≤ types of banknotes or coins≤ 26
0 < N < 100000

The note types are guaranteed to contain 1, in order to give money to all clients, whatever the amount wanted. Also, they are guaranteed to be in increasing order.
Example
Input
1 2 5 10 20 50 100 200 500
285
Output
1x200 1x50 1x20 1x10 1x5

Game modes
Fastest, Shortest, Reverse

Test cases
Nice client Test
Input
1 2 5 10 20 50 100 200 500 285
Output
1x200 1x50 1x20 1x10 1x5

Nice client - Validator Validator
Input
1 2 5 10 20 50 100 200 500 222
Output
1x200 1x20 1x2

Rich client Test
Input
1 2 5 10 20 50 100 200 500 78420
Output
156x500 2x200 1x20

Rich client - Validator Validator
Input
1 2 5 10 20 50 100 200 500 20420
Output
40x500 2x200 1x20

Client who doesn't like big notes Test
Input
1 2 5 10 20 346
Output
17x20 1x5 1x1

Client who doesn't like big notes - Validator Validator
Input
1 2 5 10 20 58
Output
2x20 1x10 1x5 1x2 1x1

Client who loves multiples of 5 Test
Input
1 5 50 500 7942
Output
15x500 8x50 8x5 2x1

Client who loves multiples of 5 - Validator Validator
Input
1 5 50 500 2497
Output
4x500 9x50 9x5 2x1

Client with big pockets Test
Input
1 2 217
Output
108x2 1x1

Client with big pockets - Validator Validator
Input
1 2 127
Output
63x2 1x1

Solution language

Solution

Stub generator input