国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(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點解題和出題工具的評論 (共 條)

分享到微博請遵守國家法律
沿河| 静宁县| 宁海县| 翁源县| 迁安市| 驻马店市| 长武县| 磐安县| 金山区| 高州市| 玉山县| 湖州市| 秦皇岛市| 临泽县| 紫金县| 边坝县| 来凤县| 枣阳市| 新昌县| 泸州市| 蒙山县| 富裕县| 宜川县| 修水县| 凤山市| 潮州市| 北安市| 资阳市| 孙吴县| 黔西县| 准格尔旗| 小金县| 冀州市| 新邵县| 哈巴河县| 临颍县| 普兰县| 敖汉旗| 崇仁县| 射洪县| 夏河县|