16
Today in my statistics class, I found that some factorials can be simplified when multiplied together! For example: 5! * 3! = 5! *3*2 = 5! *6 = 6!
Your job:
Given a string containing only Arabic numbers and exclamation points, simplify my factorial to its shortest possible string, in the least amount of bytes for your language, code golf style.
Input
A string containing only Arabic numbers and exclamation points. The factorials for the input won't be bigger than 200!. Factorials will not have more than one factorial per number. Input may be taken as a list of integers.
Output
A possibly shortened string, that has the equivalent value on the input. Order is unimportant. Factorial notation is a must, but you aren't required to use more than one factorial symbol per number.
Test cases
In: 3!2!2!
Out: 4!
In 2!3!2!0!
Out: 4!
In: 7!2!2!7!2!2!2!2!
Out: 8!8!
In: 23!3!2!2!
Out: 24!
Also: 4!!
In: 23!3!2!2!2!
Out: 24!2!
In: 127!2!2!2!2!2!2!2!
Out: 128!
In: 32!56!29!128!
Out: 29!32!56!128!
Best of luck
Since the empty product is 1 is the output for, say
1!1!
just an empty string? – Jonathan Allan – 2018-01-18T20:24:22.193@JonathanAllan 1!1! Reduces to 1! Or 0! – tuskiomi – 2018-01-18T20:26:27.277
Which then reduces to the empty string :/ – Jonathan Allan – 2018-01-18T20:26:56.177
@JonathanAllan I'm going to say 1 is not equal to as empty string – tuskiomi – 2018-01-18T20:29:09.640