from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "checkio",
                       "js": "luckyTickets"
                   }).on_ready)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

cover = """def cover(f, data):
    return f(tuple(tuple(row) for row in data[0]), data[1], data[2])
"""

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover,
            'python-3': cover
        },
        function_name="count_neighbours"
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_codes.unwrap_args,  # or None
            'python-3': cover_codes.unwrap_args
        },
        function_name="checkio"
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
from tests import TESTS

class CheckiORefereeCode(CheckiOReferee):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
    def check_current_test(self, data):
        self.current_test["code"] = self.code

        if data['result'] == self.code:
            self.current_test["result"] = True
            api.request_write_ext(self.current_test)
            return api.success(0)
        else:
            message = 'quine() returned different string.'
            self.current_test["result"] = False
            self.current_test["result_addon"] = message
            api.request_write_ext(self.current_test)
            return api.fail(0, message)

api.add_listener(
    ON_CONNECT,
    CheckiORefereeCode(
        tests=TESTS,
        cover_code={
            'python-27': cover_codes.unwrap_args,
            'python-3': cover_codes.unwrap_args
        },
        function_name="quine",
    ).on_ready)
class CheckiORefereeCodeScore(CheckiORefereeCode):


    def check_current_test(self, data):

        test_result = data["result"]["code_result"]
        best_gifts, bag_count, gift_count = test_result
        self.current_test["result_addon"] = test_result

        self.current_test["result"] = bool(best_gifts)
        self.current_test["result_message"] = "You won {:n} best gifts from {:n} bags with {:,} gifts!".format(
            best_gifts, bag_count, gift_count)

        api.request_write_ext(self.current_test)

        if not self.current_test["result"]:
            return api.fail(self.current_step, self.get_current_test_fullname())
        api.success(best_gifts)



api.add_listener(
    ON_CONNECT,
    CheckiORefereeCodeScore(
        tests=TESTS,
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
            return False, "Your die must have the same total as the opponent's."

        if min(player) <= 0:
            return False, "Each side of your die must have a positive (greater than 0) number on it."
    except (TypeError, ValueError):
        return False, "Your die must be a single list of integers."

    total = 0
    for p in player:
        for e in enemy[0]:
            if p < e:
                total -= 1
            elif p > e:
                total += 1

    if total > 0:
        if enemy[1]:
            return True, ""
        else:
            return (
                False,
                "The test data says this shouldn't be possible. Please let us know so we can correct our tests.",
            )
    elif total == 0:
        return False, "This is only a tie. You need to find a die that can win."
    else:
        return False, "This is a loss. You need to find a die that can win."


api.add_listener(ON_CONNECT, CheckiOReferee(tests=TESTS, checker=verify, function_name="winning_die").on_ready)
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS


cover_code = """def cover(f, data):
    res = f(tuple(data))
    if not isinstance(res, (tuple, list)):
        raise TypeError("the result must be a list or a tuple.")
    print("====================")
    print(res[0])
    return res, ("[" + ", ".join('{0:f}'.format(r) for r in res) + "]")"""

def str_results(answer, user_result):
    return answer == user_result[0], user_result[1]

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_code,  # or None
            'python-3': cover_code
        },
        checker=str_results,
        DEFAULT_FUNCTION_NAME="divide_pie"
    ).on_ready)
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

cover_output = '''
def cover(func, in_data):
    return list(func(*in_data))
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "weekly_calendar",
                       "js": "weeklyCalendar"
                   },
                   cover_code={
                       'python-3': cover_output,
                       'js-node': cover_codes.js_unwrap_args
                   }).on_ready)
Esempio n. 9
0
        add_close_builtins -- some closed builtin words, as example, if you want, you can close "eval"
        remove_allowed_modules -- close standard library modules, as example "math"

checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "reverse_roman",
                       "js": "reverseRoman"
                   }).on_ready)
Esempio n. 10
0
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

cover_code = '''
import types
def cover(func, in_data):
    res = func(set(in_data))
    assert isinstance(res, types.GeneratorType), "your function should be a generator"
    
    return list(res)
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "flat_list"
                   },
                   cover_code={
                       'python-3': cover_code
                   }).on_ready)
        add_close_builtins -- some closed builtin words, as example, if you want, you can close "eval"
        remove_allowed_modules -- close standard library modules, as example "math"

checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "bigger_together",
                       "js": "biggerTogether"
                   }).on_ready)
Esempio n. 12
0
checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_codes.unwrap_args,  # or None
            'python-3': cover_codes.unwrap_args
        },
        DEFAULT_FUNCTION_NAME="index_power"
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
        next_cities = {c}
        done_cities = {c}
        for _ in range(p):
            for nx in set(next_cities):
                next_cities |= net_dic[nx]
            next_cities -= done_cities
            done_cities |= next_cities
        powered_cities |= done_cities
    return not all_cities - powered_cities, (user_answer, 'Success')


cover = '''
def cover(func, args):
    network, ranges = args
    network = set(map(tuple, network))
    return func(network, ranges)
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   checker=checker,
                   function_name={
                       "python": "power_plants",
                       "js": "powerPlants"
                   },
                   cover_code={
                       'python-3': cover,
                       'js-node': cover_codes.js_unwrap_args
                   }).on_ready)
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import checkers
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   cover_code={
                       'js-node': cover_codes.js_unwrap_args,
                       'python-3': cover_codes.unwrap_args
                   },
                   function_name={
                       "python": "painting",
                       "js": "painting"
                   }).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

cover = """
def cover(func, in_data):
    return bool(func(in_data))
"""
api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   cover_code={
                       "python-27": cover,
                       "python-3": cover,
                   }).on_ready)
            verification_payload = {'sid': 'MMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}
            return MessageInstance(
                mock_message_create._version,
                verification_payload,
                account_sid=mock_message_create._solution['account_sid'],
            )
        mock_message_create.side_effect = mock_message_create_side_effect    
        ret = func(*in_data)
        mock_message_create.assert_called_once()
        return mock_message_create.call_args[1]
'''


from checkio import api
from checkio.signals import ON_CONNECT
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "send_message"
        },
        cover_code={
           'python-3': TWILIO_COVER
        }
    ).on_ready)
checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        #cover_code={
        #    'python-27': cover,
        #    'python-3': cover
        #},
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
Esempio n. 18
0
checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import checkers
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   checker=checkers.float_comparison(4),
                   cover_code={
                       'python-27': cover_codes.unwrap_args,
                       'python-3': cover_codes.unwrap_args
                   },
                   function_name="probability").on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

cover_tuple = """

def cover(func, in_data):
    return func(tuple(in_data))

"""


from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_tuple,
            'python-3': cover_tuple
        }).on_ready)
Esempio n. 20
0
        if (ee.length === 2) {
            return [new Date(ee[0][0], ee[0][1], ee[0][2], ee[0][3], ee[0][4], ee[0][5]), ee[1]];
        } else {
            return new Date(ee[0], ee[1], ee[2], ee[3], ee[4], ee[5]);
        }
    });
    var start_watching, end_watching;
    if (in_data.length > 1) {
        start_watching = new Date(in_data[1][0], in_data[1][1], in_data[1][2], in_data[1][3], in_data[1][4], in_data[1][5]);
    }
    if (in_data.length > 2) {
        end_watching = new Date(in_data[2][0], in_data[2][1], in_data[2][2], in_data[2][3], in_data[2][4], in_data[2][5]);
    }
    return func(els, start_watching, end_watching);
}
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "sum_light",
            "js": "sumLight"
        },
        cover_code={
            'python-3': all_datetime_py,
            'js-node': all_datetime_js
        }
    ).on_ready)
"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

cover = """def cover(f, data):
    return [[[str(ch) for ch in row] for row in grid] for grid in data]
"""


api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover,
            'python-3': None
        },
        DEFAULT_FUNCTION_NAME="check_cube"
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
Esempio n. 22
0
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_codes.unwrap_args,  # or None
            'python-3': cover_codes.unwrap_args
        }).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee


cover = """def cover(func, in_data):
    return func(tuple(tuple(row) for row in in_data))
"""

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   cover_code={
                       'python-27': cover,  # or None
                       'python-3': cover
                   },
                   function_name="count_gold"
    ).on_ready)
Esempio n. 24
0
            digits after coma.
checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.
"""

from checkio import api
from checkio.signals import ON_CONNECT
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from tests import TESTS

cover_set_input = '''
def cover(func, in_data):
    return sorted(func(set(in_data)))
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       'python': 'landing_site',
                       'js': 'landingSite',
                   },
                   cover_code={
                       'python-3': cover_set_input,
                       'js-node': cover_codes.js_unwrap_args,
                   }).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.code import CheckiORefereeCode
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiORefereeCode(
        tests=TESTS,
        # add_allowed_modules=[],
        add_close_builtins=["import", "__import__", "eval", "exec", "min", "max"],
        # remove_allowed_modules=[]
    ).on_ready)
Esempio n. 26
0
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "best_plates"
        },
        cover_code={
            'python-3': cover_codes.unwrap_args
        }
    ).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS


api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "flat_list",
            "js": "flatList"
        }
    ).on_ready)
Esempio n. 28
0
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.signals import ON_CONNECT

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "checkio",
                       "js": "goodRadix",
                   }).on_ready)
    dist = round(((user_result[0] - ore[0]) ** 2 + (user_result[1] - ore[1]) ** 2) ** 0.5)
    referee_data["probes"] -= 1
    if referee_data["probes"] == 0:
        referee_data.update({
            "result": False,
            "result_addon": "It was last probe.",
            "explanation": dist
        })
        return referee_data
    referee_data["input"].append([row, col, dist])
    referee_data.update({
        "result": True,
        "result_addon": "Next step.",
        "explanation": dist,

    })
    return referee_data


def is_win_referee(referee_data):
    return referee_data["explanation"] == 0

api.add_listener(
    ON_CONNECT,
    CheckiORefereeMulti(
        tests=TESTS,
        initial_referee=initial_referee,
        process_referee=process_referee,
        is_win_referee=is_win_referee,
    ).on_ready)
Esempio n. 30
0
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "find_enemy",
            "js": "findEnemy"
        },
        cover_code={
            'python-27': cover_codes.unwrap_args,
            'python-3': cover_codes.unwrap_args,
            'js-node': cover_codes.js_unwrap_args
        }
    ).on_ready)
def ext_checker(values, user_result):
    if not isinstance(user_result, (float, int)):
        return False, "The result should be a float or an integer.", 0
    # if (not 0 <= user_result[0] < 10 or not 0 <= user_result[1] < 10):
    #     return False, "The prediction coordinates should be from 0 to 10.", 0
    score_distance = (max(values) - min(values)) * SCORE_DIST
    distance = abs(user_result - values[-1])
    score = 0 if distance >= score_distance else round(100 * ((score_distance - distance) / score_distance))
    return True, "Next", score

cover = """def cover(f, data):
    return f(tuple(data))
"""


api.add_listener(
    ON_CONNECT,
    CheckioRefereePrediction(
        tests=TESTS,
        cover_code={
            'python-27': cover,
            'python-3': cover
        },
        checker=ext_checker,  # checkers.float.comparison(2)
        function_name="predict_ghost"
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-3': cover_codes.unwrap_args,
            'js-node': cover_codes.js_unwrap_args
        },
        checker=checkers.float_comparison(2),
        function_name={
            "python": "simple_areas",
            "js": "simpleAreas"
        }
    ).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

cover = """def cover(func, data):
    return list(func(data))
"""

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover,
            'python-3': cover
        },
        function_name={
            "python": "checkio",
            "js": "nonUniqueElements"
        }
    ).on_ready)
checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

cover_both = '''

def cover(func, in_data):
    return func(in_data[0], **in_data[1])

'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_both,  # or None
            'python-3': cover_both
        },
        DEFAULT_FUNCTION_NAME='friendly_number').on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name="longest_palindromic").on_ready)
Esempio n. 36
0
        add_allowed_modules -- additional module which will be allowed for your task.
        add_close_builtins -- some closed builtin words, as example, if you want, you can close "eval"
        remove_allowed_modules -- close standard library modules, as example "math"

checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "all_the_same",
                       "js": "allTheSame"
                   }).on_ready)
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS


cover = """def cover(func, data):
    return func(data[0], set(data[1]))
"""


api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover,  # or None
            'python-3': cover,
            'js-node': cover_codes.js_unwrap_args
        },
        function_name={
            "python": "berserk_rook",
            "js": "berserkRook"
        }
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
    ghost += DIRS[ghost_move]
    if ghost == stephan:
        referee_data.update({"result": False, "result_addon": 'The ghost caught Stephan.', "ghost": ghost,
                             "ghost_move": ghost_move, })
        return referee_data
    referee_data.update({"result": True,
                         "result_addon": 'Next move.',
                         "ghost": ghost,
                         "ghost_move": ghost_move,
                         "input": [house, stephan, ghost],
                         "wall": False})
    return referee_data


def is_win_referee(referee_data):
    return referee_data['stephan'] == 0


api.add_listener(
    ON_CONNECT,
    CheckiORefereeMulti(
        tests=TESTS,
        initial_referee=initial_referee,
        process_referee=process_referee,
        is_win_referee=is_win_referee,
        cover_code={
            "python-27": unwrap_args,
            "python-3": unwrap_args
        }
    ).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from checkio.referees.cover_codes import unwrap_args

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': unwrap_args,  # or None
            'python-3': unwrap_args
        },
        function_name='convert'
    ).on_ready)
Esempio n. 40
0
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

cover = """def cover(f, data):
    return f(tuple(tuple(row) for row in data[0]), data[1])
"""

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover,
            'python-3': cover,
            'js-node': cover_codes.js_unwrap_args
        },
        function_name={
            "python": "life_counter",
            "js": "lifeCounter"
        }
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
from checkio import api
from checkio.referees.io import CheckiOReferee
from .golf import CheckiORefereeGolf
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

INSPECTOR_ERROR = "Your code maybe returns correct answers, but it contains forbidden characters."
INSPECTOR_OK = "OK"


def inspector(code, _):
    for c in 'aiou':
        if c in code:
            return False, INSPECTOR_ERROR
    return True, INSPECTOR_OK


api.add_listener(
    ON_CONNECT,
    CheckiORefereeGolf(
        tests=TESTS,
        inspector=inspector,
        cover_code={
            'python-27': None,
            'python-3': None
        },
        function_name="e_fecterel",
    ).on_ready)
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "stone_wall",
            "js": "stoneWall"
        },
        cover_code={
            #'python-3': cover_codes.unwrap_args,
            #'js-node': cover_codes.js_unwrap_args
        }).on_ready)
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from golf import CheckioRefereeGolf
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckioRefereeGolf(
        tests=TESTS,
        function_name="recognize",
        max_length=200
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
                     list(prev_rects))
        assert grid_area is not None, (f'{rect} contains no area value.',
                                       list(prev_rects))

    nb_uncovered = sum(not cell for row in colored_grid for cell in row)
    assert not nb_uncovered, (f'{nb_uncovered} cells are still not covered.',
                              list(prev_rects))


dumb_cover_just_to_accept_sets = '''
def cover(func, in_data):
    return list(func(in_data))
'''


api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        checker=checker,
        function_name={
            'python': 'rectangles',
            # 'js': 'rectangles',
        },
        cover_code={
            'python-3': dumb_cover_just_to_accept_sets,
            # 'js-node': ...,
        },
    ).on_ready,
)
    if not best_size and user_result:
        return False, "Where did you find a cycle here?"
    if not best_size and not user_result:
        return True, "Ok"
    if len(user_result) < best_size + 1:
        return False, "You can find a better loop."
    if user_result[0] != user_result[-1]:
        return False, "A cycle starts and ends in the same node."
    if len(set(user_result)) != len(user_result) - 1:
        return False, "Repeat! Yellow card!"
    for n1, n2 in zip(user_result[:-1], user_result[1:]):
        if [n1, n2] not in connections and [n2, n1] not in connections:
            return False, "{}-{} is not exist".format(n1, n2)
    return True, "Ok"


api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover,
            'python-3': cover
        },
        checker=checker,
        function_name="find_cycle"
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
Esempio n. 46
0
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

cover_iterable = '''
def cover(func, in_data):
    return list(func(*in_data))
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "expand_intervals",
                       "js": "expandIntervals"
                   },
                   cover_code={
                       'python-3': cover_iterable,
                       'js-node': cover_codes.js_unwrap_args
                   }).on_ready)
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

cover_both = '''

def cover(func, in_data):
    return func(in_data[0], **in_data[1])

'''


api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_both,  # or None
            'python-3': cover_both
        },
        DEFAULT_FUNCTION_NAME='friendly_number'
    ).on_ready)
            digits after coma.
checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.
"""

from checkio import api
from checkio.signals import ON_CONNECT
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from tests import TESTS

tuple_cover = '''
def cover(func, in_data):
    return func(tuple(in_data))
'''

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       'python': 'permutation_index',
                       'js': 'permutationIndex',
                   },
                   cover_code={
                       'python-3': tuple_cover,
                       'js-node': cover_codes.js_unwrap_args,
                   }).on_ready)
Esempio n. 49
0
            instead simple "==" will be using the checker function which return tuple with result
            (false or true) and some additional info (some message).
            You can use some predefined codes from checkio.referee.checkers
        add_allowed_modules -- additional module which will be allowed for your task.
        add_close_builtins -- some closed builtin words, as example, if you want, you can close "eval"
        remove_allowed_modules -- close standard library modules, as example "math"

checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS).on_ready)
Esempio n. 50
0
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        #cover_code={
        #    'python-27': cover_codes.unwrap_args,  # or None
        #    'python-3': cover_codes.unwrap_args
        #},
        # checker=None,  # checkers.float.comparison(2)
        # add_allowed_modules=[],
        # add_close_builtins=[],
        # remove_allowed_modules=[]
    ).on_ready)
Esempio n. 51
0
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import checkers
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        checker=checkers.float_comparison(4),
        cover_code={
            'python-27': cover_codes.unwrap_args,
            'python-3': cover_codes.unwrap_args
        }
        ).on_ready)
Esempio n. 52
0
        cover_code -- is a wrapper for the user function and additional operations before give data
            in the user function. You can use some predefined codes from checkio.referee.cover_codes
        checker -- is replacement for the default checking of an user function result. If given, then
            instead simple "==" will be using the checker function which return tuple with result
            (false or true) and some additional info (some message).
            You can use some predefined codes from checkio.referee.checkers
        add_allowed_modules -- additional module which will be allowed for your task.
        add_close_builtins -- some closed builtin words, as example, if you want, you can close "eval"
        remove_allowed_modules -- close standard library modules, as example "math"

checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(ON_CONNECT, CheckiOReferee(tests=TESTS).on_ready)
Esempio n. 53
0
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee




api.add_listener(ON_CONNECT, CheckiOReferee([
        ["Basics",[
                ['2+3=?', [2,3], 5, 'EXT1'],
                ['2+7=?', [2,7], 9]
            ]
        ],
        ["Addition",[
                ['6+3=?', [6,3], 9],
                ['6+7=?', [6,7], 13, 'EXT2']
            ]
        ]
    ]).on_ready)
Esempio n. 54
0
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "sum_numbers",
                       "js": "sumNumbers"
                   },
                   cover_code={
                       'python-3': cover_codes.unwrap_args,
                       'js-node': cover_codes.js_unwrap_args
                   }).on_ready)
checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers
from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        # cover_code={
        #     'python-27': cover_codes.unwrap_args,  # or None
        #     'python-3': cover_codes.unwrap_args
        # },
        function_name="cowsay"
    ).on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS, function_name="letter_queue").on_ready)
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name="simplify").on_ready)
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        cover_code={
            'python-27': cover_codes.unwrap_args,  # or None
            'python-3': cover_codes.unwrap_args
        },
        function_name="chase",
        checker=checkers.float_comparison(8)
    ).on_ready)
checkio.referee.checkers
    checkers.float_comparison -- Checking function fabric for check result with float numbers.
        Syntax: checkers.float_comparison(digits) -- where "digits" is a quantity of significant
            digits after coma.

checkio.referee.cover_codes
    cover_codes.unwrap_args -- Your "input" from test can be given as a list. if you want unwrap this
        before user function calling, then using this function. For example: if your test's input
        is [2, 2] and you use this cover_code, then user function will be called as checkio(2, 2)
    cover_codes.unwrap_kwargs -- the same as unwrap_kwargs, but unwrap dict.

"""

from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee
from checkio.referees import cover_codes
from checkio.referees import checkers

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(
        tests=TESTS,
        function_name={
            "python": "checkio",
            "js": "digitsMultip"
        }).on_ready)
Esempio n. 60
0
from checkio.signals import ON_CONNECT
from checkio import api
from checkio.referees.io import CheckiOReferee

from tests import TESTS

api.add_listener(
    ON_CONNECT,
    CheckiOReferee(tests=TESTS,
                   function_name={
                       "python": "checkio",
                       "js": "stripedWords"
                   }).on_ready)