Skip to content

Instantly share code, notes, and snippets.

@potetisensei
Created December 1, 2018 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save potetisensei/a17d9eadb7c320f3f868b60f73cf0c02 to your computer and use it in GitHub Desktop.
Save potetisensei/a17d9eadb7c320f3f868b60f73cf0c02 to your computer and use it in GitHub Desktop.
Script for create scoring functions in CODE BLUE CTF 2018 Finals
from math import floor
# For JNI, Fliqpy, EasyExample
#base = 50
#div = [3, 6, 6, 6, 10, 15, 15, 15, 15, 9]
# For CTC, OSS, Account
base = 0
div = [2.5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 2.5]
assert(sum(div) == 100)
n = len(div)
result = 'if succeeded == 0 then 0 elsif '
cur = 0
score = base
for k in div[:-1]:
cur += k
score += ((100-base)/n)
result += 'succeeded <= ((succeeded+failed) * {} / 100) then {} elsif '.format(cur, floor(score))
score += ((100-base)/n)
assert (int(score) == 100)
result += 'succeeded < (succeeded+failed) then 99 else 100 end'
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment