summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--exercises/058_quiz7.zig9
-rw-r--r--patches/patches/058_quiz7.patch23
2 files changed, 23 insertions, 9 deletions
diff --git a/exercises/058_quiz7.zig b/exercises/058_quiz7.zig
index 59b48ba..7162078 100644
--- a/exercises/058_quiz7.zig
+++ b/exercises/058_quiz7.zig
@@ -176,11 +176,8 @@ const TripItem = union(enum) {
path: *const Path,
// This is a little helper function to print the two different
- // types of item correctly. Note how this "print()" is namespaced
- // to the TripItem union and doesn't interfere with calling the
- // "print()" from the standard library we imported at the top of
- // this program.
- fn print(self: TripItem) void {
+ // types of item correctly.
+ fn printMe(self: TripItem) void {
switch (self) {
// Oops! The hermit forgot how to capture the union values
// in a switch statement. Please capture both values as
@@ -427,7 +424,7 @@ fn printTrip(trip: []?TripItem) void {
while (i > 0) {
i -= 1;
if (trip[i] == null) continue;
- trip[i].?.print();
+ trip[i].?.printMe();
}
print("\n", .{});
diff --git a/patches/patches/058_quiz7.patch b/patches/patches/058_quiz7.patch
index 6b79676..a4e3bbb 100644
--- a/patches/patches/058_quiz7.patch
+++ b/patches/patches/058_quiz7.patch
@@ -1,14 +1,31 @@
-188,189c188,189
+185,186c185,186
< .place => print("{s}", .{p.name}),
< .path => print("--{}->", .{p.dist}),
---
> .place => |p| print("{s}", .{p.name}),
> .path => |p| print("--{}->", .{p.dist}),
-251c251
+248c248
< if (place == entry.*.?.place) return entry;
---
> if (place == entry.*.?.place) return &entry.*.?;
-305c305
+302c302
< fn getTripTo(self: *HermitsNotebook, trip: []?TripItem, dest: *Place) void {
---
> fn getTripTo(self: *HermitsNotebook, trip: []?TripItem, dest: *Place) TripError!void {
+336d335
+< // Note: you do not need to fix anything here.
+419,422c418
+< // We convert the usize length to a u8 with @intCast(), a
+< // builtin function just like @import(). We'll learn about
+< // these properly in a later exercise.
+< var i: u8 = @intCast(u8, trip.len);
+---
+> var i: u8 = @intCast(u8, trip.len); // convert usize length
+449,452c445,446
+< // Search" (BFS).
+< //
+< // By tracking "lowest cost" paths, we can also say that we're
+< // performing a "least-cost search".
+---
+> // Search" (BFS). By tracking "lowest cost" paths, we can also say
+> // that we're performing a "least-cost search".