couple more days of 2019
This commit is contained in:
parent
12d0551bb4
commit
d25c3b26d9
7 changed files with 150 additions and 1 deletions
18
2019/04/part1.js
Normal file
18
2019/04/part1.js
Normal 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
28
2019/04/part2.js
Normal 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);
|
Loading…
Add table
Add a link
Reference in a new issue