Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function f(a1, a2, x) {
return (a1 <= x && x <= a2) <= (10 <= x && x <= 29) || (13 <= x && x <= 18);
}
Insert cell
answer = solve()
Insert cell
function solve() {
let lengths = [];
for (let a1 = 1; a1 < 100; a1++) {
for (let a2 = a1 + 1, isGood = true; a2 <= 100; a2++, isGood = true) {
for (let x = 1; x <= 100; x++) {
if (!f(a1, a2, x)) {
isGood = false;
break;
}
}
if (isGood) lengths.push(a2 - a1);
}
}
return Math.max(...lengths);
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more