Normalized exercise output, answers (#41)
1. All exercises should print a trailing \n 2. The build script should always show you _exactly_ what it's looking for when you get it wrong. Therefore, .output should be set to the exact expected output.
This commit is contained in:
parent
a7e4c04399
commit
bed01210e0
8 changed files with 17 additions and 16 deletions
|
|
@ -25,5 +25,5 @@ pub fn main() void {
|
|||
// an error. Can you set the type correctly above?
|
||||
my_number = MyNumberError.TooSmall;
|
||||
|
||||
std.debug.print("I compiled!", .{});
|
||||
std.debug.print("I compiled!\n", .{});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub fn main() void {
|
|||
var a: u32 = addTwenty(44) catch 22;
|
||||
var b: u32 = addTwenty(4) ??? 22;
|
||||
|
||||
std.debug.print("a={}, b={}", .{ a, b });
|
||||
std.debug.print("a={}, b={}\n", .{ a, b });
|
||||
}
|
||||
|
||||
// Please provide the return type from this function.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub fn main() void {
|
|||
var b: u32 = makeJustRight(14) catch 0;
|
||||
var c: u32 = makeJustRight(4) catch 0;
|
||||
|
||||
std.debug.print("a={}, b={}, c={}", .{ a, b, c });
|
||||
std.debug.print("a={}, b={}, c={}\n", .{ a, b, c });
|
||||
}
|
||||
|
||||
// In this silly example we've split the responsibility of making
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub fn main() void {
|
|||
var b: u32 = addFive(14) catch 0;
|
||||
var c: u32 = addFive(4) catch 0;
|
||||
|
||||
std.debug.print("a={}, b={}, c={}", .{ a, b, c });
|
||||
std.debug.print("a={}, b={}, c={}\n", .{ a, b, c });
|
||||
}
|
||||
|
||||
fn addFive(n: u32) MyNumberError!u32 {
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ pub fn main() void {
|
|||
\\ <span style="color: #{x:0>6}">Green</span>
|
||||
\\ <span style="color: #{}">Blue</span>
|
||||
\\</p>
|
||||
\\
|
||||
, .{
|
||||
@enumToInt(Color.red),
|
||||
@enumToInt(Color.green),
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ pub fn main() void {
|
|||
// Ouch! Glorp takes a punch!
|
||||
glorp_the_wise.health -= 10;
|
||||
|
||||
std.debug.print("Your wizard has {} health and {} gold.", .{
|
||||
std.debug.print("Your wizard has {} health and {} gold.\n", .{
|
||||
glorp_the_wise.health,
|
||||
glorp_the_wise.gold,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ fn printCharacter(c: *Character) void {
|
|||
.warrior => "Warrior",
|
||||
};
|
||||
|
||||
std.debug.print("{s} (G:{} H:{} XP:{})", .{
|
||||
std.debug.print("{s} (G:{} H:{} XP:{})\n", .{
|
||||
class_name,
|
||||
c.gold,
|
||||
c.health,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue