diff options
| author | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-04-03 19:32:53 +0200 |
|---|---|---|
| committer | Chris Boesch <chrboesch@noreply.codeberg.org> | 2026-04-03 19:32:53 +0200 |
| commit | 5307b2a338a92130bc498fb1dc7d21a9fd1b0db4 (patch) | |
| tree | 51279ca4fbd7bd90294dd563640c12a8c25c79c6 /patches | |
| parent | 3056a2b5442f2f1ec58db3f3493109064ad2a2a5 (diff) | |
| parent | f6a6798c8b6b813bd2ceee81db276e05327a76e0 (diff) | |
Merge pull request 'revival of the async-io functions' (#383) from asyncIo into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/383
Diffstat (limited to 'patches')
| -rw-r--r-- | patches/patches/084_async.patch | 11 | ||||
| -rw-r--r-- | patches/patches/084_interfaces.patch (renamed from patches/patches/092_interfaces.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/085_async.patch | 11 | ||||
| -rw-r--r-- | patches/patches/085_async2.patch | 14 | ||||
| -rw-r--r-- | patches/patches/086_async2.patch | 14 | ||||
| -rw-r--r-- | patches/patches/086_async3.patch | 18 | ||||
| -rw-r--r-- | patches/patches/087_async3.patch | 18 | ||||
| -rw-r--r-- | patches/patches/087_async4.patch | 11 | ||||
| -rw-r--r-- | patches/patches/088_async4.patch | 11 | ||||
| -rw-r--r-- | patches/patches/088_async5.patch | 11 | ||||
| -rw-r--r-- | patches/patches/089_async5.patch | 11 | ||||
| -rw-r--r-- | patches/patches/089_async6.patch | 11 | ||||
| -rw-r--r-- | patches/patches/090_async6.patch | 11 | ||||
| -rw-r--r-- | patches/patches/090_async7.patch | 13 | ||||
| -rw-r--r-- | patches/patches/091_async7.patch | 13 | ||||
| -rw-r--r-- | patches/patches/091_async8.patch | 11 | ||||
| -rw-r--r-- | patches/patches/092_async8.patch | 11 | ||||
| -rw-r--r-- | patches/patches/092_async9.patch | 11 | ||||
| -rw-r--r-- | patches/patches/093_async10.patch | 13 | ||||
| -rw-r--r-- | patches/patches/093_async9.patch | 11 | ||||
| -rw-r--r-- | patches/patches/094_async10.patch | 13 | ||||
| -rw-r--r-- | patches/patches/095_interfaces.patch | 11 | ||||
| -rw-r--r-- | patches/patches/095_quiz_async.patch | 52 | ||||
| -rw-r--r-- | patches/patches/096_hello_c.patch (renamed from patches/patches/093_hello_c.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/097_bit_manipulation.patch | 11 | ||||
| -rw-r--r-- | patches/patches/097_c_math.patch (renamed from patches/patches/094_c_math.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/098_for3.patch (renamed from patches/patches/095_for3.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/099_memory_allocation.patch (renamed from patches/patches/096_memory_allocation.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/100_bit_manipulation.patch | 11 | ||||
| -rw-r--r-- | patches/patches/101_bit_manipulation2.patch (renamed from patches/patches/098_bit_manipulation2.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/102_formatting.patch (renamed from patches/patches/099_formatting.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/103_for4.patch (renamed from patches/patches/100_for4.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/104_for5.patch (renamed from patches/patches/101_for5.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/105_testing.patch (renamed from patches/patches/102_testing.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/106_tokenization.patch (renamed from patches/patches/103_tokenization.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/107_threading.patch (renamed from patches/patches/104_threading.patch) | 6 | ||||
| -rw-r--r-- | patches/patches/108_threading2.patch (renamed from patches/patches/105_threading2.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/109_files.patch (renamed from patches/patches/106_files.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/110_files2.patch (renamed from patches/patches/107_files2.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/111_labeled_switch.patch (renamed from patches/patches/108_labeled_switch.patch) | 6 | ||||
| -rw-r--r-- | patches/patches/112_vectors.patch (renamed from patches/patches/109_vectors.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/113_quiz9.patch (renamed from patches/patches/110_quiz9.patch) | 16 | ||||
| -rw-r--r-- | patches/patches/114_packed.patch (renamed from patches/patches/111_packed.patch) | 4 | ||||
| -rw-r--r-- | patches/patches/115_packed2.patch (renamed from patches/patches/112_packed2.patch) | 4 |
44 files changed, 370 insertions, 59 deletions
diff --git a/patches/patches/084_async.patch b/patches/patches/084_async.patch new file mode 100644 index 0000000..2c97f0e --- /dev/null +++ b/patches/patches/084_async.patch @@ -0,0 +1,11 @@ +--- exercises/084_async.zig 2026-04-01 20:40:08.904999609 +0200 ++++ answers/084_async.zig 2026-04-01 20:40:05.641933231 +0200 +@@ -37,7 +37,7 @@ + const std = @import("std"); + + pub fn main(init: std.process.Init) !void { +- const io = init.???; ++ const io = init.io; + + // Get the current wall-clock time using the Io interface. + // Hint: Timestamp.now() takes an Io and a Clock type (.real = wall clock). diff --git a/patches/patches/092_interfaces.patch b/patches/patches/084_interfaces.patch index 36d8784..d3a45fd 100644 --- a/patches/patches/092_interfaces.patch +++ b/patches/patches/084_interfaces.patch @@ -1,5 +1,5 @@ ---- exercises/092_interfaces.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/092_interfaces.zig 2023-10-05 20:04:07.259437354 +0200 +--- exercises/084_interfaces.zig 2026-04-03 19:24:51.764327692 +0200 ++++ answers/084_interfaces.zig 2026-04-03 19:27:31.552579474 +0200 @@ -106,7 +106,7 @@ for (my_insects) |insect| { // Almost done! We want to print() each insect with a diff --git a/patches/patches/085_async.patch b/patches/patches/085_async.patch new file mode 100644 index 0000000..ca8b102 --- /dev/null +++ b/patches/patches/085_async.patch @@ -0,0 +1,11 @@ +--- exercises/085_async.zig 2026-04-01 20:40:08.904999609 +0200 ++++ answers/085_async.zig 2026-04-01 20:40:05.641933231 +0200 +@@ -37,7 +37,7 @@ + const std = @import("std"); + + pub fn main(init: std.process.Init) !void { +- const io = init.???; ++ const io = init.io; + + // Get the current wall-clock time using the Io interface. + // Hint: Timestamp.now() takes an Io and a Clock type (.real = wall clock). diff --git a/patches/patches/085_async2.patch b/patches/patches/085_async2.patch new file mode 100644 index 0000000..7583d7c --- /dev/null +++ b/patches/patches/085_async2.patch @@ -0,0 +1,14 @@ +--- exercises/085_async2.zig 2026-04-01 19:22:50.017227542 +0200 ++++ answers/085_async2.zig 2026-04-01 19:21:57.569158481 +0200 +@@ -38,9 +38,9 @@ + + // Now collect the result. What method on Future gives us + // the value, blocking if it isn't ready yet? +- const answer = future.???(io); ++ const answer = future.await(io); + +- std.debug.print("The answer is: {}\n", .{answer}); ++ std.debug.print("the answer is: {}\n", .{answer}); + } + + fn computeAnswer(a: u32, b: u32) u32 { diff --git a/patches/patches/086_async2.patch b/patches/patches/086_async2.patch new file mode 100644 index 0000000..7506a69 --- /dev/null +++ b/patches/patches/086_async2.patch @@ -0,0 +1,14 @@ +--- exercises/086_async2.zig 2026-04-01 19:22:50.017227542 +0200 ++++ answers/086_async2.zig 2026-04-01 19:21:57.569158481 +0200 +@@ -38,9 +38,9 @@ + + // Now collect the result. What method on Future gives us + // the value, blocking if it isn't ready yet? +- const answer = future.???(io); ++ const answer = future.await(io); + +- std.debug.print("The answer is: {}\n", .{answer}); ++ std.debug.print("the answer is: {}\n", .{answer}); + } + + fn computeAnswer(a: u32, b: u32) u32 { diff --git a/patches/patches/086_async3.patch b/patches/patches/086_async3.patch new file mode 100644 index 0000000..3a3c2c4 --- /dev/null +++ b/patches/patches/086_async3.patch @@ -0,0 +1,18 @@ +--- exercises/086_async3.zig 2026-04-01 22:51:05.540094851 +0200 ++++ answers/086_async3.zig 2026-04-01 22:50:44.579669189 +0200 +@@ -29,12 +29,12 @@ + const io = init.io; + + // Launch both tasks asynchronously. +- var future_a = io.async(slowAdd, .{ 10, 20 }); +- var future_b = ???(slowMul, .{ 6, 7 }); ++ var future_a = io.async(slowAdd, .{ 1, 2 }); ++ var future_b = io.async(slowMul, .{ 6, 7 }); + + // Await both results. + const sum = future_a.await(io); +- const product = future_b.???(io); ++ const product = future_b.await(io); + + print("{} + {} = {}\n", .{ 1, 2, sum }); + print("{} * {} = {}\n", .{ 6, 7, product }); diff --git a/patches/patches/087_async3.patch b/patches/patches/087_async3.patch new file mode 100644 index 0000000..8365e7a --- /dev/null +++ b/patches/patches/087_async3.patch @@ -0,0 +1,18 @@ +--- exercises/087_async3.zig 2026-04-01 22:51:05.540094851 +0200 ++++ answers/087_async3.zig 2026-04-01 22:50:44.579669189 +0200 +@@ -29,12 +29,12 @@ + const io = init.io; + + // Launch both tasks asynchronously. +- var future_a = io.async(slowAdd, .{ 10, 20 }); +- var future_b = ???(slowMul, .{ 6, 7 }); ++ var future_a = io.async(slowAdd, .{ 1, 2 }); ++ var future_b = io.async(slowMul, .{ 6, 7 }); + + // Await both results. + const sum = future_a.await(io); +- const product = future_b.???(io); ++ const product = future_b.await(io); + + print("{} + {} = {}\n", .{ 1, 2, sum }); + print("{} * {} = {}\n", .{ 6, 7, product }); diff --git a/patches/patches/087_async4.patch b/patches/patches/087_async4.patch new file mode 100644 index 0000000..4883afd --- /dev/null +++ b/patches/patches/087_async4.patch @@ -0,0 +1,11 @@ +--- exercises/087_async4.zig 2026-04-01 23:17:31.066443941 +0200 ++++ answers/087_async4.zig 2026-04-01 23:17:39.251612131 +0200 +@@ -38,7 +38,7 @@ + + // Wait for all tasks to finish. + // What Group method blocks until all tasks complete? +- try group.??? ++ try group.await(io); + + print("All tasks finished!\n", .{}); + } diff --git a/patches/patches/088_async4.patch b/patches/patches/088_async4.patch new file mode 100644 index 0000000..1faf30e --- /dev/null +++ b/patches/patches/088_async4.patch @@ -0,0 +1,11 @@ +--- exercises/088_async4.zig 2026-04-01 23:17:31.066443941 +0200 ++++ answers/088_async4.zig 2026-04-01 23:17:39.251612131 +0200 +@@ -38,7 +38,7 @@ + + // Wait for all tasks to finish. + // What Group method blocks until all tasks complete? +- try group.??? ++ try group.await(io); + + print("All tasks finished!\n", .{}); + } diff --git a/patches/patches/088_async5.patch b/patches/patches/088_async5.patch new file mode 100644 index 0000000..d88e820 --- /dev/null +++ b/patches/patches/088_async5.patch @@ -0,0 +1,11 @@ +--- exercises/088_async5.zig 2026-04-01 23:40:40.505855238 +0200 ++++ answers/088_async5.zig 2026-04-01 23:40:10.176236971 +0200 +@@ -40,7 +40,7 @@ + + // We don't want to wait 10 seconds! + // Which Future method requests cancellation AND returns the result? +- const result = ???; ++ const result = future.cancel(io); + + print("Task returned: {}\n", .{result}); + } diff --git a/patches/patches/089_async5.patch b/patches/patches/089_async5.patch new file mode 100644 index 0000000..d2baa96 --- /dev/null +++ b/patches/patches/089_async5.patch @@ -0,0 +1,11 @@ +--- exercises/089_async5.zig 2026-04-01 23:40:40.505855238 +0200 ++++ answers/089_async5.zig 2026-04-01 23:40:10.176236971 +0200 +@@ -40,7 +40,7 @@ + + // We don't want to wait 10 seconds! + // Which Future method requests cancellation AND returns the result? +- const result = ???; ++ const result = future.cancel(io); + + print("Task returned: {}\n", .{result}); + } diff --git a/patches/patches/089_async6.patch b/patches/patches/089_async6.patch new file mode 100644 index 0000000..4ba0b49 --- /dev/null +++ b/patches/patches/089_async6.patch @@ -0,0 +1,11 @@ +--- exercises/089_async6.zig 2026-04-02 10:25:34.016616118 +0200 ++++ answers/089_async6.zig 2026-04-02 10:27:48.827144051 +0200 +@@ -47,7 +47,7 @@ + + // Wait for the first finisher. + // What Select method returns the first completed result? +- const winner = ???; ++ const winner = try sel.await(); + + switch (winner) { + .hare => |msg| print("Hare: {s}\n", .{msg}), diff --git a/patches/patches/090_async6.patch b/patches/patches/090_async6.patch new file mode 100644 index 0000000..5ac777b --- /dev/null +++ b/patches/patches/090_async6.patch @@ -0,0 +1,11 @@ +--- exercises/090_async6.zig 2026-04-02 10:25:34.016616118 +0200 ++++ answers/090_async6.zig 2026-04-02 10:27:48.827144051 +0200 +@@ -47,7 +47,7 @@ + + // Wait for the first finisher. + // What Select method returns the first completed result? +- const winner = ???; ++ const winner = try sel.await(); + + switch (winner) { + .hare => |msg| print("Hare: {s}\n", .{msg}), diff --git a/patches/patches/090_async7.patch b/patches/patches/090_async7.patch new file mode 100644 index 0000000..2108d51 --- /dev/null +++ b/patches/patches/090_async7.patch @@ -0,0 +1,13 @@ +--- exercises/090_async7.zig 2026-04-02 10:36:42.910708919 +0200 ++++ answers/090_async7.zig 2026-04-02 10:36:51.965884223 +0200 +@@ -49,8 +49,8 @@ + for (0..times) |_| { + // Acquire the lock before modifying shared state. + // What Mutex method blocks until the lock is acquired? +- state.mutex.??? catch return; +- defer state.mutex.unlock(); // <-- what's missing here? ++ state.mutex.lock(io) catch return; ++ defer state.mutex.unlock(io); + + state.counter += 1; + } diff --git a/patches/patches/091_async7.patch b/patches/patches/091_async7.patch new file mode 100644 index 0000000..b4bab9b --- /dev/null +++ b/patches/patches/091_async7.patch @@ -0,0 +1,13 @@ +--- exercises/091_async7.zig 2026-04-02 10:50:08.142508099 +0200 ++++ answers/091_async7.zig 2026-04-02 10:49:59.629341593 +0200 +@@ -49,8 +49,8 @@ + for (0..times) |_| { + // Acquire the lock before modifying shared state. + // What Mutex method blocks until the lock is acquired? +- state.mutex.??? catch return; +- defer state.mutex.unlock(); // <-- what's missing here? ++ state.mutex.lock(io) catch return; ++ defer state.mutex.unlock(io); + + state.counter += 1; + } diff --git a/patches/patches/091_async8.patch b/patches/patches/091_async8.patch new file mode 100644 index 0000000..865292f --- /dev/null +++ b/patches/patches/091_async8.patch @@ -0,0 +1,11 @@ +--- exercises/091_async8.zig 2026-04-02 10:49:27.925721496 +0200 ++++ answers/091_async8.zig 2026-04-02 10:49:31.694795212 +0200 +@@ -43,7 +43,7 @@ + // Send numbers 1 through 10 into the queue. + for (1..11) |i| { + // What Queue method sends a single element, blocking if full? +- queue.???(io, @intCast(i)) catch return; ++ queue.putOne(io, @intCast(i)) catch return; + } + // Signal that we're done sending. + queue.close(io); diff --git a/patches/patches/092_async8.patch b/patches/patches/092_async8.patch new file mode 100644 index 0000000..0ec9116 --- /dev/null +++ b/patches/patches/092_async8.patch @@ -0,0 +1,11 @@ +--- exercises/092_async8.zig 2026-04-02 10:49:27.925721496 +0200 ++++ answers/092_async8.zig 2026-04-02 10:49:31.694795212 +0200 +@@ -43,7 +43,7 @@ + // Send numbers 1 through 10 into the queue. + for (1..11) |i| { + // What Queue method sends a single element, blocking if full? +- queue.???(io, @intCast(i)) catch return; ++ queue.putOne(io, @intCast(i)) catch return; + } + // Signal that we're done sending. + queue.close(io); diff --git a/patches/patches/092_async9.patch b/patches/patches/092_async9.patch new file mode 100644 index 0000000..b7c8de9 --- /dev/null +++ b/patches/patches/092_async9.patch @@ -0,0 +1,11 @@ +--- exercises/092_async9.zig 2026-04-03 13:44:50.526780809 +0200 ++++ answers/092_async9.zig 2026-04-03 13:44:54.957870294 +0200 +@@ -36,7 +36,7 @@ + // Launch with a guaranteed separate thread. + // Which Io method guarantees true concurrency? + // (Hint: unlike io.async, this one can fail!) +- var future = try io.???(compute, .{io}); ++ var future = try io.concurrent(compute, .{io}); + + print("Main thread continues...\n", .{}); + diff --git a/patches/patches/093_async10.patch b/patches/patches/093_async10.patch new file mode 100644 index 0000000..69f7518 --- /dev/null +++ b/patches/patches/093_async10.patch @@ -0,0 +1,13 @@ +--- exercises/093_async10.zig 2026-04-03 14:25:16.600025924 +0200 ++++ answers/093_async10.zig 2026-04-03 14:24:56.192615893 +0200 +@@ -50,8 +50,8 @@ + + // Protect this section from cancellation. + // What method swaps the cancel protection state? +- const old = io.???(. blocked); +- defer _ = io.???(old); ++ const old = io.swapCancelProtection(.blocked); ++ defer _ = io.swapCancelProtection(old); + + // This sleep will NOT return error.Canceled even though + // we get canceled during it — protection is active! diff --git a/patches/patches/093_async9.patch b/patches/patches/093_async9.patch new file mode 100644 index 0000000..f759921 --- /dev/null +++ b/patches/patches/093_async9.patch @@ -0,0 +1,11 @@ +--- exercises/093_async9.zig 2026-04-03 13:44:50.526780809 +0200 ++++ answers/093_async9.zig 2026-04-03 13:44:54.957870294 +0200 +@@ -36,7 +36,7 @@ + // Launch with a guaranteed separate thread. + // Which Io method guarantees true concurrency? + // (Hint: unlike io.async, this one can fail!) +- var future = try io.???(compute, .{io}); ++ var future = try io.concurrent(compute, .{io}); + + print("Main thread continues...\n", .{}); + diff --git a/patches/patches/094_async10.patch b/patches/patches/094_async10.patch new file mode 100644 index 0000000..ae0d26d --- /dev/null +++ b/patches/patches/094_async10.patch @@ -0,0 +1,13 @@ +--- exercises/094_async10.zig 2026-04-03 14:25:16.600025924 +0200 ++++ answers/094_async10.zig 2026-04-03 14:24:56.192615893 +0200 +@@ -50,8 +50,8 @@ + + // Protect this section from cancellation. + // What method swaps the cancel protection state? +- const old = io.???(. blocked); +- defer _ = io.???(old); ++ const old = io.swapCancelProtection(.blocked); ++ defer _ = io.swapCancelProtection(old); + + // This sleep will NOT return error.Canceled even though + // we get canceled during it — protection is active! diff --git a/patches/patches/095_interfaces.patch b/patches/patches/095_interfaces.patch new file mode 100644 index 0000000..cb5fd62 --- /dev/null +++ b/patches/patches/095_interfaces.patch @@ -0,0 +1,11 @@ +--- exercises/095_interfaces.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/095_interfaces.zig 2026-04-03 13:09:13.722917764 +0200 +@@ -106,7 +106,7 @@ + for (my_insects) |insect| { + // Almost done! We want to print() each insect with a + // single method call here. +- ??? ++ insect.print(); + } + } + diff --git a/patches/patches/095_quiz_async.patch b/patches/patches/095_quiz_async.patch new file mode 100644 index 0000000..dbaae07 --- /dev/null +++ b/patches/patches/095_quiz_async.patch @@ -0,0 +1,52 @@ +--- exercises/095_quiz_async.zig 2026-04-03 18:04:53.577391455 +0200 ++++ answers/095_quiz_async.zig 2026-04-03 18:05:42.570392172 +0200 +@@ -51,7 +51,7 @@ + // Bug 1: The collector needs to lock before modifying + // shared state. What Mutex method acquires the lock? + self.mutex.lock(io) catch return; +- self.mutex.???(io) catch return; ++ defer self.mutex.unlock(io); + + switch (reading.sensor_type) { + .thermometer => self.temperature = reading.value, +@@ -79,9 +79,9 @@ + // Bug 2: io.async doesn't guarantee a separate thread. + // Which Io method guarantees true concurrency? + // (Don't forget: it can fail, so you need 'try'!) +- try sensors.???(io, sensor, .{ io, &queue, .thermometer, 20 }); +- try sensors.???(io, sensor, .{ io, &queue, .hygrometer, 60 }); +- try sensors.???(io, sensor, .{ io, &queue, .anemometer, 10 }); ++ try sensors.concurrent(io, sensor, .{ io, &queue, .thermometer, 20 }); ++ try sensors.concurrent(io, sensor, .{ io, &queue, .hygrometer, 60 }); ++ try sensors.concurrent(io, sensor, .{ io, &queue, .anemometer, 10 }); + + // Collector group: processes readings from the queue. + var collectors: std.Io.Group = .init; +@@ -90,7 +90,6 @@ + // Bug 3: Wait for ALL sensors to finish sending their readings. + // What Group method blocks until all tasks complete? + try sensors.await(io); +- // try sensors.???(io); + + // All sensors done — close the queue so the collector knows + // there's no more data coming. +@@ -104,8 +103,8 @@ + // + // Bug 4: Protect this section from cancellation. + // What Io method swaps the cancel protection state? +- const old_protection = io.???(.blocked); +- defer _ = io.???(old_protection); ++ const old_protection = io.swapCancelProtection(.blocked); ++ defer _ = io.swapCancelProtection(old_protection); + + printGardenReport(&weather); + } +@@ -127,7 +126,7 @@ + + // Bug 5: Send the reading into the queue. + // What Queue method sends a single element? +- queue.???(io, reading) catch return; ++ queue.putOne(io, reading) catch return; + } + } + diff --git a/patches/patches/093_hello_c.patch b/patches/patches/096_hello_c.patch index fe1f853..f5fe06f 100644 --- a/patches/patches/093_hello_c.patch +++ b/patches/patches/096_hello_c.patch @@ -1,5 +1,5 @@ ---- exercises/093_hello_c.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/093_hello_c.zig 2023-10-05 20:04:07.262770750 +0200 +--- exercises/096_hello_c.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/096_hello_c.zig 2026-04-03 13:09:26.195163128 +0200 @@ -54,7 +54,7 @@ // // In this exercise we use 'write' to output 17 chars, diff --git a/patches/patches/097_bit_manipulation.patch b/patches/patches/097_bit_manipulation.patch deleted file mode 100644 index 19ba876..0000000 --- a/patches/patches/097_bit_manipulation.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- 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; - - // What must be written here? -- ???; -+ x ^= y; - - print("x = {b}; y = {b}\n", .{ x, y }); - } diff --git a/patches/patches/094_c_math.patch b/patches/patches/097_c_math.patch index f8c7620..917fe6b 100644 --- a/patches/patches/094_c_math.patch +++ b/patches/patches/097_c_math.patch @@ -1,5 +1,5 @@ ---- exercises/094_c_math.zig 2024-02-28 12:50:35.789939935 +0100 -+++ answers/094_c_math.zig 2024-02-28 12:53:57.910309471 +0100 +--- exercises/097_c_math.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/097_c_math.zig 2026-04-03 13:09:32.059278502 +0200 @@ -26,7 +26,7 @@ const c = @cImport({ diff --git a/patches/patches/095_for3.patch b/patches/patches/098_for3.patch index a158b31..c280bc6 100644 --- a/patches/patches/095_for3.patch +++ b/patches/patches/098_for3.patch @@ -1,5 +1,5 @@ ---- exercises/095_for3.zig 2026-02-27 19:33:59 -+++ answers/095_for3.zig 2026-02-27 19:33:38 +--- exercises/098_for3.zig 2026-03-20 19:23:48.873150100 +0100 ++++ answers/098_for3.zig 2026-04-03 13:09:39.916433087 +0200 @@ -56,7 +56,7 @@ // I want to print every number between 1 and 20 that is NOT diff --git a/patches/patches/096_memory_allocation.patch b/patches/patches/099_memory_allocation.patch index c26eeeb..d83a0ae 100644 --- a/patches/patches/096_memory_allocation.patch +++ b/patches/patches/099_memory_allocation.patch @@ -1,5 +1,5 @@ ---- exercises/096_memory_allocation.zig 2023-11-21 14:55:33.805678390 +0100 -+++ answers/096_memory_allocation.zig 2023-11-21 14:56:00.236163484 +0100 +--- exercises/099_memory_allocation.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/099_memory_allocation.zig 2026-04-03 13:09:47.403580391 +0200 @@ -64,7 +64,7 @@ const allocator = arena.allocator(); diff --git a/patches/patches/100_bit_manipulation.patch b/patches/patches/100_bit_manipulation.patch new file mode 100644 index 0000000..f70cc41 --- /dev/null +++ b/patches/patches/100_bit_manipulation.patch @@ -0,0 +1,11 @@ +--- exercises/100_bit_manipulation.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/100_bit_manipulation.zig 2026-04-02 10:51:15.795831343 +0200 +@@ -80,7 +80,7 @@ + y ^= x; + + // What must be written here? +- ???; ++ x ^= y; + + print("x = {b}; y = {b}\n", .{ x, y }); + } diff --git a/patches/patches/098_bit_manipulation2.patch b/patches/patches/101_bit_manipulation2.patch index 5354a7b..5179272 100644 --- a/patches/patches/098_bit_manipulation2.patch +++ b/patches/patches/101_bit_manipulation2.patch @@ -1,5 +1,5 @@ ---- exercises/098_bit_manipulation2.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/098_bit_manipulation2.zig 2023-10-05 20:04:07.286104520 +0200 +--- exercises/101_bit_manipulation2.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/101_bit_manipulation2.zig 2026-04-02 10:51:15.797831382 +0200 @@ -60,5 +60,5 @@ // and if so, we know the given string is a pangram // diff --git a/patches/patches/099_formatting.patch b/patches/patches/102_formatting.patch index a56b556..dba8aef 100644 --- a/patches/patches/099_formatting.patch +++ b/patches/patches/102_formatting.patch @@ -1,5 +1,5 @@ ---- exercises/099_formatting.zig 2024-11-07 21:45:10.459123650 +0100 -+++ answers/099_formatting.zig 2024-11-07 21:43:55.154345991 +0100 +--- exercises/102_formatting.zig 2026-03-20 19:23:48.873150100 +0100 ++++ answers/102_formatting.zig 2026-04-02 10:51:15.799831421 +0200 @@ -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/103_for4.patch index ad73e9a..7a7e161 100644 --- a/patches/patches/100_for4.patch +++ b/patches/patches/103_for4.patch @@ -1,5 +1,5 @@ ---- exercises/100_for4.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/100_for4.zig 2023-10-05 20:04:07.296104707 +0200 +--- exercises/103_for4.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/103_for4.zig 2026-04-02 10:51:15.801831460 +0200 @@ -39,7 +39,7 @@ const hex_nums = [_]u8{ 0xb, 0x2a, 0x77 }; const dec_nums = [_]u8{ 11, 42, 119 }; diff --git a/patches/patches/101_for5.patch b/patches/patches/104_for5.patch index 00f19df..ef77013 100644 --- a/patches/patches/101_for5.patch +++ b/patches/patches/104_for5.patch @@ -1,5 +1,5 @@ ---- exercises/101_for5.zig 2023-10-03 22:15:22.125574535 +0200 -+++ answers/101_for5.zig 2023-10-05 20:04:07.299438103 +0200 +--- exercises/104_for5.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/104_for5.zig 2026-04-02 10:51:15.803831499 +0200 @@ -51,7 +51,7 @@ // We would like to number our list starting with 1, not 0. diff --git a/patches/patches/102_testing.patch b/patches/patches/105_testing.patch index 6d18bf6..069b72b 100644 --- a/patches/patches/102_testing.patch +++ b/patches/patches/105_testing.patch @@ -1,5 +1,5 @@ ---- exercises/102_testing.zig 2025-10-24 12:54:56 -+++ answers/102_testing.zig 2025-10-24 12:56:33 +--- exercises/105_testing.zig 2026-03-20 19:23:48.873150100 +0100 ++++ answers/105_testing.zig 2026-04-02 10:51:15.805831538 +0200 @@ -71,7 +71,7 @@ // The corresponding test is not much different from the previous one. Except // that it contains an error that you need to correct. diff --git a/patches/patches/103_tokenization.patch b/patches/patches/106_tokenization.patch index 941ca3b..4792df6 100644 --- a/patches/patches/103_tokenization.patch +++ b/patches/patches/106_tokenization.patch @@ -1,5 +1,5 @@ ---- exercises/103_tokenization.zig 2026-02-27 19:25:11 -+++ answers/103_tokenization.zig 2026-02-27 19:26:04 +--- exercises/106_tokenization.zig 2026-03-20 19:23:48.873150100 +0100 ++++ answers/106_tokenization.zig 2026-04-02 10:51:15.807831578 +0200 @@ -134,7 +134,7 @@ ; diff --git a/patches/patches/104_threading.patch b/patches/patches/107_threading.patch index eda25fd..3f65ef4 100644 --- a/patches/patches/104_threading.patch +++ b/patches/patches/107_threading.patch @@ -1,6 +1,6 @@ ---- exercises/104_threading.zig 2025-11-28 14:17:31.552529679 +0100 -+++ answers/104_threading.zig 2025-11-28 14:15:36.823931851 +0100 -@@ -97,12 +97,12 @@ +--- exercises/107_threading.zig 2026-04-01 23:31:10.073198955 +0200 ++++ answers/107_threading.zig 2026-04-02 10:51:15.809831617 +0200 +@@ -88,12 +88,12 @@ defer handle.join(); // Second thread diff --git a/patches/patches/105_threading2.patch b/patches/patches/108_threading2.patch index dfa5613..d71f254 100644 --- a/patches/patches/105_threading2.patch +++ b/patches/patches/108_threading2.patch @@ -1,5 +1,5 @@ ---- exercises/105_threading2.zig 2024-03-23 16:35:14.754540802 +0100 -+++ answers/105_threading2.zig 2024-03-23 16:38:00.577539733 +0100 +--- exercises/108_threading2.zig 2025-08-15 15:17:57.839348063 +0200 ++++ answers/108_threading2.zig 2026-04-02 10:51:15.811831656 +0200 @@ -81,8 +81,8 @@ defer handle1.join(); diff --git a/patches/patches/106_files.patch b/patches/patches/109_files.patch index 27bcb56..ac59d70 100644 --- a/patches/patches/106_files.patch +++ b/patches/patches/109_files.patch @@ -1,5 +1,5 @@ ---- exercises/106_files.zig 2026-01-09 22:41:19.373872684 +0100 -+++ answers/106_files.zig 2026-01-09 22:41:44.518372910 +0100 +--- exercises/109_files.zig 2026-03-20 19:23:48.874150121 +0100 ++++ answers/109_files.zig 2026-04-02 10:51:15.813831695 +0200 @@ -41,7 +41,7 @@ // by doing nothing // diff --git a/patches/patches/107_files2.patch b/patches/patches/110_files2.patch index 6820742..64dc193 100644 --- a/patches/patches/107_files2.patch +++ b/patches/patches/110_files2.patch @@ -1,5 +1,5 @@ ---- exercises/107_files2.zig 2026-01-09 22:43:15.211177186 +0100 -+++ answers/107_files2.zig 2026-01-09 22:42:48.943654602 +0100 +--- exercises/110_files2.zig 2026-03-20 19:23:48.874150121 +0100 ++++ answers/110_files2.zig 2026-04-02 10:51:15.815831734 +0200 @@ -39,7 +39,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 diff --git a/patches/patches/108_labeled_switch.patch b/patches/patches/111_labeled_switch.patch index fa9dd67..0fb872d 100644 --- a/patches/patches/108_labeled_switch.patch +++ b/patches/patches/111_labeled_switch.patch @@ -1,6 +1,6 @@ ---- exercises/108_labeled_switch.zig 2024-09-20 12:09:24.370066539 +0200 -+++ answers/108_labeled_switch.zig 2024-09-20 12:09:06.499711739 +0200 -@@ -65,13 +65,13 @@ +--- exercises/111_labeled_switch.zig 2025-08-15 15:17:57.840348083 +0200 ++++ answers/111_labeled_switch.zig 2026-04-02 10:51:15.817831773 +0200 +@@ -67,13 +67,13 @@ // how would you fix it? pr: switch (PullRequestState.Draft) { PullRequestState.Draft => continue :pr PullRequestState.InReview, diff --git a/patches/patches/109_vectors.patch b/patches/patches/112_vectors.patch index bf18cc0..5bf684b 100644 --- a/patches/patches/109_vectors.patch +++ b/patches/patches/112_vectors.patch @@ -1,5 +1,5 @@ ---- exercises/109_vectors.zig 2024-11-07 14:57:09.673383618 +0100 -+++ answers/109_vectors.zig 2024-11-07 14:22:59.069150138 +0100 +--- exercises/112_vectors.zig 2025-08-15 15:17:57.840348083 +0200 ++++ answers/112_vectors.zig 2026-04-02 10:51:15.819831812 +0200 @@ -121,8 +121,8 @@ const Vec4 = @Vector(4, f32); diff --git a/patches/patches/110_quiz9.patch b/patches/patches/113_quiz9.patch index 9d9b864..03bd572 100644 --- a/patches/patches/110_quiz9.patch +++ b/patches/patches/113_quiz9.patch @@ -1,6 +1,6 @@ ---- 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 @@ +--- exercises/113_quiz9.zig 2025-08-15 15:17:57.840348083 +0200 ++++ answers/113_quiz9.zig 2026-04-02 10:51:15.821831851 +0200 +@@ -84,7 +84,7 @@ PORTB = 0b1100; print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB}); print("^ {b:0>4} // (bitmask)\n", .{0b0101}); @@ -9,7 +9,7 @@ checkAnswer(0b1001, PORTB); newline(); -@@ -116,7 +116,7 @@ +@@ -92,7 +92,7 @@ PORTB = 0b1100; print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB}); print("^ {b:0>4} // (bitmask)\n", .{0b0011}); @@ -18,7 +18,7 @@ checkAnswer(0b1111, PORTB); newline(); -@@ -170,7 +170,7 @@ +@@ -103,7 +103,7 @@ PORTB = 0b1001; // reset PORTB print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB}); print("| {b:0>4} // (bitmask)\n", .{0b0100}); @@ -27,7 +27,7 @@ checkAnswer(0b1101, PORTB); newline(); -@@ -178,7 +178,7 @@ +@@ -111,7 +111,7 @@ PORTB = 0b1001; // reset PORTB print(" {b:0>4} // (reset state)\n", .{PORTB}); print("| {b:0>4} // (bitmask)\n", .{0b0100}); @@ -36,7 +36,7 @@ checkAnswer(0b1101, PORTB); newline(); -@@ -269,7 +269,7 @@ +@@ -122,7 +122,7 @@ PORTB = 0b1110; // reset PORTB print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB}); print("& {b:0>4} // (bitmask)\n", .{0b1011}); @@ -45,7 +45,7 @@ checkAnswer(0b1010, PORTB); newline(); -@@ -277,7 +277,7 @@ +@@ -130,7 +130,7 @@ PORTB = 0b0111; // reset PORTB print(" {b:0>4} // (reset state)\n", .{PORTB}); print("& {b:0>4} // (bitmask)\n", .{0b1110}); diff --git a/patches/patches/111_packed.patch b/patches/patches/114_packed.patch index d38ac68..3c79f18 100644 --- a/patches/patches/111_packed.patch +++ b/patches/patches/114_packed.patch @@ -1,5 +1,5 @@ ---- exercises/111_packed.zig 2026-03-13 11:18:44 -+++ answers/111_packed.zig 2026-03-13 11:18:57 +--- exercises/114_packed.zig 2026-03-20 19:23:48.874150121 +0100 ++++ answers/114_packed.zig 2026-04-02 10:51:15.824831910 +0200 @@ -41,7 +41,7 @@ const PackedStruct = packed struct { diff --git a/patches/patches/112_packed2.patch b/patches/patches/115_packed2.patch index 9b01eb3..81c32ab 100644 --- a/patches/patches/112_packed2.patch +++ b/patches/patches/115_packed2.patch @@ -1,5 +1,5 @@ ---- exercises/112_packed2.zig 2026-03-13 11:14:08 -+++ answers/112_packed2.zig 2026-03-13 11:14:16 +--- exercises/115_packed2.zig 2026-03-20 19:23:48.874150121 +0100 ++++ answers/115_packed2.zig 2026-04-02 10:51:15.826831949 +0200 @@ -13,9 +13,9 @@ const s: S = .{ .a = true, .b = -1 }; switch (s) { |
