五月天青色头像情侣网名,国产亚洲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點解題和出題工具的評論 (共 條)

分享到微博請遵守國家法律
南阳市| 通道| 耒阳市| 新余市| 称多县| 清水河县| 峨山| 本溪| 容城县| 嘉善县| 西林县| 兴海县| 灵武市| 墨脱县| 天镇县| 德清县| 广丰县| 邵阳县| 兴业县| 防城港市| 承德市| 清河县| 商洛市| 青河县| 佳木斯市| 西青区| 台东县| 荃湾区| 贺兰县| 文水县| 漾濞| 镇安县| 屏边| 长子县| 中卫市| 新竹市| 乌鲁木齐市| 宁南县| 临邑县| 灵璧县| 连南|