Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29
with:
version: 0.16.0
version: 0.17.0

- name: Test exercises
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zig-fmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Install Zig
uses: mlugg/setup-zig@d1434d08867e3ee9daa34448df10607b98908d29
with:
version: 0.16.0
version: 0.17.0

- name: Check that Zig code is formatted
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Fortunately, all of the popular installation methods are listed on the [Zig inst

## Zig version

Exercism currently supports Zig 0.16.0 (released on 2026-04-14) only.
Exercism uses Zig 0.17.0 (released on 2026-10-01).

An exercise may be compatible with a different Zig version, but that isn't guaranteed.
Zig has not yet reached version 1.0, and breaking changes are common.
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

It may be helpful to look at the implementation of [`std.enums.EnumSet`][enumset].

[enumset]: https://ziglang.org/documentation/0.16.0/std/#std.enums.EnumSet
[enumset]: https://ziglang.org/documentation/0.17.0/std/#std.enums.EnumSet
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.meta/example.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn isAllergicTo(score: tag_type, allergen: Allergen) bool {
}

pub fn initAllergenSet(score: usize) EnumSet(Allergen) {
const len = @typeInfo(Allergen).@"enum".fields.len;
const len = @typeInfo(Allergen).@"enum".field_names.len;
const bits = IntegerBitSet(len){ .mask = @as(tag_type, @truncate(score)) };
return .{ .bits = bits };
}
2 changes: 1 addition & 1 deletion exercises/practice/anagram/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ For more details on hash maps in Zig, see:
- [Zighelp - Hash Maps][zighelp]
- [Zig Standard Library - `buf_set.zig`][buf-set]

[buf-set]: https://ziglang.org/documentation/0.16.0/std/#std.BufSet
[buf-set]: https://ziglang.org/documentation/0.17.0/std/#std.BufSet
[zig-hashmaps-explained]: https://devlog.hexops.com/2022/zig-hashmaps-explained/
[zighelp]: https://zighelp.org/chapter-2/#hash-maps
2 changes: 1 addition & 1 deletion exercises/practice/anagram/.meta/example.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const mem = std.mem;
/// Returns the case-insensitive counts of English letters in `s`.
/// Caller guarantees that `s` contains at most 15 of a single letter.
fn count(s: []const u8) [26]u4 {
var result = [_]u4{0} ** 26;
var result: [26]u4 = @splat(0);
for (s) |c| {
switch (c) {
'A'...'Z' => result[c - 'A'] += 1,
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/dnd-character/.docs/instructions.append.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A correct implementation has less than a 0.01% chance of failing each test.

See the instructions above for a definition of what an ability score is.

[random]: https://ziglang.org/documentation/0.16.0/std/#std.Random
[random-seed]: https://ziglang.org/documentation/0.16.0/std/#std.testing.random_seed
[random]: https://ziglang.org/documentation/0.17.0/std/#std.Random
[random-seed]: https://ziglang.org/documentation/0.17.0/std/#std.testing.random_seed
[chi-squared-test]: https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test
[p-value]: https://en.wikipedia.org/wiki/P-value
2 changes: 1 addition & 1 deletion exercises/practice/isogram/.approaches/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn isIsogram(str: []const u8) bool {
seen |= mask;
}
// Pad the remaining bytes with zeroes to fill one last block.
var padded = [_]u8{0} ** block_len;
var padded: [block_len]u8 = @splat(0);
@memcpy(padded[0 .. str.len - i], str[i..]);
const mask = letterMask(padded) orelse return false;
return seen & mask == 0;
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/isogram/.approaches/simd/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn isIsogram(str: []const u8) bool {
seen |= mask;
}
// Pad the remaining bytes with zeroes to fill one last block.
var padded = [_]u8{0} ** block_len;
var padded: [block_len]u8 = @splat(0);
@memcpy(padded[0 .. str.len - i], str[i..]);
const mask = letterMask(padded) orelse return false;
return seen & mask == 0;
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/pangram/.meta/example.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub fn isPangram(s: []const u8) bool {
if (s.len < 26) return false;

var letters = [_]bool{false} ** 26;
var letters: [26]bool = @splat(false);
for (s) |c| {
const i = switch (c) {
'A'...'Z' => c - 'A',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ For more details, see the [Zig Language Reference][zig-reference] and the implem

However, note that this exercise does not currently test an input of 0 (because `std.testing` does [not yet support expecting a panic][proposal]).

[zig-reference]: https://ziglang.org/documentation/0.16.0/#unreachable
[assert]: https://ziglang.org/documentation/0.16.0/std/#std.debug.assert
[zig-reference]: https://ziglang.org/documentation/0.17.0/#unreachable
[assert]: https://ziglang.org/documentation/0.17.0/std/#std.debug.assert
[proposal]: https://github.com/ziglang/zig/issues/1356
8 changes: 4 additions & 4 deletions exercises/practice/queen-attack/test_queen_attack.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const queen_attack = @import("queen_attack.zig");
const QueenError = queen_attack.QueenError;

test "queen has exactly two fields" {
try testing.expectEqual(2, std.meta.fields(queen_attack.Queen).len);
try testing.expectEqual(2, @typeInfo(queen_attack.Queen).@"struct".field_names.len);
}

test "queen with a valid position" {
const queen = try queen_attack.Queen.init(2, 2);
// Allow the fields to have any name.
const fields = std.meta.fields(@TypeOf(queen));
inline for (fields) |f| {
const actual = @field(queen, f.name);
const field_names = @typeInfo(@TypeOf(queen)).@"struct".field_names;
inline for (field_names) |name| {
const actual = @field(queen, name);
const expected = @as(@TypeOf(actual), 2);
try testing.expectEqual(expected, actual);
}
Expand Down
8 changes: 4 additions & 4 deletions generators/exercises/queen_attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def gen_case(case):
inp = case["input"]
if prop == "fields":
n = case["expected"]
return f" try testing.expectEqual({n}, std.meta.fields(queen_attack.Queen).len);\n"
return f" try testing.expectEqual({n}, @typeInfo(queen_attack.Queen).@\"struct\".field_names.len);\n"
if prop == "create":
pos = inp["queen"]["position"]
row, col = pos["row"], pos["column"]
Expand All @@ -32,9 +32,9 @@ def gen_case(case):
return (
f" const queen = try queen_attack.Queen.init({row}, {col});\n"
f" // Allow the fields to have any name.\n"
f" const fields = std.meta.fields(@TypeOf(queen));\n"
f" inline for (fields) |f| {{\n"
f" const actual = @field(queen, f.name);\n"
f" const field_names = @typeInfo(@TypeOf(queen)).@\"struct\".field_names;\n"
f" inline for (field_names) |name| {{\n"
f" const actual = @field(queen, name);\n"
f" const expected = @as(@TypeOf(actual), {row});\n"
f" try testing.expectEqual(expected, actual);\n"
f" }}\n"
Expand Down
Loading