Skip to content

Instantly share code, notes, and snippets.

@TristanWiley
Created December 1, 2021 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TristanWiley/b27ccdf71ec1044c1ba636a18aedacee to your computer and use it in GitHub Desktop.
Save TristanWiley/b27ccdf71ec1044c1ba636a18aedacee to your computer and use it in GitHub Desktop.
var input = document.getElementsByTagName("pre")[0].innerText.split("\n").filter(e => e !== "");
var previous = 100000000;
var increased = 0;
input.forEach(line => {
var val = parseInt(line);
if (val > previous) {
increased++;
}
previous = val;
});
console.log(increased);
var input = document.getElementsByTagName("pre")[0].innerText.split("\n").filter(e => e !== "").map(Number);
var newInput = []
for (var i = 2; i < input.length; i++){
newInput.push(input[i]+input[i-1]+input[i-2]);
}
var increased = 0;
var previous = 1000000000000000;
newInput.forEach(val => {
if (val > previous) {
increased++;
}
previous = val;
});
console.log(increased)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment