Department numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Zig}}: writer.print() is void (no return))
Line 4,887: Line 4,887:
const stdout = std.io.getStdOut().writer();
const stdout = std.io.getStdOut().writer();


_ = try stdout.writeAll("Police Sanitation Fire\n");
try stdout.writeAll("Police Sanitation Fire\n");
_ = try stdout.writeAll("------ ---------- ----\n");
try stdout.writeAll("------ ---------- ----\n");


var p: usize = 2;
var p: usize = 2;
Line 4,895: Line 4,895:
for (1..7 + 1) |f|
for (1..7 + 1) |f|
if (p != s and s != f and f != p and p + f + s == 12) {
if (p != s and s != f and f != p and p + f + s == 12) {
_ = try stdout.print(" {d} {d} {d}\n", .{ p, s, f });
try stdout.print(" {d} {d} {d}\n", .{ p, s, f });
};
};
}</syntaxhighlight>
}</syntaxhighlight>
Line 4,921: Line 4,921:
const stdout = std.io.getStdOut().writer();
const stdout = std.io.getStdOut().writer();


_ = try stdout.writeAll("Police Sanitation Fire\n");
try stdout.writeAll("Police Sanitation Fire\n");
_ = try stdout.writeAll("------ ---------- ----\n");
try stdout.writeAll("------ ---------- ----\n");


var it = SolutionIterator{};
var it = SolutionIterator{};
while (it.next()) |solution| {
while (it.next()) |solution| {
_ = try stdout.print(
try stdout.print(
" {d} {d} {d}\n",
" {d} {d} {d}\n",
.{ solution.police, solution.sanitation, solution.fire },
.{ solution.police, solution.sanitation, solution.fire },