Skip to content

Instantly share code, notes, and snippets.

@icot
Last active November 17, 2018 13:50
Show Gist options
  • Save icot/c0b4dfc5760064e629653d1d913a9fd4 to your computer and use it in GitHub Desktop.
Save icot/c0b4dfc5760064e629653d1d913a9fd4 to your computer and use it in GitHub Desktop.
HTB Ownership computation
#!/usr/bin/env python3
from termcolor import colored
ASOwns = 3
AUOwns = 3
COwns = 34
AMs = 20
Challenges = 62
ownership = (ASOwns + (AUOwns / 2) + (COwns / 10)) / (AMs + (AMs / 2) + (Challenges / 10)) * 100
print("Current Ownership: {}".format(ownership))
st = "O/C "
maxTargetChallenges = 15
for chall in range(maxTargetChallenges + 1):
st += "| +{:2d} |".format(chall)
print(st)
print("-"*149)
for ASOwns in range(ASOwns, AMs+1):
AUOwns = ASOwns
st = "{:2d} ".format(ASOwns)
for targetChallenges in range(maxTargetChallenges + 1):
ownership = (ASOwns + (AUOwns / 2) + ((COwns + targetChallenges) / 10)) / (AMs + (AMs / 2) + (Challenges / 10)) * 100
if ownership > 90:
st += "| " + colored("{:3.2f}".format(ownership), "red") + " |"
elif ownership > 70.0:
st += "| " + colored("{:3.2f}".format(ownership), "green") + " |"
elif ownership > 45.0:
st += "| " + colored("{:3.2f}".format(ownership), "blue") + " |"
else:
st += "| {:3.2f} |".format(ownership)
print(st)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment