五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

24點解題和出題工具

2023-07-12 15:36 作者:開朗的小盆友yyds  | 我要投稿

接著上一篇文章

24點解題工具代碼:

import itertools

#by jason

def calculate24(nums):

? ? permutations = list(itertools.permutations(nums))

? ? operators = list(itertools.product(["+", "-", "*", "/"], repeat=3))

? ? for perm in permutations:

? ? ? ? for operator in operators:

? ? ? ? ? ? equation = f"{perm[0]} {operator[0]} {perm[1]} {operator[1]} {perm[2]} {operator[2]} {perm[3]}"

? ? ? ? ? ? if abs(eval(equation) - 24) < 1e-6:

? ? ? ? ? ? ? ? return equation.replace("//", "/")

? ? return "無解"

while 1:

????a=int(input("1:"))

????b=int(input("2:"))

????c=int(input("3:"))

????d=int(input("4:"))

????print(calculate24([a, b, c, d]))

????input("_____________________________________")






24點出題工具代碼:

#by jason

import itertools

import random as r


def py24(nums):

? ? permutations = list(itertools.permutations(nums))

? ? operators = list(itertools.product(["+", "-", "*", "/"], repeat=3))

? ? for perm in permutations:

? ? ? ? for operator in operators:

? ? ? ? ? ? equation = f"{perm[0]} {operator[0]} {perm[1]} {operator[1]} {perm[2]} {operator[2]} {perm[3]}"

? ? ? ? ? ? if abs(eval(equation) - 24) < 1e-6:

? ? ? ? ? ? ? ? return equation.replace("//", "/")

? ? return "No"

while 1:

? ? a=r.randint(1,10)

? ? b=r.randint(1,10)

? ? c=r.randint(1,10)

? ? d=r.randint(1,10)

? ? f=[a,b,c,d]

? ? if((py24(f))!="No"):

? ? ? ? print(a," ",b," ",c," ",d,' ')

? ? ? ? input("")

? ? ? ? print(py24(f))

? ? ? ? input("")

? ? ? ? print("___________________________________________________________________")


? ? else:

? ? ? ? pass





24點解題和出題工具的評論 (共 條)

分享到微博請遵守國家法律
通城县| 鄂尔多斯市| 汝城县| 河间市| 铜鼓县| 墨江| 墨脱县| 晋中市| 遂川县| 托克逊县| 安达市| 六盘水市| 本溪市| 霍州市| 泗洪县| 周至县| 昌吉市| 民勤县| 安塞县| 西充县| 鹤壁市| 徐汇区| 湘潭市| 远安县| 临颍县| 贡觉县| 南宁市| 马边| 会昌县| 雅江县| 阿拉善左旗| 台中县| 吴忠市| 巴林右旗| 射阳县| 扎兰屯市| 陆河县| 德州市| 衡阳市| 穆棱市| 芦山县|