Find the numbers and calculate output Objective

Given an input list of 6 distinct digits, find 3 numbers a, b and c such that a × b = c, with a having 2 digits, b having 1 digit and c having 3 digits. In a more visual way, your program must arrange those 6 digits in the boxes of this image:



If more than one solution exists, you may output any of them.

Input

6 distinct digits. You may take them in any reasonable way for your language.

Output

The 3 numbers a, b and c. The output format is relatively free, as long as the 3 numbers are separated and are always printed in the same order (but not necessarily in the order a, b, c).

Test Cases

1, 2, 3, 4, 5, 6 -&gt; 54,3,162  
2, 3, 4, 5, 6, 7 -&gt; 57,6,342 or 52,7,364


Scoring

The shortest code in bytes wins.
JavaScript (ES6), 90 88 bytes

Takes input as an array of 6 digits. Returns a string describing a possible solution (such as '54*3==162') or exits with a 'too much recursion' error if (and only if) there's no solution.

f=(a,k=1)=&gt;eval(s='01*2==345'.replace(/\d/g,n=&gt;a[n],a.sort(_=&gt;(k=k*2%3779)&amp;2)))?s:f(a,k)


How it works

This is a deterministic algorithm.

The primes P=2 and Q=3779 were chosen in such a way that the sort callback (k = k * P % Q) &amp; 2 is guaranteed to generate all 720 possible permutations of the input array over time. More precisely, all permutations are covered after 2798 sorts -- which should be within the recursion limit of all browsers.

We inject each permutation in the expression 01*2==345 by mapping the digits to the corresponding entries in the array.

We evaluate this expression and do recursive calls until it's true.

Test



f=(a,k=1)=&gt;eval(s='01*2==345'.replace(/\d/g,n=&gt;a[n],a.sort(_=&gt;(k=k*2%3779)&amp;2)))?s:f(a,k)

console.log(f([1,2,3,4,5,6])); // 54*3==162
console.log(f([2,3,4,5,6,7])); // 52*7==364
console.log(f([1,2,3,4,6,7])); // 73*2==146