[ya-day1] update test cases 9 for problem B WIP
This commit is contained in:
@@ -63,5 +63,8 @@ describe("tiShortChoser", () => {
|
|||||||
it("____ 1000, 1, 1, 1000 ", () => {
|
it("____ 1000, 1, 1, 1000 ", () => {
|
||||||
expect(tiShortChoser(1000, 1, 1, 1000)).toEqual("1001 1");
|
expect(tiShortChoser(1000, 1, 1, 1000)).toEqual("1001 1");
|
||||||
});
|
});
|
||||||
|
it("1, 0, 1, 0 ", () => {
|
||||||
|
expect(tiShortChoser(1, 0, 1, 0)).toEqual("1 1");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,35 +10,41 @@ export function tiShortChoser(
|
|||||||
const isEquaal = tB + sB === tR + sR;
|
const isEquaal = tB + sB === tR + sR;
|
||||||
const tIsEquale = tB === tR && tB > 0;
|
const tIsEquale = tB === tR && tB > 0;
|
||||||
const sIsEquale = sB === sR && sB > 0;
|
const sIsEquale = sB === sR && sB > 0;
|
||||||
|
const isBlue = tB === sB && !tIsEquale && !sIsEquale;
|
||||||
|
const isRed = tR === sR && !tIsEquale && !sIsEquale;
|
||||||
|
|
||||||
if (blueIsGrater) {
|
if (blueIsGrater) {
|
||||||
tishort = tR + 1;
|
tishort = sIsEquale && !isEquaal ? 1 : tR + 1;
|
||||||
socks = sR + 1;
|
socks = tIsEquale || isEquaal ? 1 : sR + 1;
|
||||||
} else {
|
} else {
|
||||||
tishort = tB + 1;
|
tishort = sIsEquale && !isEquaal ? 1 : tB + 1;
|
||||||
socks = sB + 1;
|
socks = tIsEquale || isEquaal ? 1 : sB + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tIsEquale || isEquaal) {
|
|
||||||
tishort = tB + 1;
|
|
||||||
socks = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sIsEquale && !isEquaal) {
|
|
||||||
tishort = 1;
|
|
||||||
socks = sB + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tB === 0 || tR === 0) {
|
if (tB === 0 || tR === 0) {
|
||||||
tishort = 1;
|
tishort = 1;
|
||||||
socks = tB === 0 ? sB + 1 : sR + 1;
|
socks = tB === 0 ? sB + 1 : sR + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sB === 0 || sR === 0) {
|
if (sB === 0 || sR === 0) {
|
||||||
socks = 1;
|
socks = 1;
|
||||||
tishort = sB === 0 ? tB + 1 : tR + 1;
|
tishort = sB === 0 ? tB + 1 : tR + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isRed) {
|
||||||
|
tishort = tR + 1;
|
||||||
|
socks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBlue) {
|
||||||
|
tishort = tB + 1;
|
||||||
|
socks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isBlue && isRed && (tB !== 0 || sB !== 0)) {
|
||||||
|
tishort = 2;
|
||||||
|
socks = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return [tishort, socks].join(" ");
|
return [tishort, socks].join(" ");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user