|
发表于 2019-12-8 16:56:30
|
显示全部楼层
- """
- 将1-9这9个数字填入下矿,让等式成立.
- [] x [] [] = [] [] [] = [] [] * []
- """
- from random import choice
- while True:
- num = [str(x) for x in range(1,10)]
- a = choice(num)
- num.remove(a)
- b = choice(num)
- num.remove(b)
- c = choice(num)
- num.remove(c)
- d = choice(num)
- num.remove(d)
- e = choice(num)
- num.remove(e)
- f = choice(num)
- num.remove(f)
- g = choice(num)
- num.remove(g)
- h = choice(num)
- num.remove(h)
- i = choice(num)
- result1 = int(a) * int(b + c)
- result2 = int(g + h) * int(i)
- result3 = int(d + e + f)
- if result1 == result2 == result3:
- print('{}x{}{}={}{}{}={}{}x{}'.format(a,b,c,d,e,f,g,h,i))
- break
-
复制代码
用Python写的 |
|