Capture The Flag

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

CTF stands for Capture The Flag. After all, what else could CTF stand for?

Many problems have long flavour texts that are 'interesting', 'fun to read', and 'help you understand the problem'. In this problem, we cut out the middleman and provide you with the checker directly.

from re import split as resplit
from dmoj.utils.unicode import utf8bytes

OFFSET = [REDACTED]
goal = [20, 50, 54, 68, 54, 67, 20, 58, 65, 57, 4, 67, 16]

def is_valid(s):
    if len(s) != 13:
        return False

    for c in s:
        if not (32 <= c <= 127):
            return False

    return True

def check(process_output, judge_output, judge_input, **kwargs):
    process_lines = list(filter(None, resplit(b'[\r\n]', utf8bytes(process_output))))

    if len(process_lines) != 1:
        return False

    s = process_lines[0] #s is a byte string

    if not is_valid(s):
        return False

    for i in range(13):
        if goal[i] + OFFSET != s[i]:
            return False

    return True

Comments

There are no comments at the moment.