mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-06-08 07:50:00 +00:00
Insert space for additional async exercises
This commit is contained in:
64
build.zig
64
build.zig
@@ -1153,17 +1153,29 @@ const exercises = [_]Exercise{
|
|||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "090_async7.zig",
|
.main_file = "090_async7.zig",
|
||||||
.output = "Counter: 400 (expected: 400)",
|
.output = "Counter: 400",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "091_async8.zig",
|
.main_file = "091_async8.zig",
|
||||||
.output = "ABCDEF",
|
.output = "Sum of 1..10 = 55",
|
||||||
.skip = true,
|
|
||||||
.skip_hint = "async has not been implemented in the current compiler version.",
|
|
||||||
},
|
},
|
||||||
|
|
||||||
.{
|
.{
|
||||||
.main_file = "092_interfaces.zig",
|
.main_file = "092_async9.zig",
|
||||||
|
.output = "",
|
||||||
|
.skip = true,
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.main_file = "093_async10.zig",
|
||||||
|
.output = "",
|
||||||
|
.skip = true,
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.main_file = "094_async_quiz.zig",
|
||||||
|
.output = "",
|
||||||
|
.skip = true,
|
||||||
|
},
|
||||||
|
.{
|
||||||
|
.main_file = "095_interfaces.zig",
|
||||||
.output =
|
.output =
|
||||||
\\Daily Insect Report:
|
\\Daily Insect Report:
|
||||||
\\Ant is alive.
|
\\Ant is alive.
|
||||||
@@ -1172,33 +1184,33 @@ const exercises = [_]Exercise{
|
|||||||
, // pay attention to the comma
|
, // pay attention to the comma
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "093_hello_c.zig",
|
.main_file = "096_hello_c.zig",
|
||||||
.output = "Hello C from Zig! - C result is 17 chars written.",
|
.output = "Hello C from Zig! - C result is 17 chars written.",
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "094_c_math.zig",
|
.main_file = "097_c_math.zig",
|
||||||
.output = "The normalized angle of 765.2 degrees is 45.2 degrees.",
|
.output = "The normalized angle of 765.2 degrees is 45.2 degrees.",
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "095_for3.zig",
|
.main_file = "098_for3.zig",
|
||||||
.output = "1 2 4 7 8 11 13 14 16 17 19\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15",
|
.output = "1 2 4 7 8 11 13 14 16 17 19\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "096_memory_allocation.zig",
|
.main_file = "099_memory_allocation.zig",
|
||||||
.output = "Running Average: 0.30 0.25 0.20 0.18 0.22",
|
.output = "Running Average: 0.30 0.25 0.20 0.18 0.22",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "097_bit_manipulation.zig",
|
.main_file = "100_bit_manipulation.zig",
|
||||||
.output = "x = 1011; y = 1101",
|
.output = "x = 1011; y = 1101",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "098_bit_manipulation2.zig",
|
.main_file = "101_bit_manipulation2.zig",
|
||||||
.output = "Is this a pangram? true!",
|
.output = "Is this a pangram? true!",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "099_formatting.zig",
|
.main_file = "102_formatting.zig",
|
||||||
.output =
|
.output =
|
||||||
\\
|
\\
|
||||||
\\ X | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
\\ X | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||||
@@ -1235,11 +1247,11 @@ const exercises = [_]Exercise{
|
|||||||
,
|
,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "100_for4.zig",
|
.main_file = "103_for4.zig",
|
||||||
.output = "Arrays match!",
|
.output = "Arrays match!",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "101_for5.zig",
|
.main_file = "104_for5.zig",
|
||||||
.output =
|
.output =
|
||||||
\\1. Wizard (Gold: 25, XP: 40)
|
\\1. Wizard (Gold: 25, XP: 40)
|
||||||
\\2. Bard (Gold: 11, XP: 17)
|
\\2. Bard (Gold: 11, XP: 17)
|
||||||
@@ -1248,12 +1260,12 @@ const exercises = [_]Exercise{
|
|||||||
, // pay attention to the comma
|
, // pay attention to the comma
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "102_testing.zig",
|
.main_file = "105_testing.zig",
|
||||||
.output = "",
|
.output = "",
|
||||||
.kind = .@"test",
|
.kind = .@"test",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "103_tokenization.zig",
|
.main_file = "106_tokenization.zig",
|
||||||
.output =
|
.output =
|
||||||
\\My
|
\\My
|
||||||
\\name
|
\\name
|
||||||
@@ -1274,7 +1286,7 @@ const exercises = [_]Exercise{
|
|||||||
, // pay attention to the comma
|
, // pay attention to the comma
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "104_threading.zig",
|
.main_file = "107_threading.zig",
|
||||||
.output =
|
.output =
|
||||||
\\Starting work...
|
\\Starting work...
|
||||||
\\thread 1: started.
|
\\thread 1: started.
|
||||||
@@ -1288,32 +1300,32 @@ const exercises = [_]Exercise{
|
|||||||
, // pay attention to the comma
|
, // pay attention to the comma
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "105_threading2.zig",
|
.main_file = "108_threading2.zig",
|
||||||
.output = "PI ≈ 3.14159265",
|
.output = "PI ≈ 3.14159265",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "106_files.zig",
|
.main_file = "109_files.zig",
|
||||||
.output = "Successfully wrote 18 bytes.",
|
.output = "Successfully wrote 18 bytes.",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "107_files2.zig",
|
.main_file = "110_files2.zig",
|
||||||
.output =
|
.output =
|
||||||
\\AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
\\AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||||
\\Successfully Read 18 bytes: It's zigling time!
|
\\Successfully Read 18 bytes: It's zigling time!
|
||||||
, // pay attention to the comma
|
, // pay attention to the comma
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "108_labeled_switch.zig",
|
.main_file = "111_labeled_switch.zig",
|
||||||
.output = "The pull request has been merged.",
|
.output = "The pull request has been merged.",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "109_vectors.zig",
|
.main_file = "112_vectors.zig",
|
||||||
.output =
|
.output =
|
||||||
\\Max difference (old fn): 0.014
|
\\Max difference (old fn): 0.014
|
||||||
\\Max difference (new fn): 0.014
|
\\Max difference (new fn): 0.014
|
||||||
, // pay attention to the comma
|
, // pay attention to the comma
|
||||||
},
|
},
|
||||||
.{ .main_file = "110_quiz9.zig", .output =
|
.{ .main_file = "113_quiz9.zig", .output =
|
||||||
\\Toggle pins with XOR on PORTB
|
\\Toggle pins with XOR on PORTB
|
||||||
\\-----------------------------
|
\\-----------------------------
|
||||||
\\ 1100 // (initial state of PORTB)
|
\\ 1100 // (initial state of PORTB)
|
||||||
@@ -1345,11 +1357,11 @@ const exercises = [_]Exercise{
|
|||||||
\\= 0110
|
\\= 0110
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "111_packed.zig",
|
.main_file = "114_packed.zig",
|
||||||
.output = "",
|
.output = "",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.main_file = "112_packed2.zig",
|
.main_file = "115_packed2.zig",
|
||||||
.output = "",
|
.output = "",
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub fn main(init: std.process.Init) !void {
|
|||||||
|
|
||||||
try group.await(io);
|
try group.await(io);
|
||||||
|
|
||||||
print("Counter: {} (expected: 400)\n", .{state.counter});
|
print("Counter: {}\n", .{state.counter});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increment(io: std.Io, state: *SharedState, times: u32) void {
|
fn increment(io: std.Io, state: *SharedState, times: u32) void {
|
||||||
|
|||||||
@@ -1,35 +1,62 @@
|
|||||||
//
|
//
|
||||||
// You have doubtless noticed that 'suspend' requires a block
|
// Tasks often need to communicate! Io provides Queue for this —
|
||||||
// expression like so:
|
// a bounded, thread-safe channel for passing data between tasks:
|
||||||
//
|
//
|
||||||
// suspend {}
|
// var backing: [16]u32 = undefined;
|
||||||
|
// var queue: std.Io.Queue(u32) = .init(&backing);
|
||||||
//
|
//
|
||||||
// The suspend block executes when a function suspends. To get
|
// // Producer task:
|
||||||
// sense for when this happens, please make the following
|
// try queue.putOne(io, value); // blocks if queue is full
|
||||||
// program print the string
|
|
||||||
//
|
//
|
||||||
// "ABCDEF"
|
// // Consumer task:
|
||||||
|
// const val = try queue.getOne(io); // blocks if queue is empty
|
||||||
//
|
//
|
||||||
const print = @import("std").debug.print;
|
// When the producer is done, it calls queue.close(io) to signal
|
||||||
|
// that no more data is coming. After that, getOne() will return
|
||||||
|
// error.Closed once the queue is drained.
|
||||||
|
//
|
||||||
|
// This is the classic producer/consumer pattern — one task
|
||||||
|
// generates work, another processes it, and the queue handles
|
||||||
|
// all the synchronization automatically.
|
||||||
|
//
|
||||||
|
// Fix this program: the producer sends numbers 1..10, the
|
||||||
|
// consumer sums them up. The expected sum is 55.
|
||||||
|
//
|
||||||
|
const std = @import("std");
|
||||||
|
const print = std.debug.print;
|
||||||
|
|
||||||
pub fn main() void {
|
pub fn main(init: std.process.Init) !void {
|
||||||
print("A", .{});
|
const io = init.io;
|
||||||
|
|
||||||
var frame = async suspendable();
|
var backing: [4]u32 = undefined;
|
||||||
|
var queue: std.Io.Queue(u32) = .init(&backing);
|
||||||
|
|
||||||
print("X", .{});
|
var group: std.Io.Group = .init;
|
||||||
|
|
||||||
resume frame;
|
group.async(io, producer, .{ io, &queue });
|
||||||
|
group.async(io, consumer, .{ io, &queue });
|
||||||
|
|
||||||
print("F", .{});
|
try group.await(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn suspendable() void {
|
fn producer(io: std.Io, queue: *std.Io.Queue(u32)) void {
|
||||||
print("X", .{});
|
// Send numbers 1 through 10 into the queue.
|
||||||
|
for (1..11) |i| {
|
||||||
suspend {
|
// What Queue method sends a single element, blocking if full?
|
||||||
print("X", .{});
|
queue.???(io, @intCast(i)) catch return;
|
||||||
}
|
}
|
||||||
|
// Signal that we're done sending.
|
||||||
print("X", .{});
|
queue.close(io);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn consumer(io: std.Io, queue: *std.Io.Queue(u32)) void {
|
||||||
|
var sum: u32 = 0;
|
||||||
|
while (true) {
|
||||||
|
const value = queue.getOne(io) catch |err| switch (err) {
|
||||||
|
error.Closed => break,
|
||||||
|
error.Canceled => return,
|
||||||
|
};
|
||||||
|
sum += value;
|
||||||
|
}
|
||||||
|
print("Sum of 1..10 = {}\n", .{sum});
|
||||||
}
|
}
|
||||||
|
|||||||
11
patches/patches/091_async8.patch
Normal file
11
patches/patches/091_async8.patch
Normal file
@@ -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);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/092_interfaces.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/095_interfaces.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/092_interfaces.zig 2023-10-05 20:04:07.259437354 +0200
|
+++ answers/095_interfaces.zig 2026-04-03 13:09:13.722917764 +0200
|
||||||
@@ -106,7 +106,7 @@
|
@@ -106,7 +106,7 @@
|
||||||
for (my_insects) |insect| {
|
for (my_insects) |insect| {
|
||||||
// Almost done! We want to print() each insect with a
|
// Almost done! We want to print() each insect with a
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/093_hello_c.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/096_hello_c.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/093_hello_c.zig 2023-10-05 20:04:07.262770750 +0200
|
+++ answers/096_hello_c.zig 2026-04-03 13:09:26.195163128 +0200
|
||||||
@@ -54,7 +54,7 @@
|
@@ -54,7 +54,7 @@
|
||||||
//
|
//
|
||||||
// In this exercise we use 'write' to output 17 chars,
|
// In this exercise we use 'write' to output 17 chars,
|
||||||
@@ -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 });
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/094_c_math.zig 2024-02-28 12:50:35.789939935 +0100
|
--- exercises/097_c_math.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/094_c_math.zig 2024-02-28 12:53:57.910309471 +0100
|
+++ answers/097_c_math.zig 2026-04-03 13:09:32.059278502 +0200
|
||||||
@@ -26,7 +26,7 @@
|
@@ -26,7 +26,7 @@
|
||||||
|
|
||||||
const c = @cImport({
|
const c = @cImport({
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/095_for3.zig 2026-02-27 19:33:59
|
--- exercises/098_for3.zig 2026-03-20 19:23:48.873150100 +0100
|
||||||
+++ answers/095_for3.zig 2026-02-27 19:33:38
|
+++ answers/098_for3.zig 2026-04-03 13:09:39.916433087 +0200
|
||||||
@@ -56,7 +56,7 @@
|
@@ -56,7 +56,7 @@
|
||||||
|
|
||||||
// I want to print every number between 1 and 20 that is NOT
|
// I want to print every number between 1 and 20 that is NOT
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/096_memory_allocation.zig 2023-11-21 14:55:33.805678390 +0100
|
--- exercises/099_memory_allocation.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/096_memory_allocation.zig 2023-11-21 14:56:00.236163484 +0100
|
+++ answers/099_memory_allocation.zig 2026-04-03 13:09:47.403580391 +0200
|
||||||
@@ -64,7 +64,7 @@
|
@@ -64,7 +64,7 @@
|
||||||
const allocator = arena.allocator();
|
const allocator = arena.allocator();
|
||||||
|
|
||||||
11
patches/patches/100_bit_manipulation.patch
Normal file
11
patches/patches/100_bit_manipulation.patch
Normal file
@@ -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 });
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/098_bit_manipulation2.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/101_bit_manipulation2.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/098_bit_manipulation2.zig 2023-10-05 20:04:07.286104520 +0200
|
+++ answers/101_bit_manipulation2.zig 2026-04-02 10:51:15.797831382 +0200
|
||||||
@@ -60,5 +60,5 @@
|
@@ -60,5 +60,5 @@
|
||||||
// and if so, we know the given string is a pangram
|
// and if so, we know the given string is a pangram
|
||||||
//
|
//
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/099_formatting.zig 2024-11-07 21:45:10.459123650 +0100
|
--- exercises/102_formatting.zig 2026-03-20 19:23:48.873150100 +0100
|
||||||
+++ answers/099_formatting.zig 2024-11-07 21:43:55.154345991 +0100
|
+++ answers/102_formatting.zig 2026-04-02 10:51:15.799831421 +0200
|
||||||
@@ -131,7 +131,7 @@
|
@@ -131,7 +131,7 @@
|
||||||
for (0..size) |b| {
|
for (0..size) |b| {
|
||||||
// What formatting is needed here to make our columns
|
// What formatting is needed here to make our columns
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/100_for4.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/103_for4.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/100_for4.zig 2023-10-05 20:04:07.296104707 +0200
|
+++ answers/103_for4.zig 2026-04-02 10:51:15.801831460 +0200
|
||||||
@@ -39,7 +39,7 @@
|
@@ -39,7 +39,7 @@
|
||||||
const hex_nums = [_]u8{ 0xb, 0x2a, 0x77 };
|
const hex_nums = [_]u8{ 0xb, 0x2a, 0x77 };
|
||||||
const dec_nums = [_]u8{ 11, 42, 119 };
|
const dec_nums = [_]u8{ 11, 42, 119 };
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/101_for5.zig 2023-10-03 22:15:22.125574535 +0200
|
--- exercises/104_for5.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/101_for5.zig 2023-10-05 20:04:07.299438103 +0200
|
+++ answers/104_for5.zig 2026-04-02 10:51:15.803831499 +0200
|
||||||
@@ -51,7 +51,7 @@
|
@@ -51,7 +51,7 @@
|
||||||
|
|
||||||
// We would like to number our list starting with 1, not 0.
|
// We would like to number our list starting with 1, not 0.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/102_testing.zig 2025-10-24 12:54:56
|
--- exercises/105_testing.zig 2026-03-20 19:23:48.873150100 +0100
|
||||||
+++ answers/102_testing.zig 2025-10-24 12:56:33
|
+++ answers/105_testing.zig 2026-04-02 10:51:15.805831538 +0200
|
||||||
@@ -71,7 +71,7 @@
|
@@ -71,7 +71,7 @@
|
||||||
// The corresponding test is not much different from the previous one. Except
|
// The corresponding test is not much different from the previous one. Except
|
||||||
// that it contains an error that you need to correct.
|
// that it contains an error that you need to correct.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/103_tokenization.zig 2026-02-27 19:25:11
|
--- exercises/106_tokenization.zig 2026-03-20 19:23:48.873150100 +0100
|
||||||
+++ answers/103_tokenization.zig 2026-02-27 19:26:04
|
+++ answers/106_tokenization.zig 2026-04-02 10:51:15.807831578 +0200
|
||||||
@@ -134,7 +134,7 @@
|
@@ -134,7 +134,7 @@
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/104_threading.zig 2026-04-01 23:31:10.073198955 +0200
|
--- exercises/107_threading.zig 2026-04-01 23:31:10.073198955 +0200
|
||||||
+++ answers/104_threading.zig 2026-04-01 23:29:51.314585919 +0200
|
+++ answers/107_threading.zig 2026-04-02 10:51:15.809831617 +0200
|
||||||
@@ -88,12 +88,12 @@
|
@@ -88,12 +88,12 @@
|
||||||
defer handle.join();
|
defer handle.join();
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/105_threading2.zig 2024-03-23 16:35:14.754540802 +0100
|
--- exercises/108_threading2.zig 2025-08-15 15:17:57.839348063 +0200
|
||||||
+++ answers/105_threading2.zig 2024-03-23 16:38:00.577539733 +0100
|
+++ answers/108_threading2.zig 2026-04-02 10:51:15.811831656 +0200
|
||||||
@@ -81,8 +81,8 @@
|
@@ -81,8 +81,8 @@
|
||||||
defer handle1.join();
|
defer handle1.join();
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/106_files.zig 2026-01-09 22:41:19.373872684 +0100
|
--- exercises/109_files.zig 2026-03-20 19:23:48.874150121 +0100
|
||||||
+++ answers/106_files.zig 2026-01-09 22:41:44.518372910 +0100
|
+++ answers/109_files.zig 2026-04-02 10:51:15.813831695 +0200
|
||||||
@@ -41,7 +41,7 @@
|
@@ -41,7 +41,7 @@
|
||||||
// by doing nothing
|
// by doing nothing
|
||||||
//
|
//
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/107_files2.zig 2026-01-09 22:43:15.211177186 +0100
|
--- exercises/110_files2.zig 2026-03-20 19:23:48.874150121 +0100
|
||||||
+++ answers/107_files2.zig 2026-01-09 22:42:48.943654602 +0100
|
+++ answers/110_files2.zig 2026-04-02 10:51:15.815831734 +0200
|
||||||
@@ -39,7 +39,7 @@
|
@@ -39,7 +39,7 @@
|
||||||
// initialize 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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
--- exercises/108_labeled_switch.zig 2024-09-20 12:09:24.370066539 +0200
|
--- exercises/111_labeled_switch.zig 2025-08-15 15:17:57.840348083 +0200
|
||||||
+++ answers/108_labeled_switch.zig 2024-09-20 12:09:06.499711739 +0200
|
+++ answers/111_labeled_switch.zig 2026-04-02 10:51:15.817831773 +0200
|
||||||
@@ -65,13 +65,13 @@
|
@@ -67,13 +67,13 @@
|
||||||
// how would you fix it?
|
// how would you fix it?
|
||||||
pr: switch (PullRequestState.Draft) {
|
pr: switch (PullRequestState.Draft) {
|
||||||
PullRequestState.Draft => continue :pr PullRequestState.InReview,
|
PullRequestState.Draft => continue :pr PullRequestState.InReview,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/109_vectors.zig 2024-11-07 14:57:09.673383618 +0100
|
--- exercises/112_vectors.zig 2025-08-15 15:17:57.840348083 +0200
|
||||||
+++ answers/109_vectors.zig 2024-11-07 14:22:59.069150138 +0100
|
+++ answers/112_vectors.zig 2026-04-02 10:51:15.819831812 +0200
|
||||||
@@ -121,8 +121,8 @@
|
@@ -121,8 +121,8 @@
|
||||||
|
|
||||||
const Vec4 = @Vector(4, f32);
|
const Vec4 = @Vector(4, f32);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
--- exercises/110_quiz9.zig 2025-02-08 13:19:48.522641785 -0800
|
--- exercises/113_quiz9.zig 2025-08-15 15:17:57.840348083 +0200
|
||||||
+++ answers/110_quiz9.zig 2025-02-10 17:42:04.525004335 -0800
|
+++ answers/113_quiz9.zig 2026-04-02 10:51:15.821831851 +0200
|
||||||
@@ -108,7 +108,7 @@
|
@@ -84,7 +84,7 @@
|
||||||
PORTB = 0b1100;
|
PORTB = 0b1100;
|
||||||
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
||||||
print("^ {b:0>4} // (bitmask)\n", .{0b0101});
|
print("^ {b:0>4} // (bitmask)\n", .{0b0101});
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
checkAnswer(0b1001, PORTB);
|
checkAnswer(0b1001, PORTB);
|
||||||
|
|
||||||
newline();
|
newline();
|
||||||
@@ -116,7 +116,7 @@
|
@@ -92,7 +92,7 @@
|
||||||
PORTB = 0b1100;
|
PORTB = 0b1100;
|
||||||
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
||||||
print("^ {b:0>4} // (bitmask)\n", .{0b0011});
|
print("^ {b:0>4} // (bitmask)\n", .{0b0011});
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
checkAnswer(0b1111, PORTB);
|
checkAnswer(0b1111, PORTB);
|
||||||
|
|
||||||
newline();
|
newline();
|
||||||
@@ -170,7 +170,7 @@
|
@@ -103,7 +103,7 @@
|
||||||
PORTB = 0b1001; // reset PORTB
|
PORTB = 0b1001; // reset PORTB
|
||||||
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
||||||
print("| {b:0>4} // (bitmask)\n", .{0b0100});
|
print("| {b:0>4} // (bitmask)\n", .{0b0100});
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
checkAnswer(0b1101, PORTB);
|
checkAnswer(0b1101, PORTB);
|
||||||
|
|
||||||
newline();
|
newline();
|
||||||
@@ -178,7 +178,7 @@
|
@@ -111,7 +111,7 @@
|
||||||
PORTB = 0b1001; // reset PORTB
|
PORTB = 0b1001; // reset PORTB
|
||||||
print(" {b:0>4} // (reset state)\n", .{PORTB});
|
print(" {b:0>4} // (reset state)\n", .{PORTB});
|
||||||
print("| {b:0>4} // (bitmask)\n", .{0b0100});
|
print("| {b:0>4} // (bitmask)\n", .{0b0100});
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
checkAnswer(0b1101, PORTB);
|
checkAnswer(0b1101, PORTB);
|
||||||
|
|
||||||
newline();
|
newline();
|
||||||
@@ -269,7 +269,7 @@
|
@@ -122,7 +122,7 @@
|
||||||
PORTB = 0b1110; // reset PORTB
|
PORTB = 0b1110; // reset PORTB
|
||||||
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
|
||||||
print("& {b:0>4} // (bitmask)\n", .{0b1011});
|
print("& {b:0>4} // (bitmask)\n", .{0b1011});
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
checkAnswer(0b1010, PORTB);
|
checkAnswer(0b1010, PORTB);
|
||||||
|
|
||||||
newline();
|
newline();
|
||||||
@@ -277,7 +277,7 @@
|
@@ -130,7 +130,7 @@
|
||||||
PORTB = 0b0111; // reset PORTB
|
PORTB = 0b0111; // reset PORTB
|
||||||
print(" {b:0>4} // (reset state)\n", .{PORTB});
|
print(" {b:0>4} // (reset state)\n", .{PORTB});
|
||||||
print("& {b:0>4} // (bitmask)\n", .{0b1110});
|
print("& {b:0>4} // (bitmask)\n", .{0b1110});
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/111_packed.zig 2026-03-13 11:18:44
|
--- exercises/114_packed.zig 2026-03-20 19:23:48.874150121 +0100
|
||||||
+++ answers/111_packed.zig 2026-03-13 11:18:57
|
+++ answers/114_packed.zig 2026-04-02 10:51:15.824831910 +0200
|
||||||
@@ -41,7 +41,7 @@
|
@@ -41,7 +41,7 @@
|
||||||
|
|
||||||
const PackedStruct = packed struct {
|
const PackedStruct = packed struct {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
--- exercises/112_packed2.zig 2026-03-13 11:14:08
|
--- exercises/115_packed2.zig 2026-03-20 19:23:48.874150121 +0100
|
||||||
+++ answers/112_packed2.zig 2026-03-13 11:14:16
|
+++ answers/115_packed2.zig 2026-04-02 10:51:15.826831949 +0200
|
||||||
@@ -13,9 +13,9 @@
|
@@ -13,9 +13,9 @@
|
||||||
const s: S = .{ .a = true, .b = -1 };
|
const s: S = .{ .a = true, .b = -1 };
|
||||||
switch (s) {
|
switch (s) {
|
||||||
Reference in New Issue
Block a user