Public
Edited
Dec 4, 2022
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fullyOverlaping = input.filter(
(pair) =>
(pair.first.start <= pair.second.start &&
pair.first.end >= pair.second.end) ||
(pair.second.start <= pair.first.start && pair.second.end >= pair.first.end)
)
Insert cell
anyOverlaping = input.filter(
(pair) =>
(pair.first.start <= pair.second.start &&
pair.first.end >= pair.second.start) ||
(pair.first.start <= pair.second.end &&
pair.first.end >= pair.second.end) ||
(pair.second.start <= pair.first.start &&
pair.second.end >= pair.first.start) ||
(pair.second.start <= pair.first.end && pair.second.end >= pair.first.end)
)
Insert cell
Insert cell
input = (await FileAttachment("04.txt").text())
.split("\n")
.filter((l) => l.trim().length > 0)
.map((l) => {
let pair = l.split(",");
let first = pair[0].split("-");
let second = pair[1].split("-");
return {
first: {
start: parseInt(first[0]),
end: parseInt(first[1])
},
second: {
start: parseInt(second[0]),
end: parseInt(second[1])
}
};
})
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