- # -*- coding: utf-8 -*-
- #stones = [ '●', '○' ]
- stones = [ 'o', 'x' ]
- patterns = [ '00', '10', '01', '11' ]
- def test(n, a, b, c, d):
- print('=' * 50)
- print(" Stones: {}".format(n))
- print(" - oo: {}, ox: {},".format(a, b))
- print(" - xo: {}, xx: {}".format(c, d))
- print('=' * 50)
- lines = [ "{{:0{}b}}".format(n).format(x) for x in range(2 ** n) ]
- count = 0
- for x in lines:
- matched = [ 0 ] * len(patterns)
- for y in range(0, len(x)-1):
- for i, z in enumerate(patterns):
- if z == x[y:y+2]:
- matched[i] += 1
- if matched == [ a, b, c, d ]:
- count += 1
- print(' ', x.replace('0', stones[0]).replace('1', stones[1]))
- print('=' * 50)
- print(" Result: {}".format(count))
- print('=' * 50)
- print()
- test(6, 2, 1, 1, 1)
- test(10, 4, 2, 2, 1)
는 내가 계산 안함
댓글 0