您當前的位置:首頁 > 遊戲

極客戰記—沙漠(41-60關)

作者:由 Yarwood 發表于 遊戲時間:2022-01-14

第41關—sarven拯救:

極客戰記—沙漠(41-60關)

第42關—釣魚:

極客戰記—沙漠(41-60關)

第43關—別衝過去,安靜點:

極客戰記—沙漠(41-60關)

第44關—誘餌和開關:

極客戰記—沙漠(41-60關)

第45關—Z字形逃竄:

極客戰記—沙漠(41-60關)

第46關—沙漠三角洲:

極客戰記—沙漠(41-60關)

第47關—立方雷區:

# 穿過雷區

# 這個函式返回乘以次數的數字。

def mult(number, times):

total = 0

while times > 0:

total += number

times -= 1

return total

# 這個函式返回乘方的數字。

def power(number, exponent):

total = 1

# 補全函式。

while exponent>0:

total*=number

exponent-=1

return total

# 別修改這些程式碼

# 你可以在塔上找到方程的係數

tower = hero。findFriends()[0]

a = tower。a

b = tower。b

c = tower。c

d = tower。d

x = hero。pos。x

while True:

# 用三次方程求路徑

y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0)

hero。moveXY(x, y)

x = x + 5

極客戰記—沙漠(41-60關)

第48關—煩躁的GCD:

# 計算秘密數字並進入財政部。

# 這兩個人知道密碼的關鍵。

friends = hero。findFriends()

number1 = friends[0]。secretNumber

number2 = friends[1]。secretNumber

# 只是為了確保第一個數字更大。

if number2 > number1:

swap = number1

number1 = number2

number2 = swap

# 這是簡單但慢的功能找到gcd。

def bruteforceGCD (a, b):

hero。say(“樸素的演算法。”)

cycles = 0

# 我們列舉了所有可能的除數。

counter = b

while True:

cycles += 1

if cycles > 100:

hero。say(“計算是困難的。我累了。”)

break

# 如果兩個數字都有 “counter” 除數。

if a % counter == 0 and b % counter == 0:

break

counter -= 1

hero。say(“我使用了 ” + cycles + “ 週期”)

return counter

# 這是找到gcd的聰明方式。

def euclidianGCD (a, b):

cycles = 0

while b:

cycles += 1

swap = b

b = a % b

a = swap

hero。say(“我使用了 ” + cycles + “ 週期”)

return a

# 也許你需要使用另一個功能?

secretNumber = euclidianGCD(number1,number2) # ∆

hero。moveXY(48, 34)

hero。say(secretNumber)

# 財政部是開放的(我希望如此)!去那兒!

hero。moveXY(68, 34)

極客戰記—沙漠(41-60關)

第49關—sarven救世主:

極客戰記—沙漠(41-60關)

第50關—安全毯:

極客戰記—沙漠(41-60關)

第51關—奇數沙塵暴:

極客戰記—沙漠(41-60關)

第52關—團隊合作:

極客戰記—沙漠(41-60關)

第53關—銀行突襲:

極客戰記—沙漠(41-60關)

第54關—協助防禦:

極客戰記—沙漠(41-60關)

第55關—招募隊伍:

極客戰記—沙漠(41-60關)

第56關——第二寶石:

極客戰記—沙漠(41-60關)

第57關—遊魂:

極客戰記—沙漠(41-60關)

第58關—潛伏:

極客戰記—沙漠(41-60關)

第59關—優待:

極客戰記—沙漠(41-60關)

第60關—sarven牧羊人:

極客戰記—沙漠(41-60關)

標簽: Hero  cycles  total  Power  Tower