コード例 #1
0
def BruteForceGuessOrDie(problem, programs):
    while programs:
        program = programs.pop(0)
        logging.info('=== [%d] %s', len(programs) + 1, program)
        try:
            example = api.Guess(problem.id, program)
        except api.Solved:
            logging.info('')
            logging.info(u'*\u30fb\u309c\uff9f\uff65*:.\uff61. '
                         u'SOLVED!'
                         u' .\uff61.:*\uff65\u309c\uff9f\uff65*:')
            logging.info('')
            return
        if example:
            logging.info(
                'rejected. argument=0x%016x, expected=0x%016x, actual=0x%016x',
                example.argument, example.expected, example.actual)
            if FLAGS.counterexample_filter:
                programs = FilterProgramsWithCounterExample(programs, example)
        else:
            logging.info('rejected, but could not get a counterexample.')
    logging.error('************************************')
    logging.error('NO PROGRAM WAS ACCEPTED. DEAD END...')
    logging.error('************************************')
    sys.exit(1)
コード例 #2
0
def Guess(problem, program, detail):
    logging.info('=== %s', program)
    print >> detail, 'program:', program
    detail.flush()

    example = api.Guess(problem.id, program)
    if example:
        logging.info(
            'rejected. argument=0x%016x, expected=0x%016x, actual=0x%016x',
            example.argument, example.expected, example.actual)
        print >> detail, '=> rejected. argument=0x%016x, expected=0x%016x, actual=0x%016x' % (
            example.argument, example.expected, example.actual)
        detail.flush()
        return example
    logging.info('rejected, but could not get a counterexample.')
    print >> detail, '=> rejected, but could not get a counterexample.'
    detail.flush()
    return None
コード例 #3
0
ファイル: lisbeth.py プロジェクト: nya3jp/icfpc2013
def BruteForceGuessOrDie(problem, programs):
    for program in programs:
        logging.info('=== %s', program)
        try:
            example = api.Guess(problem.id, program)
            if example:
                logging.info(
                    'rejected. argument=0x%016x, expected=0x%016x, actual=0x%016x',
                    example.argument, example.expected, example.actual)
            else:
                logging.info('rejected, but could not get a counterexample.')
        except api.Solved:
            logging.info('')
            logging.info(u'*\u30fb\u309c\uff9f\uff65*:.\uff61. '
                         u'SOLVED!'
                         u' .\uff61.:*\uff65\u309c\uff9f\uff65*:')
            logging.info('')
            return
    logging.error('************************************')
    logging.error('NO PROGRAM WAS ACCEPTED. DEAD END...')
    logging.error('************************************')
    sys.exit(1)