Popcorn Hack 1

Q: What are methods of real-world purpose that using logic gates can implement?

Authorization (AND Gate): Need both keycard and PIN = better security.

Automatic doors (OR Gate): Door opens if motion sensor or button triggers = easier access

Popcorn Hack 2

Q: A digital circuit receives three binary inputs: X, Y, and Z. The circuit outputs 1 if and only if X AND Y are both 1, OR Z is 1. Correct expression: A. (X AND Y) OR Z

“X AND Y are both 1” → X AND Y

“OR Z is 1” → then OR with Z → (X AND Y) OR Z

Homework Hack

def secure_entry_system(keycard, pin, voice_auth):
    def AND(a, b):
        return a & b  # AND logic

    # Now we AND all three: (keycard AND pin) AND voice_auth
    return AND(AND(keycard, pin), voice_auth)

# Test cases
print(secure_entry_system(1, 1, 1))  # Expected Output: 1 (Access Granted)
print(secure_entry_system(1, 1, 0))  # Expected Output: 0 (Access Denied)
print(secure_entry_system(1, 0, 1))  # Expected Output: 0 (Access Denied)
print(secure_entry_system(0, 1, 1))  # Expected Output: 0 (Access Denied)

1
0
0
0