(X and Y) or (Y and (not Z))
i = 0 sum = 0 while i != 10 do sum = sum + i i = i + 1 end
Ruby has another loop called an until loop that runs until a particular condition is true. For example, the loop above can be written equivalently by negating the loop condition and using until instead of while:
i = 0 sum = 0 until i == 10 do sum = sum + i i = i + 1 end
Use DeMorgan's Law to convert the following Ruby while loop to an equivalent until loop.
while (x >= 40) and (x < 68) do ... end
0 1 2 3 4 5 6 7 8 9 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Let ABCD represent a 4-bit binary-coded decimal number as described above. For example, the decimal digit 7 is represented in binary-coded decimal as 0111, so in this case, A = 0, B = 1, C = 1, and D = 1.
A seven-degment display can be used to display each of the ten decimal digits as shown below.
We can define a circuit abstractly below that requires four Boolean inputs A, B, C, and D represent a decimal digit encoded in binary-coded decimal format, and seven Boolean outputs s1, s2, ..., s7 to control each segment of the display:
A segment si is lit if si is 1 (true) and not lit if si is 0 (false).
Your answer should be of the following form:
s5 = (________) ∨ (________) ∨ (________) ∨ ...
where each missing section is a boolean expression with all 4 input variables that is true when ABCD represents a decimal digit that results in the segment s5 of the display being lit. To help you get started, the digit 0 (binary 0000) will light segment s5, so the first expression in the formula above would be
(¬A ∧ ¬B ∧ ¬C ∧ ¬D)
since s5 would be true (i.e. 1) if A = 0, B = 0, C = 0, and D = 0. You will need to find all of the other missing expressions for s5.
X Y | C S --------------- 0 0 | 0 0 0 1 | 0 1 1 0 | 0 1 1 1 | 1 0
This adder can be represented abstractly using the following diagram: