From e2673edbfac6714ebf44bbbc396a19ec3803eb6d Mon Sep 17 00:00:00 2001 From: karthik Date: Wed, 6 Aug 2025 14:20:56 +0530 Subject: [PATCH] fix : every logic for (TAN,QUI & FOR ) are working. --- .../selection.service/selection.service.ts | 58 ++++++++++++++----- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/btc-UI/src/app/components/selection.service/selection.service.ts b/btc-UI/src/app/components/selection.service/selection.service.ts index 16945ce..c945b8f 100644 --- a/btc-UI/src/app/components/selection.service/selection.service.ts +++ b/btc-UI/src/app/components/selection.service/selection.service.ts @@ -87,11 +87,18 @@ export class SelectionService { } } } else { - const group1Count = group1.includes('F') ? this.runnerCount : group1.filter(n => typeof n === 'number').length; - const group2Count = group2.includes('F') ? this.runnerCount : group2.filter(n => typeof n === 'number').length; - combinations = isBoxed - ? this.calculatePermutations(group1Count + group2Count) - : group1Count * group2Count; + const group1Numbers = group1.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group1.filter(n => typeof n === 'number') as number[]; + const group2Numbers = group2.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group2.filter(n => typeof n === 'number') as number[]; + if (isBoxed) { + const allNumbers = [...new Set([...group1Numbers, ...group2Numbers])]; + combinations = this.calculatePermutations(allNumbers.length); + } else { + for (const a of group1Numbers) { + for (const b of group2Numbers) { + if (a !== b) combinations++; + } + } + } } updated.numbers = [...group1, '-', ...group2]; @@ -119,11 +126,22 @@ export class SelectionService { } combinations = pairSet.size; } else { - const group1Count = group1.includes('F') ? this.runnerCount : group1.filter(n => typeof n === 'number').length; - const group2Count = group2.includes('F') ? this.runnerCount : group2.filter(n => typeof n === 'number').length; - combinations = isBoxed - ? this.calculateCombinations(group1Count + group2Count) - : group1Count * group2Count; + const group1Numbers = group1.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group1.filter(n => typeof n === 'number') as number[]; + const group2Numbers = group2.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group2.filter(n => typeof n === 'number') as number[]; + if (isBoxed) { + const allNumbers = [...new Set([...group1Numbers, ...group2Numbers])]; + combinations = this.calculateCombinations(allNumbers.length); + } else { + const pairSet = new Set(); + for (const a of group1Numbers) { + for (const b of group2Numbers) { + if (a === b) continue; + const key = a < b ? `${a},${b}` : `${b},${a}`; + pairSet.add(key); + } + } + combinations = pairSet.size; + } } updated.numbers = [...group1, '-', ...group2]; @@ -156,9 +174,23 @@ export class SelectionService { } } } else { - combinations = isBoxed - ? this.calculatePermutationsN(numbers.includes('F') ? this.runnerCount : numbers.filter(n => typeof n === 'number').length, 3) - : this.runnerCount * this.runnerCount * this.runnerCount; + const group1Numbers = group1.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group1.filter(n => typeof n === 'number') as number[]; + const group2Numbers = group2.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group2.filter(n => typeof n === 'number') as number[]; + const group3Numbers = group3.includes('F') ? Array.from({ length: this.runnerCount }, (_, i) => i + 1) : group3.filter(n => typeof n === 'number') as number[]; + if (isBoxed) { + const allNumbers = [...new Set([...group1Numbers, ...group2Numbers, ...group3Numbers])]; + combinations = this.calculatePermutationsN(allNumbers.length, 3); + } else { + for (const i of group1Numbers) { + for (const j of group2Numbers) { + if (i === j) continue; + for (const k of group3Numbers) { + if (i === k || j === k) continue; + combinations++; + } + } + } + } } updated.numbers = [...group1, '-', ...group2, '-', ...group3];