From e06cf4560482f998d757374262589c615fe94cef Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 19 Jun 2024 12:19:46 -0400 Subject: [PATCH] 092-098 completed --- exercises/092_interfaces.zig | 2 +- exercises/093_hello_c.zig | 2 +- exercises/094_c_math.zig | 2 +- exercises/095_for3.zig | 2 +- exercises/096_memory_allocation.zig | 2 +- exercises/097_bit_manipulation.zig | 2 +- exercises/098_bit_manipulation2.zig | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/exercises/092_interfaces.zig b/exercises/092_interfaces.zig index 7775dd5..12caaaf 100644 --- a/exercises/092_interfaces.zig +++ b/exercises/092_interfaces.zig @@ -106,7 +106,7 @@ pub fn main() !void { for (my_insects) |insect| { // Almost done! We want to print() each insect with a // single method call here. - ??? + insect.print(); } } diff --git a/exercises/093_hello_c.zig b/exercises/093_hello_c.zig index 182e0b0..a1a40cb 100644 --- a/exercises/093_hello_c.zig +++ b/exercises/093_hello_c.zig @@ -54,7 +54,7 @@ pub fn main() void { // // In this exercise we use 'write' to output 17 chars, // but something is still missing... - const c_res = write(2, "Hello C from Zig!", 17); + const c_res = c.write(2, "Hello C from Zig!", 17); // let's see what the result from C is: std.debug.print(" - C result is {d} chars written.\n", .{c_res}); diff --git a/exercises/094_c_math.zig b/exercises/094_c_math.zig index ec59a86..395ed34 100644 --- a/exercises/094_c_math.zig +++ b/exercises/094_c_math.zig @@ -26,7 +26,7 @@ const std = @import("std"); const c = @cImport({ // What do we need here? - ??? + @cInclude("math.h"); }); pub fn main() !void { diff --git a/exercises/095_for3.zig b/exercises/095_for3.zig index e4c4662..13a77a1 100644 --- a/exercises/095_for3.zig +++ b/exercises/095_for3.zig @@ -54,7 +54,7 @@ pub fn main() void { // I want to print every number between 1 and 20 that is NOT // divisible by 3 or 5. - for (???) |n| { + for (0..21) |n| { // The '%' symbol is the "modulo" operator and it // returns the remainder after division. diff --git a/exercises/096_memory_allocation.zig b/exercises/096_memory_allocation.zig index 58de7b0..e353008 100644 --- a/exercises/096_memory_allocation.zig +++ b/exercises/096_memory_allocation.zig @@ -64,7 +64,7 @@ pub fn main() !void { const allocator = arena.allocator(); // allocate memory for this array - const avg: []f64 = ???; + const avg: []f64 = try allocator.alloc(f64, arr.len); runningAverage(arr, avg); std.debug.print("Running Average: ", .{}); diff --git a/exercises/097_bit_manipulation.zig b/exercises/097_bit_manipulation.zig index 03fc72d..f1a44ea 100644 --- a/exercises/097_bit_manipulation.zig +++ b/exercises/097_bit_manipulation.zig @@ -80,7 +80,7 @@ pub fn main() !void { y ^= x; // What must be written here? - ???; + x ^= y; print("x = {d}; y = {d}\n", .{ x, y }); } diff --git a/exercises/098_bit_manipulation2.zig b/exercises/098_bit_manipulation2.zig index 979b103..0115b90 100644 --- a/exercises/098_bit_manipulation2.zig +++ b/exercises/098_bit_manipulation2.zig @@ -60,5 +60,5 @@ fn isPangram(str: []const u8) bool { // and if so, we know the given string is a pangram // // but what do we have to compare? - return bits == 0x..???; + return bits == 0x3ffffff; }