[ya-day1] tshortChooser teste 1 - 19
parent
46779a7da5
commit
d6ece9360b
@ -1,17 +1,45 @@
|
||||
export function tiShortChoser(
|
||||
tBlue: number,
|
||||
tRed: number,
|
||||
sBlue: number,
|
||||
sRed: number,
|
||||
tB: number,
|
||||
tR: number,
|
||||
sB: number,
|
||||
sR: number,
|
||||
) {
|
||||
let tishort = tBlue > tRed ? tRed + 1 : tBlue + 1;
|
||||
let socks = sBlue > sRed ? sRed + 1 : sBlue + 1;
|
||||
let tishort = 0;
|
||||
let socks = 0;
|
||||
const blueIsGrater = tB + sB > tR + sR;
|
||||
const isEquaal = tB + sB === tR + sR;
|
||||
const tIsEquale = tB === tR && tB > 0;
|
||||
const sIsEquale = sB === sR && sB > 0;
|
||||
|
||||
if (tBlue === tRed) tishort = tRed + 1;
|
||||
if (sBlue === sRed) socks = sRed + 1;
|
||||
if (blueIsGrater) {
|
||||
tishort = tR + 1;
|
||||
socks = sR + 1;
|
||||
} else {
|
||||
tishort = tB + 1;
|
||||
socks = sB + 1;
|
||||
}
|
||||
|
||||
if (tIsEquale || isEquaal) {
|
||||
tishort = tB + 1;
|
||||
socks = 1;
|
||||
}
|
||||
|
||||
if (sIsEquale && !isEquaal) {
|
||||
tishort = 1;
|
||||
socks = sB + 1;
|
||||
}
|
||||
|
||||
if (tB === 0 || tR === 0) {
|
||||
tishort = 1;
|
||||
socks = tB === 0 ? sB + 1 : sR + 1;
|
||||
}
|
||||
|
||||
if (sB === 0 || sR === 0) {
|
||||
socks = 1;
|
||||
tishort = sB === 0 ? tB + 1 : tR + 1;
|
||||
}
|
||||
|
||||
if (tBlue === tRed && tBlue === 1) tishort = 2;
|
||||
if (sBlue === sRed && sBlue === 1) socks = 2;
|
||||
|
||||
return [tishort, socks].join(" ");
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue