mirror of
https://codeberg.org/ziglings/exercises.git
synced 2026-07-28 18:25:16 +00:00
Merge branch 'main' into make-threading-mathier
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- exercises/005_arrays2.zig 2026-05-04 16:26:32.778330847 +0200
|
||||
+++ answers/005_arrays2.zig 2026-05-04 16:26:13.082917974 +0200
|
||||
@@ -21,12 +21,12 @@
|
||||
--- exercises/005_arrays2.zig 2026-06-27 09:03:29.918124920 +0000
|
||||
+++ answers/005_arrays2.zig 2026-06-27 09:01:13.162138431 +0000
|
||||
@@ -21,15 +21,15 @@
|
||||
// (Problem 1)
|
||||
// Please set this array concatenating the two arrays above.
|
||||
// It should result in: 1 3 3 7
|
||||
@@ -10,8 +10,12 @@
|
||||
// (Problem 2)
|
||||
// Please set this array using repetition.
|
||||
// It should result in: 1 0 0 1 1 0 0 1 1 0 0 1
|
||||
- const bit_pattern_unit = [_]u8{ ??? };
|
||||
- const bit_pattern_unit = ???;
|
||||
+ const bit_pattern_unit = [_]u8{ 1, 0, 0, 1 };
|
||||
const bit_pattern: [3 * bit_pattern_unit.len]u8 = @bitCast(@as([3][bit_pattern_unit.len]u8, @splat(bit_pattern_unit)));
|
||||
|
||||
// Okay, that's all of the problems. Let's see the results.
|
||||
// How long should the bit pattern be?
|
||||
- const len = ???;
|
||||
+ const len = 3 * bit_pattern_unit.len;
|
||||
|
||||
// For now, don't worry about the use of SIMD.
|
||||
const bit_pattern: [len]u8 = std.simd.repeat(len, bit_pattern_unit);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- exercises/047_methods.zig 2023-10-03 22:15:22.122241138 +0200
|
||||
+++ answers/047_methods.zig 2023-10-05 20:04:07.056100214 +0200
|
||||
@@ -88,7 +88,7 @@
|
||||
--- exercises/047_methods.zig 2026-06-21 16:11:59.110876971 +0200
|
||||
+++ answers/047_methods.zig 2026-06-21 16:13:07.066363558 +0200
|
||||
@@ -106,7 +106,7 @@
|
||||
for (&aliens) |*alien| {
|
||||
|
||||
// *** Zap the alien with the heat ray here! ***
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
//
|
||||
// The fix for this is very subtle, but it makes a big
|
||||
// difference!
|
||||
- const Type2 = narcissus.fetchTheMostBeautifulType();
|
||||
+ const Type2 = Narcissus.fetchTheMostBeautifulType();
|
||||
- const Type2 = narcissus.FetchTheMostBeautifulType();
|
||||
+ const Type2 = Narcissus.FetchTheMostBeautifulType();
|
||||
|
||||
// Now we print a pithy statement about Narcissus.
|
||||
print("A {s} loves all {s}es. ", .{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
--- exercises/109_files.zig 2026-03-20 19:23:48.874150121 +0100
|
||||
+++ answers/109_files.zig 2026-04-02 10:51:15.813831695 +0200
|
||||
--- exercises/109_files.zig 2026-06-29 17:08:04.124224900 +0000
|
||||
+++ answers/109_files.zig 2026-06-29 17:13:20.696220533 +0000
|
||||
@@ -41,7 +41,7 @@
|
||||
// by doing nothing
|
||||
//
|
||||
@@ -9,6 +9,15 @@
|
||||
// if there's any other unexpected error we just propagate it through
|
||||
else => return e,
|
||||
};
|
||||
@@ -50,7 +50,7 @@
|
||||
// wait a minute...
|
||||
// opening a directory might fail!
|
||||
// what should we do here?
|
||||
- var output_dir: std.Io.Dir = cwd.openDir(io, "output", .{});
|
||||
+ var output_dir: std.Io.Dir = try cwd.openDir(io, "output", .{});
|
||||
defer output_dir.close(io);
|
||||
|
||||
// we try to open the file `zigling.txt`,
|
||||
@@ -61,7 +61,7 @@
|
||||
// but here we are not yet done writing to the file
|
||||
// if only there were a keyword in Zig that
|
||||
|
||||
Reference in New Issue
Block a user