added patch file for exercise 110

This commit is contained in:
Alexander Sisco 2025-02-08 13:15:48 -08:00
parent 596d5e50ca
commit 1478d41801

View file

@ -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();