summaryrefslogtreecommitdiff
path: root/exercises/017_quiz2.zig
diff options
context:
space:
mode:
authorDave Gauer <dave@ratfactor.com>2021-03-12 18:59:46 -0500
committerDave Gauer <dave@ratfactor.com>2021-03-12 18:59:46 -0500
commit0956f1839fcaaa273353148da9e157a8f9690d2f (patch)
treed6c90700131d5b28e898881f13e2a05612e4703f /exercises/017_quiz2.zig
parent93eefe0f250bb76bfdd8e6bb784b6a9586517000 (diff)
"999 is enough for anybody" triple-zero padding (#18)
When I hit 999 exercises, I will finally have reached the ultimate state of soteriological release and no more exercises will be needed. The cycle will be complete. All that will be left is perfect quietude, freedom, and highest happiness.
Diffstat (limited to 'exercises/017_quiz2.zig')
-rw-r--r--exercises/017_quiz2.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/exercises/017_quiz2.zig b/exercises/017_quiz2.zig
new file mode 100644
index 0000000..7de7010
--- /dev/null
+++ b/exercises/017_quiz2.zig
@@ -0,0 +1,28 @@
+//
+// Quiz time again! Let's see if you can solve the famous "Fizz Buzz"!
+//
+// "Players take turns to count incrementally, replacing
+// any number divisible by three with the word "fizz",
+// and any number divisible by five with the word "buzz".
+// - From https://en.wikipedia.org/wiki/Fizz_buzz
+//
+// Let's go from 1 to 16. This has been started for you, but there's
+// some problems. :-(
+//
+const std = import standard library;
+
+function main() void {
+ var i: u8 = 1;
+ var stop_at: u8 = 16;
+
+ // What kind of loop is this? A 'for' or a 'while'?
+ ??? (i <= stop_at) : (i += 1) {
+ if (i % 3 == 0) std.debug.print("Fizz", .{});
+ if (i % 5 == 0) std.debug.print("Buzz", .{});
+ if (!(i % 3 == 0) and !(i % 5 == 0)) {
+ std.debug.print("{}", .{???});
+ }
+ std.debug.print(", ", .{});
+ }
+ std.debug.print("\n", .{});
+}