Published
Edited
Dec 10, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function part1 (s) {
let stack = [];
for (const char of s) {
if (stack.length && char === toggleCase[stack.slice(-1)]) {
stack.pop();
} else {
stack.push(char);
}
}
return stack;
}
Insert cell
reducedPolymer = part1(input)
Insert cell
reducedPolymer.length
Insert cell
Insert cell
function part2 (s) {
let lengths = [];
for (const char of alphabet) {
const sWithoutChar = s.filter(c => c.toLowerCase() !== char);
lengths.push(part1(sWithoutChar).length);
}
return Math.min(...lengths);
}
Insert cell
part2(reducedPolymer)
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more