Skip to content

Commit

Permalink
Merge pull request #20 from dieseltravis/glitch
Browse files Browse the repository at this point in the history
Glitch fixed day 8
  • Loading branch information
dieseltravis authored Dec 11, 2023
2 parents 1eaa273 + 00eafb0 commit a378e2a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ my 2023 solutions on glitch: [branch-three-oviraptor](https://branch-three-ovira

also on github: [dieseltravis/aoc2023](https://github.com/dieseltravis/aoc2023)

[![Days completed in a row](https://img.shields.io/badge/⭐%20days%20in%20a%20row-7-blueviolet)](https://adventofcode.com/2023/) [![glitch](https://shields.io/badge/glitch-%F0%9F%91%8D%F0%9F%8E%8F-blue?logo=glitch&logoColor=violet)](https://glitch.com/)
[![Days completed in a row](https://img.shields.io/badge/⭐%20days%20in%20a%20row-10-blueviolet)](https://adventofcode.com/2023/) [![glitch](https://shields.io/badge/glitch-%F0%9F%91%8D%F0%9F%8E%8F-blue?logo=glitch&logoColor=violet)](https://glitch.com/)

[![Node.js CI](https://github.com/dieseltravis/aoc2023/actions/workflows/node.js.yml/badge.svg)](https://github.com/dieseltravis/aoc2023/actions/workflows/node.js.yml) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdieseltravis%2Faoc2023.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fdieseltravis%2Faoc2023?ref=badge_shield) [![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?logo=javascript)](https://github.com/standard/semistandard)

Expand Down Expand Up @@ -41,8 +41,8 @@ also on github: [dieseltravis/aoc2023](https://github.com/dieseltravis/aoc2023)

## previous years:

[Glitch playlist of all years](https://glitch.com/@travishardiman/advent-of-code)
[Github list of all projects](https://github.com/stars/dieseltravis/lists/advent-of-code)
[🎏 Glitch playlist of all years](https://glitch.com/@travishardiman/advent-of-code)
[:octocat: Github list of all projects](https://github.com/stars/dieseltravis/lists/advent-of-code)

### 2022

Expand Down
35 changes: 24 additions & 11 deletions public/funs.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,8 @@
return c;
},
part2: (data) => {
// const gcd = (a, b) => !b ? a : gcd(b, a % b);
// const lcm = (a, b) => (a * b) / gcd(a, b);
const gcd = (a, b) => !b ? a : gcd(b, a % b);
const lcm = (a, b) => (a * b) / gcd(a, b);
const input = data.trim().split('\n\n');
const directions = input[0].trim().split('');
const map = input[1].trim().split('\n').reduce((m, line) => {
Expand All @@ -654,23 +654,32 @@
const nlen = nodes.length;
const starts = nodes.slice();
console.log(nodes, directions, map, starts);
let safety = 10000000000;
let safety = 100000;
let i = 0;
let c = 0;
while (!nodes.every(zzz) && safety-- > 0) {
let c = 1;
const found = [];
const lowest = [];
while (lowest.length < nlen && safety-- > 0) {
i = i % dlen;
const d = directions[i];
for (let l = nlen; l--;) {
let node = nodes[l];
node = map[node][d];
nodes[l] = node;
if (!found.includes(l)) {
let node = nodes[l];
node = map[node][d];
nodes[l] = node;
if (zzz(node)) {
found.push(l);
lowest.push(c);
}
}
}
// console.log(c, i, d, node);
i++;
c++;
}
console.log(safety, c);
return c;
const multiple = lowest.reduce((acc, l) => lcm(acc, l), 1);
console.log(safety, c, lowest, multiple);
return multiple;
}
},
day9: {
Expand Down Expand Up @@ -916,7 +925,11 @@
}
},
day11: {
part1: d => d,
part1: (data) => {
const input = data.trim().split('\n');
console.log(input);
return 0;
},
part2: d => d
},
day12: {
Expand Down

0 comments on commit a378e2a

Please sign in to comment.