<pre>
<script>
const randomNetto = length => {
let n = length, ar = [n], sum = n, k = n;
for (let i = 2; i < length; i++) {
n *= --k;
n /= i;
sum += n;
ar.push(sum);
}
ar = ar.map(a => a / sum);
return random => {
let len = 0;
for (let k of ar) {
len++;
if (random < k) break;
}
return len
}
}
function splitSet(set) {
const random = a => Math.trunc(Math.random() * a),
sort = (a, b) => a - b;
let {length} = set = set.slice(0),
ar = [],
count = randomNetto(length),
n = count(Math.random());
for (let i = 0; i < n; i++) {
let k = random(length - i);
ar.push(...set.splice(k, 1))
}
ar.sort(sort);
return ar[0] == 1 ? [ar, set] : [set, ar];
}
let obj = {};
for (let i = 0; i < 63000; i++) {
let [s1, s2] = splitSet([1, 2, 3, 4, 5, 6, 7])
obj[[s1]] = (obj[[s1]] >> 0) + 1;
obj[[s2]] = (obj[[s2]] >> 0) + 1;
}
document.write(JSON.stringify(obj, "", " "))
obj = {};
for (let i = 0; i < 15500; i++) {
let [s1, s2] = splitSet([1, 2, 3, 4, 5])
obj[[s1]] = (obj[[s1]] >> 0) + 1;
obj[[s2]] = (obj[[s2]] >> 0) + 1;
}
document.write(JSON.stringify(obj, "", " "))
</script>
</pre>