From 0651d71c472abb67b7be668772e2d59f2d259d6b Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 12 Jun 2024 06:54:01 -0400 Subject: [PATCH] 075-079 completed --- exercises/075_quiz8.zig | 6 +++++- exercises/076_sentinels.zig | 4 ++-- exercises/077_sentinels2.zig | 2 +- exercises/078_sentinels3.zig | 2 +- exercises/079_quoted_identifiers.zig | 8 ++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/exercises/075_quiz8.zig b/exercises/075_quiz8.zig index 63d208b..b9fc50d 100644 --- a/exercises/075_quiz8.zig +++ b/exercises/075_quiz8.zig @@ -49,7 +49,11 @@ const Path = struct { // // Please fill in the body of this function! fn makePath(from: *Place, to: *Place, dist: u8) Path { - + return Path{ + .from = from, + .to = to, + .dist = dist, + }; } // Using our new function, these path definitions take up considerably less diff --git a/exercises/076_sentinels.zig b/exercises/076_sentinels.zig index 357bd95..dfa32b8 100644 --- a/exercises/076_sentinels.zig +++ b/exercises/076_sentinels.zig @@ -82,7 +82,7 @@ fn printSequence(my_seq: anytype) void { print("Array:", .{}); // Loop through the items in my_seq. - for (???) |s| { + for (my_seq) |s| { print("{}", .{s}); } }, @@ -94,7 +94,7 @@ fn printSequence(my_seq: anytype) void { // Loop through the items in my_seq until we hit the // sentinel value. var i: usize = 0; - while (??? != my_sentinel) { + while (my_seq[i] != my_sentinel) { print("{}", .{my_seq[i]}); i += 1; } diff --git a/exercises/077_sentinels2.zig b/exercises/077_sentinels2.zig index fb8f13d..3892898 100644 --- a/exercises/077_sentinels2.zig +++ b/exercises/077_sentinels2.zig @@ -60,7 +60,7 @@ pub fn main() void { // length... You've actually solved this problem before! // // Here's a big hint: do you remember how to take a slice? - const printable = ???; + const printable = foo.data[0..11]; print("{s}\n", .{printable}); } diff --git a/exercises/078_sentinels3.zig b/exercises/078_sentinels3.zig index 1e443e6..90b953f 100644 --- a/exercises/078_sentinels3.zig +++ b/exercises/078_sentinels3.zig @@ -21,7 +21,7 @@ pub fn main() void { const data: [*]const u8 = "Weird Data!"; // Please cast 'data' to 'printable': - const printable: [*:0]const u8 = ???; + const printable: [*:0]const u8 = @ptrCast(data); print("{s}\n", .{printable}); } diff --git a/exercises/079_quoted_identifiers.zig b/exercises/079_quoted_identifiers.zig index 182c7ff..6abbe59 100644 --- a/exercises/079_quoted_identifiers.zig +++ b/exercises/079_quoted_identifiers.zig @@ -20,11 +20,11 @@ const print = @import("std").debug.print; pub fn main() void { - const 55_cows: i32 = 55; - const isn't true: bool = false; + const @"55_cows": i32 = 55; + const @"isn't true": bool = false; print("Sweet freedom: {}, {}.\n", .{ - 55_cows, - isn't true, + @"55_cows", + @"isn't true", }); }