Merge pull request 'fix: typos' (#222) from ddogfoodd/exercises:main into main

Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/222
This commit is contained in:
Chris Boesch 2025-03-22 10:47:00 +00:00
commit d7052e4137
8 changed files with 14 additions and 14 deletions

View File

@ -200,7 +200,7 @@ pub fn build(b: *Build) !void {
if (rand) |_| { if (rand) |_| {
// Random build mode: verifies one random exercise. // Random build mode: verifies one random exercise.
// like for 'exno' but chooses a random exersise number. // like for 'exno' but chooses a random exercise number.
print("work in progress: check a random exercise\n", .{}); print("work in progress: check a random exercise\n", .{});
var prng = std.Random.DefaultPrng.init(blk: { var prng = std.Random.DefaultPrng.init(blk: {

View File

@ -17,7 +17,7 @@
// //
// if (foo) |value| { // if (foo) |value| {
// ... // ...
// } else |err| switch(err) { // } else |err| switch (err) {
// ... // ...
// } // }
// //

View File

@ -7,7 +7,7 @@
// doing this work. // doing this work.
// //
// An 'inline for' is performed at compile time, allowing you to // An 'inline for' is performed at compile time, allowing you to
// programatically loop through a series of items in situations // programmatically loop through a series of items in situations
// like those mentioned above where a regular runtime 'for' loop // like those mentioned above where a regular runtime 'for' loop
// wouldn't be allowed: // wouldn't be allowed:
// //

View File

@ -21,9 +21,9 @@
// There were the Scottish mathematician Gregory and the German // There were the Scottish mathematician Gregory and the German
// mathematician Leibniz, and even a few hundred years earlier the Indian // mathematician Leibniz, and even a few hundred years earlier the Indian
// mathematician Madhava. All of them independently developed the same // mathematician Madhava. All of them independently developed the same
// formula, which was published by Leibnitz in 1682 in the journal // formula, which was published by Leibniz in 1682 in the journal
// "Acta Eruditorum". // "Acta Eruditorum".
// This is why this method has become known as the "Leibnitz series", // This is why this method has become known as the "Leibniz series",
// although the other names are also often used today. // although the other names are also often used today.
// We will not go into the formula and its derivation in detail, but // We will not go into the formula and its derivation in detail, but
// will deal with the series straight away: // will deal with the series straight away:
@ -50,7 +50,7 @@
// enough for us for now, because we want to understand the principle and // enough for us for now, because we want to understand the principle and
// nothing more, right? // nothing more, right?
// //
// As we have already discovered, the Leibnitz series is a series with a // As we have already discovered, the Leibniz series is a series with a
// fixed distance of 2 between the individual partial values. This makes // fixed distance of 2 between the individual partial values. This makes
// it easy to apply a simple loop to it, because if we start with n = 1 // it easy to apply a simple loop to it, because if we start with n = 1
// (which is not necessarily useful now) we always have to add 2 in each // (which is not necessarily useful now) we always have to add 2 in each

View File

@ -12,7 +12,7 @@
// Alright, bud, lean in close. Here's the game plan. // Alright, bud, lean in close. Here's the game plan.
// - First, we open the {project_root}/output/ directory // - First, we open the {project_root}/output/ directory
// - Secondly, we open file `zigling.txt` in that directory // - Secondly, we open file `zigling.txt` in that directory
// - Then, we initalize an array of characters with all letter 'A', and print it // - Then, we initialize an array of characters with all letter 'A', and print it
// - After that, we read the content of the file into the array // - After that, we read the content of the file into the array
// - Finally, we print out the content we just read // - Finally, we print out the content we just read
@ -30,9 +30,9 @@ pub fn main() !void {
const file = try output_dir.openFile("zigling.txt", .{}); const file = try output_dir.openFile("zigling.txt", .{});
defer file.close(); defer file.close();
// initalize an array of u8 with all letter 'A' // initialize an array of u8 with all letter 'A'
// we need to pick the size of the array, 64 seems like a good number // we need to pick the size of the array, 64 seems like a good number
// fix the initalization below // fix the initialization below
var content = ['A']*64; var content = ['A']*64;
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA` // this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`
std.debug.print("{s}\n", .{content}); std.debug.print("{s}\n", .{content});

View File

@ -24,7 +24,7 @@
// //
// By combining all we've learned so far, we can now proceed with a labeled switch // By combining all we've learned so far, we can now proceed with a labeled switch
// //
// A labeled switch is some extra syntatic sugar, which comes with all sorts of // A labeled switch is some extra syntactic sugar, which comes with all sorts of
// candy (performance benefits). Don't believe me? Directly to source https://github.com/ziglang/zig/pull/21367 // candy (performance benefits). Don't believe me? Directly to source https://github.com/ziglang/zig/pull/21367
// //
// Here is the previous excerpt implemented as a labeled switch instead: // Here is the previous excerpt implemented as a labeled switch instead:

View File

@ -161,7 +161,7 @@ pub fn main() !void {
// In order to output a 1, the logic of an XOR operation requires that the // In order to output a 1, the logic of an XOR operation requires that the
// two input bits are of different values. Therefore, 0 ^ 1 and 1 ^ 0 will // two input bits are of different values. Therefore, 0 ^ 1 and 1 ^ 0 will
// both yield a 1 but 0 ^ 0 and 1 ^ 1 will output 0. XOR's unique behavior // both yield a 1 but 0 ^ 0 and 1 ^ 1 will output 0. XOR's unique behavior
// of outputing a 0 when both inputs are 1s is what makes it different from // of outputting a 0 when both inputs are 1s is what makes it different from
// the OR operator; it also gives us the ability to toggle bits by putting // the OR operator; it also gives us the ability to toggle bits by putting
// 1s into our bitmask. // 1s into our bitmask.
// //
@ -247,7 +247,7 @@ pub fn main() !void {
// PORTB = PORTB & 0b1011; // PORTB = PORTB & 0b1011;
// print("PORTB: {b:0>4}\n", .{PORTB}); // output -> 1010 // print("PORTB: {b:0>4}\n", .{PORTB}); // output -> 1010
// //
// - 0s clear bits when used in conjuction with a bitwise AND. // - 0s clear bits when used in conjunction with a bitwise AND.
// - 1s do nothing, thus preserving the original bits. // - 1s do nothing, thus preserving the original bits.
// //
// -AND op- ---expanded--- // -AND op- ---expanded---

View File

@ -1,9 +1,9 @@
--- exercises/107_files2.zig 2025-03-13 15:26:59.532367792 +0200 --- exercises/107_files2.zig 2025-03-13 15:26:59.532367792 +0200
+++ answers/107_files2.zig 2025-03-14 22:08:35.167953736 +0200 +++ answers/107_files2.zig 2025-03-14 22:08:35.167953736 +0200
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
// initalize an array of u8 with all letter 'A' // initialize an array of u8 with all letter 'A'
// we need to pick the size of the array, 64 seems like a good number // we need to pick the size of the array, 64 seems like a good number
// fix the initalization below // fix the initialization below
- var content = ['A']*64; - var content = ['A']*64;
+ var content = [_]u8{'A'} ** 64; + var content = [_]u8{'A'} ** 64;
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA` // this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`