• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Jul 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import random
2.
3. diamondDurability = 1562
4.
5. def checkBreak (level):
6.     formula = int((100 / (level + 1)))
7.     roll = random.randint(0, 100)
8.
9.     if roll <= formula:
10.         # Lost Durability
11.         return True
12.     elif roll > formula:
13.         # Kept Durability
14.         return False
15.
16.
17.
18. pickaxes = int(input("How many pickaxes would you like to use? "))
19. level = int(input("What level unbreaking do the pickaxes have? "))
20.
21. pickaxeLifeSpan = []
22. lowestDurability = 10000000
23. highestDurability = 0
24.
25. while pickaxes > 0:
26.     tests = 0
27.     durability = diamondDurability
28.
29.     while durability > 0:
30.         if checkBreak(level):
31.             durability -= 1
32.         tests += 1
33.     pickaxeLifeSpan.append(tests)
34.     print("Pickaxe broke after", tests, "blocks broken.")
35.
36.     if tests > highestDurability:
37.         highestDurability = tests
38.     if tests < lowestDurability:
39.         lowestDurability = tests
40.
41.     pickaxes -= 1
42.
43.
44. print("The average number of blocks broken needed to break a pickaxe is", (sum(pickaxeLifeSpan) // len(pickaxeLifeSpan)))
45. print("The least lasting pickaxe lasted", lowestDurability, "blocks broken.")
46. print("The longest lasting pickaxe lasted", highestDurability, "blocks broken.")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?