Skip to content
Snippets Groups Projects
Commit 41bd2884 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Recorded work from Wednesday.

parent bc1e7b11
No related branches found
No related tags found
No related merge requests found
......@@ -55,10 +55,10 @@ Problem: Given a sequence of fueling sites, the distances between consecutive si
## DAG
* Vertices (situations):
* Locations
* Edges (actions):
* Ways to advance to a location up to `range` units of distance away
* Vertices (situations):
* Locations
* Edge weights (optional):
* Distance to the next location
* Topological order:
......@@ -212,23 +212,23 @@ Problem: Given frequencies for a set of symbols, create a lossless binary encodi
## DAG
* Vertices (situations):
*
* Edges (actions):
*
* Edge weights (optional):
*
* Combine two parts (sets of symbols) and record bits for the combination that we did
* Vertices (situations):
* Partitions of the symbols
* Edge weights:
* Total frequency of the combined set
* Topological order:
*
* By decreasing number of parts
* Goal:
*
* Find the shortest path from having all sets separated to having all sets combined into one part
## Choosing a Forward Edge
* Direct solution:
*
*
*
* Choose the lowest-frequency part
* Choose the second-lowest-frequency part
* Follow the edge that combines those parts
## Example
......
......@@ -11,9 +11,9 @@ export function planFuelings(gaps, range) {
const destination = gaps.length;
while (results[results.length - 1] < destination) {
let best = undefined;
for (let distance = , candidate = ;
distance < && candidate < ;
distance += , candidate += ) {
for (let distance = 0, candidate = results[results.length - 1];
distance <= range && candidate <= destination;
distance += gaps[candidate], ++candidate) {
best = candidate;
}
results.push(best);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment