Quantcast
Channel: 《2010 = 1+2-(3-4-5)*6*7*8-9》的评论
Viewing all articles
Browse latest Browse all 15

作者:hecha

$
0
0

做了一个 python 的简单实现,处理了使用单个数的情况,结果中会有些重复
def f(n):
if len(n) == 1:
yield n[0], str(n[0])
else:
for i in range(1, len(n)):
nx, ny = n[:i], n[i:]
for x, ex in f(nx):
for y, ey in f(ny):
yield x + y, ‘(‘ + ex + ‘+’ + ey + ‘)’
yield x – y, ‘(‘ + ex + ‘-‘ + ey + ‘)’
yield x * y, ‘(‘ + ex + ‘*’ + ey + ‘)’

for i, e in f([1, 2, 3, 4, 5, 6, 7, 8, 9]):
if i == 2010:
print(e + ‘=’ + str(i))


Viewing all articles
Browse latest Browse all 15

Latest Images

Trending Articles


“Mr bolero banat lines”


OFW quotes : Pinoy Tagalog Quotes


Patama Quotes – Tanga love tagalog quotes


INUMAN QUOTES


RE: Mutton Pies (frankie241)


Hato lada ym dei namar ka jingpyrshah jong U JJM Nichols Roy (Bah Joy) ngin...


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 11.6.0 by Vimeo.com, Inc.


Vimeo 11.8.2 by Vimeo.com, Inc.


Doodle Jump 3.11.35 by Lima Sky LLC


Sapos para colorear


Long Distance Relationship Tagalog Love Quotes


Tagalog God Quotes to inspire you


Re:Mutton Pies (lleechef)


FORECLOSURE OF REAL ESTATE MORTGAGE


Vimeo Create - Video Maker & Editor 1.5.2 by Vimeo Inc


Vimeo 10.7.1 by Vimeo.com, Inc.


Vimeo 11.6.1 by Vimeo.com, Inc.


Doodle Jump 3.11.34 by Lima Sky LLC


Doodle Jump 3.11.34 by Lima Sky LLC



Latest Images