summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorChris Boesch <chrboesch@noreply.codeberg.org>2025-02-13 22:27:29 +0000
committerChris Boesch <chrboesch@noreply.codeberg.org>2025-02-13 22:27:29 +0000
commit0e0cafb71ea7adc40fbc1844c60d89126c2bda3e (patch)
treec32eaedcb06f3ee2db7f8cf7a3f49ed236b7565e /patches
parent0af4f75e070ddc200b4de250425425cf145c2717 (diff)
parent064184c8a78d460b1d20837ef0064274f4730905 (diff)
Merge pull request 'Suggesting a third exercise for bit manipulation' (#202) from alexsisco/zigling-exercises:bit_man3 into main
Reviewed-on: https://codeberg.org/ziglings/exercises/pulls/202
Diffstat (limited to 'patches')
-rw-r--r--patches/patches/110_quiz9.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/patches/patches/110_quiz9.patch b/patches/patches/110_quiz9.patch
new file mode 100644
index 0000000..9d9b864
--- /dev/null
+++ b/patches/patches/110_quiz9.patch
@@ -0,0 +1,56 @@
+--- exercises/110_quiz9.zig 2025-02-08 13:19:48.522641785 -0800
++++ answers/110_quiz9.zig 2025-02-10 17:42:04.525004335 -0800
+@@ -108,7 +108,7 @@
+ PORTB = 0b1100;
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("^ {b:0>4} // (bitmask)\n", .{0b0101});
+- PORTB ^= (1 << 1) | (1 << 0); // What's wrong here?
++ PORTB ^= (1 << 2) | (1 << 0);
+ checkAnswer(0b1001, PORTB);
+
+ newline();
+@@ -116,7 +116,7 @@
+ PORTB = 0b1100;
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("^ {b:0>4} // (bitmask)\n", .{0b0011});
+- PORTB ^= (1 << 1) & (1 << 0); // What's wrong here?
++ PORTB ^= (1 << 1) | (1 << 0);
+ checkAnswer(0b1111, PORTB);
+
+ newline();
+@@ -170,7 +170,7 @@
+ PORTB = 0b1001; // reset PORTB
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("| {b:0>4} // (bitmask)\n", .{0b0100});
+- PORTB = PORTB ??? (1 << 2); // What's missing here?
++ PORTB = PORTB | (1 << 2);
+ checkAnswer(0b1101, PORTB);
+
+ newline();
+@@ -178,7 +178,7 @@
+ PORTB = 0b1001; // reset PORTB
+ print(" {b:0>4} // (reset state)\n", .{PORTB});
+ print("| {b:0>4} // (bitmask)\n", .{0b0100});
+- PORTB ??? (1 << 2); // What's missing here?
++ PORTB |= (1 << 2);
+ checkAnswer(0b1101, PORTB);
+
+ newline();
+@@ -269,7 +269,7 @@
+ PORTB = 0b1110; // reset PORTB
+ print(" {b:0>4} // (initial state of PORTB)\n", .{PORTB});
+ print("& {b:0>4} // (bitmask)\n", .{0b1011});
+- PORTB = PORTB & ???@as(u4, 1 << 2); // What character is missing here?
++ PORTB = PORTB & ~@as(u4, 1 << 2);
+ checkAnswer(0b1010, PORTB);
+
+ newline();
+@@ -277,7 +277,7 @@
+ PORTB = 0b0111; // reset PORTB
+ print(" {b:0>4} // (reset state)\n", .{PORTB});
+ print("& {b:0>4} // (bitmask)\n", .{0b1110});
+- PORTB &= ~(1 << 0); // What's missing here?
++ PORTB &= ~@as(u4, 1 << 0);
+ checkAnswer(0b0110, PORTB);
+
+ newline();