summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
Diffstat (limited to 'patches')
-rwxr-xr-xpatches/eowyn.sh14
-rw-r--r--patches/patches/046_optionals2.patch4
-rw-r--r--patches/patches/058_quiz7.patch6
-rw-r--r--patches/patches/060_floats.patch12
-rw-r--r--patches/patches/065_builtins2.patch10
-rw-r--r--patches/patches/082_anonymous_structs3.patch6
-rw-r--r--patches/patches/097_bit_manipulation.patch6
-rw-r--r--patches/patches/099_formatting.patch4
-rw-r--r--patches/patches/100_for4.patch2
-rw-r--r--patches/patches/106_files.patch91
-rw-r--r--patches/patches/107_files2.patch54
-rw-r--r--patches/patches/109_vectors.patch13
-rw-r--r--patches/patches/110_quiz9.patch56
13 files changed, 128 insertions, 150 deletions
diff --git a/patches/eowyn.sh b/patches/eowyn.sh
index 8cac450..afc2732 100755
--- a/patches/eowyn.sh
+++ b/patches/eowyn.sh
@@ -12,6 +12,12 @@
# using the patches in this directory and convey them
# to convalesce in the healed directory.
#
+delete_progress() {
+ progress_file=".progress.txt"
+ if [ -f $progress_file ]; then
+ rm $progress_file
+ fi
+}
set -e
# We check ourselves before we wreck ourselves.
@@ -23,9 +29,12 @@ fi
# Which version we have?
echo "Zig version" $(zig version)
-echo "Eowyn version 23.10.5.1, let's try our magic power."
+echo "Eowyn version 25.1.9, let's try our magic power."
echo ""
+# Remove progress file
+delete_progress
+
# Create directory of healing if it doesn't already exist.
mkdir -p patches/healed
@@ -54,3 +63,6 @@ zig fmt --check patches/healed
# Test the healed exercises. May the compiler have mercy upon us.
zig build -Dhealed
+
+# Remove progress file again
+delete_progress
diff --git a/patches/patches/046_optionals2.patch b/patches/patches/046_optionals2.patch
index 1b364a6..8fa01a2 100644
--- a/patches/patches/046_optionals2.patch
+++ b/patches/patches/046_optionals2.patch
@@ -1,5 +1,5 @@
---- exercises/046_optionals2.zig 2024-09-04 20:51:36.766783971 +0200
-+++ answers/046_optionals2.zig 2024-09-04 20:51:01.389400985 +0200
+--- exercises/046_optionals2.zig 2024-11-08 22:46:25.592875338 +0100
++++ answers/046_optionals2.zig 2024-11-08 22:46:20.699447951 +0100
@@ -22,7 +22,7 @@
const Elephant = struct {
diff --git a/patches/patches/058_quiz7.patch b/patches/patches/058_quiz7.patch
index 265b9e3..978fbb1 100644
--- a/patches/patches/058_quiz7.patch
+++ b/patches/patches/058_quiz7.patch
@@ -1,8 +1,8 @@
---- exercises/058_quiz7.zig 2023-10-03 22:15:22.125574535 +0200
-+++ answers/058_quiz7.zig 2023-10-05 20:04:07.106101152 +0200
+--- exercises/058_quiz7.zig 2024-10-28 09:06:49.448505460 +0100
++++ answers/058_quiz7.zig 2024-10-28 09:35:14.631932322 +0100
@@ -192,8 +192,8 @@
// Oops! The hermit forgot how to capture the union values
- // in a switch statement. Please capture both values as
+ // in a switch statement. Please capture each value as
// 'p' so the print statements work!
- .place => print("{s}", .{p.name}),
- .path => print("--{}->", .{p.dist}),
diff --git a/patches/patches/060_floats.patch b/patches/patches/060_floats.patch
index 404654a..9e64c6f 100644
--- a/patches/patches/060_floats.patch
+++ b/patches/patches/060_floats.patch
@@ -1,11 +1,11 @@
---- exercises/060_floats.zig 2023-11-06 19:45:03.609687304 +0100
-+++ answers/060_floats.zig 2023-11-06 19:44:49.249419994 +0100
+--- exercises/060_floats.zig 2025-03-03 20:23:40.255443963 +0400
++++ answers/060_floats.zig 2025-03-03 20:29:58.554854977 +0400
@@ -43,7 +43,7 @@
//
- // We'll convert this weight from pound to kilograms at a
- // conversion of 0.453592kg to the pound.
-- const shuttle_weight: f16 = 0.453592 * 4480e6;
-+ const shuttle_weight: f32 = 0.453592 * 4.480e6;
+ // We'll convert this weight from pounds to metric units at a
+ // conversion of 0.453592 kg to the pound.
+- const shuttle_weight: f16 = 0.453592 * 4480e3;
++ const shuttle_weight: f32 = 0.453592 * 4.480e3;
// By default, float values are formatted in scientific
// notation. Try experimenting with '{d}' and '{d:.3}' to see
diff --git a/patches/patches/065_builtins2.patch b/patches/patches/065_builtins2.patch
index d5da950..e5e6410 100644
--- a/patches/patches/065_builtins2.patch
+++ b/patches/patches/065_builtins2.patch
@@ -1,5 +1,5 @@
---- exercises/065_builtins2.zig 2024-09-02 19:15:56.569952315 +0200
-+++ answers/065_builtins2.zig 2024-09-02 19:13:44.280600350 +0200
+--- exercises/065_builtins2.zig 2024-11-02 16:58:30.607829441 +0100
++++ answers/065_builtins2.zig 2024-11-02 16:58:33.821220588 +0100
@@ -58,7 +58,7 @@
// Oops! We cannot leave the 'me' and 'myself' fields
// undefined. Please set them here:
@@ -24,16 +24,16 @@
// (which is a zero-bit type that takes up no space at all!):
- if (fields[0].??? != void) {
+ if (fields[0].type != void) {
- print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[0].name});
+ print(" {s}", .{fields[0].name});
}
- if (fields[1].??? != void) {
+ if (fields[1].type != void) {
- print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[1].name});
+ print(" {s}", .{fields[1].name});
}
- if (fields[2].??? != void) {
+ if (fields[2].type != void) {
- print(" {s}", .{@typeInfo(Narcissus).@"struct".fields[2].name});
+ print(" {s}", .{fields[2].name});
}
diff --git a/patches/patches/082_anonymous_structs3.patch b/patches/patches/082_anonymous_structs3.patch
index b918011..0f71a94 100644
--- a/patches/patches/082_anonymous_structs3.patch
+++ b/patches/patches/082_anonymous_structs3.patch
@@ -1,5 +1,5 @@
---- exercises/082_anonymous_structs3.zig 2024-09-07 19:13:58.210327580 +0200
-+++ answers/082_anonymous_structs3.zig 2024-09-07 19:21:20.972733477 +0200
+--- exercises/082_anonymous_structs3.zig 2025-03-14 16:41:17.892873287 +0200
++++ answers/082_anonymous_structs3.zig 2025-03-14 16:40:56.043829543 +0200
@@ -82,14 +82,14 @@
// @typeInfo(Circle).@"struct".fields
//
@@ -17,7 +17,7 @@
// 3. Print the field's name, type, and value.
//
// Each 'field' in this loop is one of these:
-@@ -117,9 +117,9 @@
+@@ -119,9 +119,9 @@
//
// The first field should print as: "0"(bool):true
print("\"{s}\"({any}):{any} ", .{
diff --git a/patches/patches/097_bit_manipulation.patch b/patches/patches/097_bit_manipulation.patch
index 5303ee1..19ba876 100644
--- a/patches/patches/097_bit_manipulation.patch
+++ b/patches/patches/097_bit_manipulation.patch
@@ -1,5 +1,5 @@
---- exercises/097_bit_manipulation.zig 2023-10-03 22:15:22.125574535 +0200
-+++ answers/097_bit_manipulation.zig 2023-10-05 20:04:07.282771124 +0200
+--- exercises/097_bit_manipulation.zig 2025-05-12 21:25:03.395385743 +0200
++++ answers/097_bit_manipulation.zig 2025-05-12 21:22:57.472986976 +0200
@@ -80,7 +80,7 @@
y ^= x;
@@ -7,5 +7,5 @@
- ???;
+ x ^= y;
- print("x = {d}; y = {d}\n", .{ x, y });
+ print("x = {b}; y = {b}\n", .{ x, y });
}
diff --git a/patches/patches/099_formatting.patch b/patches/patches/099_formatting.patch
index 384bf86..a56b556 100644
--- a/patches/patches/099_formatting.patch
+++ b/patches/patches/099_formatting.patch
@@ -1,5 +1,5 @@
---- exercises/099_formatting.zig 2023-10-03 22:15:22.125574535 +0200
-+++ answers/099_formatting.zig 2023-10-05 20:04:07.292771311 +0200
+--- exercises/099_formatting.zig 2024-11-07 21:45:10.459123650 +0100
++++ answers/099_formatting.zig 2024-11-07 21:43:55.154345991 +0100
@@ -131,7 +131,7 @@
for (0..size) |b| {
// What formatting is needed here to make our columns
diff --git a/patches/patches/100_for4.patch b/patches/patches/100_for4.patch
index 3539be2..ad73e9a 100644
--- a/patches/patches/100_for4.patch
+++ b/patches/patches/100_for4.patch
@@ -7,5 +7,5 @@
- for (hex_nums, ???) |hn, ???| {
+ for (hex_nums, dec_nums) |hn, dn| {
if (hn != dn) {
- std.debug.print("Uh oh! Found a mismatch: {d} vs {d}\n", .{ hn, dn });
+ print("Uh oh! Found a mismatch: {d} vs {d}\n", .{ hn, dn });
return;
diff --git a/patches/patches/106_files.patch b/patches/patches/106_files.patch
index 5eb5a19..f40a33a 100644
--- a/patches/patches/106_files.patch
+++ b/patches/patches/106_files.patch
@@ -1,63 +1,16 @@
---- exercises/106_files.zig 2024-06-17 10:11:53.651439869 +0200
-+++ answers/106_files.zig 2024-06-17 10:21:50.697337653 +0200
-@@ -1,22 +1,22 @@
- //
- // Until now, we've only been printing our output in the console,
--// which is good enough for fighting aliens and hermit bookkeeping.
-+// which is good enough for fighting alien and hermit bookkeeping.
- //
--// However, many other tasks require some interaction with the file system,
-+// However, many other task require some interaction with the file system,
- // which is the underlying structure for organizing files on your computer.
- //
--// The file system provides a hierarchical structure for storing files
--// by organizing them into directories, which hold files and other directories,
--// thus creating a tree structure that can be navigated.
-+// The File System provide a hierarchical structure for storing files
-+// by organizing files into directories, which hold files and other directories,
-+// thus creating a tree structure for navigating.
- //
--// Fortunately, the Zig standard library provides a simple API for interacting
--// with the file system, see the detail documentation here:
-+// Fortunately, zig standard library provide a simple api for interacting
-+// with the file system, see the detail documentation here
- //
- // https://ziglang.org/documentation/master/std/#std.fs
- //
--// In this exercise, we'll try to:
--// - create a new directory,
--// - open a file in the directory,
-+// In this exercise, we'll try to
-+// - create a new directory
-+// - open a file in the directory
- // - write to the file.
- //
- // import std as always
-@@ -27,42 +27,42 @@
- const cwd: std.fs.Dir = std.fs.cwd();
-
- // then we'll try to make a new directory /output/
-- // to store our output files.
-+ // to put our output files.
- cwd.makeDir("output") catch |e| switch (e) {
-- // there is a chance you might want to run this
-+ // there are chance you might want to run this
- // program more than once and the path might already
-- // have been created, so we'll have to handle this error
-+ // been created, so we'll have to handle this error
+--- exercises/106_files.zig 2025-03-13 15:26:59.532367792 +0200
++++ answers/106_files.zig 2025-03-14 22:04:52.243435159 +0200
+@@ -35,7 +35,7 @@
// by doing nothing
//
// we want to catch error.PathAlreadyExists and do nothing
- ??? => {},
-- // if there's any other unexpected error we just propagate it through
+ error.PathAlreadyExists => {},
-+ // if is any other unexpected error we just propagate it through
+ // if there's any other unexpected error we just propagate it through
else => return e,
};
-
- // then we'll try to open our freshly created directory
-- // wait a minute...
-+ // wait a minute
+@@ -44,7 +44,7 @@
+ // wait a minute...
// opening a directory might fail!
// what should we do here?
- var output_dir: std.fs.Dir = cwd.openDir("output", .{});
@@ -65,36 +18,12 @@
defer output_dir.close();
// we try to open the file `zigling.txt`,
-- // and propagate any error up
-+ // and propagate the error up if there are any errors
- const file: std.fs.File = try output_dir.createFile("zigling.txt", .{});
- // it is a good habit to close a file after you are done with it
- // so that other programs can read it and prevent data corruption
+@@ -55,7 +55,7 @@
// but here we are not yet done writing to the file
-- // if only there were a keyword in Zig that
-- // allowed you to "defer" code execution to the end of the scope...
+ // if only there were a keyword in Zig that
+ // allowed you to "defer" code execution to the end of the scope...
- file.close();
-+ // if only there were a keyword in zig that
-+ // allows you "defer" code execute to the end of scope...
+ defer file.close();
-- // you are not allowed to move these two lines above the file closing line!
-+ // !you are not allowed to switch these two lines above the file closing line!
+ // you are not allowed to move these two lines above the file closing line!
const byte_written = try file.write("It's zigling time!");
- std.debug.print("Successfully wrote {d} bytes.\n", .{byte_written});
- }
- // to check if you actually write to the file, you can either,
--// 1. open the file in your text editor, or
-+// 1. open the file on your text editor, or
- // 2. print the content of the file in the console with the following command
- // >> cat ./output/zigling.txt
- //
-@@ -86,7 +86,7 @@
- //
- // Question:
- // - what should you do if you want to also read the file after opening it?
--// - go to the documentation of the struct `std.fs.Dir` here:
-+// - go to documentation of the struct `std.fs.Dir` here
- // https://ziglang.org/documentation/master/std/#std.fs.Dir
- // - can you find a function for opening a file? how about deleting a file?
- // - what kind of options can you use with those functions?
diff --git a/patches/patches/107_files2.patch b/patches/patches/107_files2.patch
index ebf8a7c..95aaa0c 100644
--- a/patches/patches/107_files2.patch
+++ b/patches/patches/107_files2.patch
@@ -1,55 +1,23 @@
---- exercises/107_files2.zig 2024-06-17 10:11:53.651439869 +0200
-+++ answers/107_files2.zig 2024-06-17 10:21:50.700671057 +0200
-@@ -4,17 +4,17 @@
- // - create a file {project_root}/output/zigling.txt
- // with content `It's zigling time!`(18 byte total)
- //
--// Now there's no point in writing to a file if we don't read from it, am I right?
--// Let's write a program to read the content of the file that we just created.
-+// Now there no point in writing to a file if we don't read from it am I right?
-+// let's write a program to read the content of the file that we just created.
- //
- // I am assuming that you've created the appropriate files for this to work.
- //
--// 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
- // - Secondly, we open file `zigling.txt` in that directory
--// - Then, we initalize an array of characters with all letter 'A', and print it
--// - After that, we read the content of the file into the array
--// - Finally, we print out the content we just read
-+// - then, we initalize an array of characters with all letter 'A', and print it
-+// - After that, we read the content of the file to the array
-+// - Finally, we print out the read content
-
- const std = @import("std");
-
-@@ -30,23 +30,23 @@
- const file = try output_dir.openFile("zigling.txt", .{});
- defer file.close();
-
-- // initalize an array of u8 with all letter 'A'
-- // we need to pick the size of the array, 64 seems like a good number
-+ // initalize an array of u8 with all letter 'A'.
-+ // we need to pick the size of the array, 64 seems like a good number.
- // fix the initalization below
+--- exercises/107_files2.zig 2025-03-13 15:26:59.532367792 +0200
++++ answers/107_files2.zig 2025-03-14 22:08:35.167953736 +0200
+@@ -33,7 +33,7 @@
+ // initialize an array of u8 with all letter 'A'
+ // we need to pick the size of the array, 64 seems like a good number
+ // fix the initialization below
- var content = ['A']*64;
+ var content = [_]u8{'A'} ** 64;
// this should print out : `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA`
std.debug.print("{s}\n", .{content});
- // okay, seems like a threat of violence is not the answer in this case
-- // can you go here to find a way to read the content?
-+ // can you go here to find a way to read the content ?
+@@ -41,12 +41,12 @@
+ // can you go here to find a way to read the content?
// https://ziglang.org/documentation/master/std/#std.fs.File
- // hint: you might find two answers that are both vaild in this case
+ // hint: you might find two answers that are both valid in this case
- const bytes_read = zig_read_the_file_or_i_will_fight_you(&content);
+ const bytes_read = try file.read(&content);
-- // Woah, too screamy. I know you're excited for zigling time but tone it down a bit.
-- // Can you print only what we read from the file?
-+ // Woah, too screamy, I know you're excited for zigling time but tone it down a bit
-+ // Can you print only what we read from the file ?
+ // Woah, too screamy. I know you're excited for zigling time but tone it down a bit.
+ // Can you print only what we read from the file?
std.debug.print("Successfully Read {d} bytes: {s}\n", .{
bytes_read,
- content, // change this line only
diff --git a/patches/patches/109_vectors.patch b/patches/patches/109_vectors.patch
new file mode 100644
index 0000000..bf18cc0
--- /dev/null
+++ b/patches/patches/109_vectors.patch
@@ -0,0 +1,13 @@
+--- exercises/109_vectors.zig 2024-11-07 14:57:09.673383618 +0100
++++ answers/109_vectors.zig 2024-11-07 14:22:59.069150138 +0100
+@@ -121,8 +121,8 @@
+
+ const Vec4 = @Vector(4, f32);
+ fn calcMaxPairwiseDiffNew(a: Vec4, b: Vec4) f32 {
+- const abs_diff_vec = ???;
+- const max_diff = @reduce(???, abs_diff_vec);
++ const abs_diff_vec = @abs(a - b);
++ const max_diff = @reduce(.Max, abs_diff_vec);
+ return max_diff;
+ }
+
diff --git a/patches/patches/110_quiz9.patch b/patches/patches/110_quiz9.patch
new file mode 100644
index 0000000..9d9b864
--- /dev/null
+++ b/patches/patches/110_quiz9.patch
@@ -0,0 +1,56 @@
+--- exercises/110_quiz9.zig 2025-02-08 13:19:48.522641785 -0800
++++ answers/110_quiz9.zig 2025-02-10 17:42:04.525004335 -0800
+@@ -108,7 +108,7 @@
+ PORTB = 0b1100;
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("^ {b:0>4} // (bitmask)\n", .{0b0101});
+- PORTB ^= (1 << 1) | (1 << 0); // What's wrong here?
++ PORTB ^= (1 << 2) | (1 << 0);
+ checkAnswer(0b1001, PORTB);
+
+ newline();
+@@ -116,7 +116,7 @@
+ PORTB = 0b1100;
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("^ {b:0>4} // (bitmask)\n", .{0b0011});
+- PORTB ^= (1 << 1) & (1 << 0); // What's wrong here?
++ PORTB ^= (1 << 1) | (1 << 0);
+ checkAnswer(0b1111, PORTB);
+
+ newline();
+@@ -170,7 +170,7 @@
+ PORTB = 0b1001; // reset PORTB
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("| {b:0>4} // (bitmask)\n", .{0b0100});
+- PORTB = PORTB ??? (1 << 2); // What's missing here?
++ PORTB = PORTB | (1 << 2);
+ checkAnswer(0b1101, PORTB);
+
+ newline();
+@@ -178,7 +178,7 @@
+ PORTB = 0b1001; // reset PORTB
+ print(" {b:0>4} // (reset state)\n", .{PORTB});
+ print("| {b:0>4} // (bitmask)\n", .{0b0100});
+- PORTB ??? (1 << 2); // What's missing here?
++ PORTB |= (1 << 2);
+ checkAnswer(0b1101, PORTB);
+
+ newline();
+@@ -269,7 +269,7 @@
+ PORTB = 0b1110; // reset PORTB
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("& {b:0>4} // (bitmask)\n", .{0b1011});
+- PORTB = PORTB & ???@as(u4, 1 << 2); // What character is missing here?
++ PORTB = PORTB & ~@as(u4, 1 << 2);
+ checkAnswer(0b1010, PORTB);
+
+ newline();
+@@ -277,7 +277,7 @@
+ PORTB = 0b0111; // reset PORTB
+ print(" {b:0>4} // (reset state)\n", .{PORTB});
+ print("& {b:0>4} // (bitmask)\n", .{0b1110});
+- PORTB &= ~(1 << 0); // What's missing here?
++ PORTB &= ~@as(u4, 1 << 0);
+ checkAnswer(0b0110, PORTB);
+
+ newline();