couple more days of 2019

This commit is contained in:
Tristan 2019-12-05 17:08:18 +00:00
parent 12d0551bb4
commit d25c3b26d9
7 changed files with 150 additions and 1 deletions

18
2019/04/part1.js Normal file
View file

@ -0,0 +1,18 @@
// puzzle input
const inputMin = 172930;
const inputMax = 683082;
amt = 0;
for (let i = inputMin; i < inputMax; i++) {
adjChars = false;
increasing = false;
let prev;
for (char of String(i)) {
if (char == prev) {adjChars = true}
if (char < prev) {increasing = true}
prev = char;
}
if (adjChars && !increasing) {amt++;console.log(i)}
}
console.log(amt);

28
2019/04/part2.js Normal file
View file

@ -0,0 +1,28 @@
const inputMin = 172930;
const inputMax = 683082;
amt = 0;
for (let i = inputMin; i < inputMax; i++) {
adjChars = 1;
pair = false;
decreasing = false;
let prev;
for (char of String(i)) {
if (char == prev) {
adjChars++;
} else if (adjChars == 2) {
pair = true;
} else {adjChars = 1}
if (char < prev) {decreasing = true}
prev = char;
}
if (adjChars == 2) {
pair = true;
}
if (pair && !decreasing) {amt++;console.log(i)}
}
console.log(amt);