Skip to content

Commit 665ab47

Browse files
author
Alexei Bezborodov
committed
Nand game
1 parent 6b15d81 commit 665ab47

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

nandgame.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def NAND(a, b):
44
return 0
55
return 1
66

7-
print('NAND(1,1)=', NAND(1, 1))
7+
print('NAND(1,0)=', NAND(1, 0))
88

99
def INV(a):
1010
return NAND(a, a)
@@ -23,7 +23,7 @@ def XOR(a, b):
2323
def HALF_ADD(a, b):
2424
return AND(a, b), XOR(a, b)
2525

26-
h,l = HALF_ADD(1,1)
26+
h, l = HALF_ADD(1,1)
2727
print('HALF_ADD(1,1)=', h, l)
2828

2929
def FULL_ADD(a, b, c):
@@ -32,16 +32,13 @@ def FULL_ADD(a, b, c):
3232
return OR(h1, h), l1
3333

3434
h,l = FULL_ADD(1,1,1)
35-
print('FULL_ADD(1,1)=', h, l)
35+
print('FULL_ADD(1,1,1)=', h, l)
3636

3737
def MULTI_BIT_ADD(a, b, c):
38-
h = 0
39-
result = [0]*len(a)
38+
s = [0]*len(a)
4039
for i in range(len(a)):
41-
h, l = FULL_ADD(a[i], b[i], c)
42-
result[i] = l
43-
c = h
44-
return h, result
40+
c, s[i] = FULL_ADD(a[i], b[i], c)
41+
return c, s
4542

46-
h,r = MULTI_BIT_ADD([1, 0],[1, 1],1)
47-
print('MULTI_BIT_ADD([1, 0],[1, 1],1)=', h, r)
43+
c, s = MULTI_BIT_ADD([0,1,1,0,0],[1,1,0,0,0],0)
44+
print('MULTI_BIT_ADD([0,1,1,0,0],[1,1,0,0,0],0)=', c, s)

0 commit comments

Comments
 (0)