Public
Edited
Dec 15, 2022
Insert cell
Insert cell
Insert cell
startOfPacketIndex = indexUniqueSequence(puzzleInput, 4)
Insert cell
startOfMessageIndex = indexUniqueSequence(puzzleInput, 14)
Insert cell
function indexUniqueSequence(text, size) {
return text
.split("")
.map((c, endIndex, list) => list.slice(endIndex - size, endIndex))
.map((list) => list.length === size && list.length === _.uniq(list).length)
.findIndex(_.identity);
}
Insert cell
sampleInput = "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw"
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