Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Greedy Algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 310
Greedy Algorithms
Commits
bc1e7b11
Commit
bc1e7b11
authored
1 year ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Recorded work from Monday.
parent
9daf6fba
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
greedy-algorithms/notes.md
+8
-5
8 additions, 5 deletions
greedy-algorithms/notes.md
greedy-algorithms/src/features/fueling/solver.js
+11
-2
11 additions, 2 deletions
greedy-algorithms/src/features/fueling/solver.js
with
19 additions
and
7 deletions
greedy-algorithms/notes.md
+
8
−
5
View file @
bc1e7b11
...
...
@@ -122,8 +122,8 @@ Problem: [same as above]
## Choosing a Forward Edge
*
Exhaustive search:
*
Generate
…
*
Check that
…
*
Generate
all following locations out to a distance of
`range`
as long as we don't go past the final destination
*
Check that
the chosen destination maximizes distance travelled (always favors the candidate)
## Example
...
...
@@ -139,12 +139,15 @@ Problem: [same as above]
Location Next Location
-------- -------------
a …
…
a c
c d
d e
e h
h i
Path
----
a →
…
a →
c → d → e → h → i
--------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
greedy-algorithms/src/features/fueling/solver.js
+
11
−
2
View file @
bc1e7b11
...
...
@@ -7,7 +7,16 @@ export function planFuelings(gaps, range) {
gaps
.
every
((
gap
)
=>
gap
<=
range
),
`Tried to find a fueling plan crossing a gap longer than the range
${
range
}
.`
,
);
const
results
=
[];
// TODO: stub
const
results
=
[
0
];
const
destination
=
gaps
.
length
;
while
(
results
[
results
.
length
-
1
]
<
destination
)
{
let
best
=
undefined
;
for
(
let
distance
=
…
,
candidate
=
…
;
distance
<
…
&&
candidate
<
…
;
distance
+=
…
,
candidate
+=
…
)
{
best
=
candidate
;
}
results
.
push
(
best
);
}
return
results
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment