Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A B C'D'E'F' v
- A B'C'D'E'F v
- A'B C'D'E'F' v
- : : : : : :
- <absolute bucketload of boolean expressions>
- : : : : : :
- A'B'C'D'E F
- bool nOf(int n, bool[] bs)
- {
- foreach(bool b in bs)
- {
- if((n -= b ? 1 : 0) <= 0) break;
- }
- return n == 0;
- }
- expressions = [A, B, C, D, E, F, G ]
- numTrue = len(filter(None, expressions)
- $expressions = array(A, B, C, D, E, F, G);
- $numTrue = count(array_filter($expressions));
- (A & B & C & ~D & ~E) |
- (A & B & ~C & D & ~E) |
- (A & B & ~C & ~D & E) | ...
- (~A & ~B & C & D & E)
- 2 : a&(b|c|d|e|f) | b&(c|d|e|f) | c&(d|e|f) | d&(e|f) | e*f
- 3 : a&(b&(c|d|e|f) | c&(d|e|f) | d&(e|f) | e*f) | b&(c&(d|e|f) | d&(e|f) | e*f) | c&(d&(e|f) | e*f) | d&e&f
- bool AofB(int n, bool[] bs)
- {
- if(bs.length == 0) return false;
- if(n == 0) return true;
- foreach(int i, bool b; b[0..$-n])
- if(b && AofB(n-1,b[i+1..$]) return true;
- return false;
- }
- bool AofB(int n, bool[] bs)
- {
- foreach(bool b; bs) if(b && --n == 0) return true;
- return false;
- }
- Basic Half-Adder
- A, B : 1st 2nd bits
- O, C : unit output and carry to next unit
- O := A xor B;
- C := A and B;
- (A && B) || (A && C) || ... || (D && E) || (D && F) || (E && F)
- #{x | x <- {A, B, C, D, E, F} | x} = 2
- #{...}
- {x | x <- {A, B, C, D, E, F} | x}
Add Comment
Please, Sign In to add comment