Description:
In this challenge, you are asked to create an alias that will
'redistribute' the given 'liquids' so that each 'container' is filled to its maximum capacity.
Simple example
$redist(4,a2,a2,a2) = a4 a2
Let's take a look at the above example. You have been given an unlimited amount of new, unfilled containers, each can hold 4 units ($1). You have been given 3 containers, each holding 2 units of liquid 'a' ($2-) so a
total of 6 units of liquid 'a'. If I was to redistribute the liquids so that as many containers were filled to their maximum capacity as possible (4) -- I would get a4 a2.
Specifications
Input:
- $1 will always be a whole number >= 1 (representing the maximum capacity of a container)
- $2 will always be a letter from a-z (lowercase) followed by a whole number >= 1 (representing a container, a liquid within it and how many units of that liquid are in it)
- Amount of liquid in the single container $2- MAY be more than $1
- There can be infintely more parameters following the same format as $2 representing other containers
- In $2-, there may be multiple types of liquids, it must support something like $redist(3,a4,b3,b2,a2) (which is a3 a3 b3 b2)
Output:
- Must return all the liquids in containers that are filled to $1 and if is any liquid left over, a separate container for that too eg. $redist(4,a2,a2,a2) -> a4 a2 NOT a4
- Each container should be space delimited, with the type of liquid first, followed by the amount of units that container may hold
- The containers may be returned in any order, e.g. $redist(4,a3,a3) -> 'a4 a2' OR 'a2 a4' (all examples above may have other combinations that I didn't specify)
- Update: your alias can return either upper case or lower case output
Example:
$redist(4,a2,a2,a2) = a4 a2
$redist(4,x3,x3,x3) = x4 x4 x1
$redist(4,a1,a1) = a2
$redist(8,k3,k6,k4,k9) = k8 k8 k6
$redist(111,m145,z54,m195,m12,z64) = m111 m111 m111 m19 z111 z7
$redist(2,b50) = b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2 b2
$redist(4,a4,a3,a7,b2,b8,d5,d9,e2,e3,e1,a2,c4,c3) = a4 a4 a4 a4 b4 b4 b2 c4 c3 d4 d4 d4 d2 e4 e2
$redist(18315031,a13853102,a1375135,a15385325,b10857135,b1249531,b14752495) = a18315031 a12298531 b18315031 b8544130
Since the output can be in any order, the above examples are just returned in alphabetical order.
Your alias does not have to match the output as long as all the tokens are returned.
Rules:
- Tested in a clean, offline mIRC 6.35
- Will be loaded in ALIASES section (i.e "redist {" -- NOT "alias redist {"
- MUST HAVE closing bracket -- if not supplied it WILL be added on
- No COMs, DLLs, or sockets
- Alias must give correct results after consecutive runs
- As stated before, the alias must work in THEORY with any numbers/amount of parameters.
Obviously mIRC's calculation and line-length limits prevent it from practically working with any number but if these limits didn't exist, the alias would be able to support things like $redist(2,a108235171208457213850135)