summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patches/patches/110_bit_manipulation3.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/patches/patches/110_bit_manipulation3.patch b/patches/patches/110_bit_manipulation3.patch
new file mode 100644
index 0000000..9c64336
--- /dev/null
+++ b/patches/patches/110_bit_manipulation3.patch
@@ -0,0 +1,56 @@
+--- exercises/110_bit_manipulation3.zig 2025-02-08 11:52:35.609300707 -0800
++++ answers/110_bit_manipulation3.zig 2025-02-08 13:00:15.414038314 -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();