fix : TAN without box is working , box is having issue

This commit is contained in:
karthik 2025-07-29 00:09:43 +05:30
parent 1be559a552
commit 5c36c781a6

View File

@ -98,7 +98,7 @@ export class SelectionService {
}
updated.numbers = [...group1, '-', ...group2];
updated.total = combinations * value * 10; // Value multiplier as per your code (10x)
updated.total = combinations * value * 10;
break;
}
@ -113,9 +113,23 @@ export class SelectionService {
const group2 = updated.numbers.slice(dashIndices[0] + 1, dashIndices[1]).filter(n => typeof n === 'number') as number[];
const group3 = updated.numbers.slice(dashIndices[1] + 1).filter(n => typeof n === 'number') as number[];
let combinations = group1.length * group2.length * group3.length;
let combinations = 0;
if (isBoxed) {
combinations = this.calculatePermutations(group1.length + group2.length + group3.length);
// Boxed: all unique numbers, nP3
const allNums = Array.from(new Set([...group1, ...group2, ...group3]));
combinations = allNums.length >= 3 ? this.calculatePermutationsN(allNums.length, 3) : 0;
} else {
// Unboxed: only combinations where all chosen numbers are different
for (const a of group1) {
for (const b of group2) {
if (b === a) continue;
for (const c of group3) {
if (c === a || c === b) continue;
combinations++;
}
}
}
}
updated.total = combinations * value * 10;
@ -171,6 +185,15 @@ export class SelectionService {
return n >= 2 ? n * (n - 1) : 0;
}
private calculatePermutationsN(n: number, r: number): number {
if (n < r) return 0;
let result = 1;
for (let i = 0; i < r; i++) {
result *= (n - i);
}
return result;
}
private splitToLegs(numbers: (number | string)[], legCount: number): number[][] {
const result: number[][] = [];
let currentLeg: number[] = [];