File size: 1,231 Bytes
e3af2b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# μ•„λž˜ λ‚˜μ™€μžˆλŠ” κ·œμΉ™μ€ 회둜둜 λ§Œλ“  ν•¨μˆ˜ μ•ˆμ—μ„œλ§Œ 적용
# ν—ˆμš©λœ ν•¨μˆ˜: return, μ‚¬μš©μžκ°€ μ •μ˜ν•œ ν•¨μˆ˜
# ν—ˆμš©λœ μ—°μ‚°μž(두 κ°’μ˜ μ—°μ‚°μœΌλ‘œ μ‚¬μš©λ  λ•Œ): !, &, |, ^, =
# ν—ˆμš©λœ μžλ£Œν˜•: bool, tuple

def main() -> None:
    from functools import wraps

    # κΈ°λ³Έ ν•¨μˆ˜ (회둜 λ°–μ—μ„œλ§Œ)
    def circuit(func): # decorator function
        @wraps(func)
        def wrapper(*args): # wrapper function
            return func(*args)
        return wrapper
    
    def BoolToStr(bools: tuple[bool]):
        retstr = ''
        for i in range(len(bools)):
            if bools[i]:
                retstr += '1'
            else:
                retstr += '0'
        return retstr
    
    # 회둜 λ§Œλ“€κΈ°
    @circuit
    def Add1Dgt(in1: bool, in2: bool) -> tuple:
        firstdgt: bool = in1 ^ in2
        seconddgt: bool = in1 & in2
        return (seconddgt, firstdgt)
    
    def Add2dgt(in1: bool, in2: bool) -> tuple:
        

    # ν…ŒμŠ€νŠΈ
    print(BoolToStr(Add1Dgt(1, 1)))
    print(BoolToStr(Add1Dgt(1, 0)))
    print(BoolToStr(Add1Dgt(0, 1)))
    print(BoolToStr(Add1Dgt(0, 0)))

if __name__ == '__main__':
    main()