Ejemplo n.º 1
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        out = solution(self.is_dead, self.number_of_cows)

        is_success = out == self.dragon_coming_to

        return CasePerformance(is_successful=is_success,
                               performance=self.looks)
Ejemplo n.º 2
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        out = solution(self.throw_attempt)

        is_success = (out == self.max_floor) and \
                     (not self.attempted_after_ran_out)

        return CasePerformance(is_successful=is_success,
                               performance=self.attempts)
Ejemplo n.º 3
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = 0
        for word in self.list_of_words:
            if self.letter.lower() in word.lower():
                true_solution += 1

        out = solution(self.list_of_words, self.letter)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 4
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = 0
        for x in set(self.list_of_numbers):
            if ((x % 2) != 0) and (x > 0):
                true_solution += x

        out = solution(self.list_of_numbers)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 5
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = ""

        for w in self.list_of_words:
            if (max(Counter(w.lower()).values(), default=0) >=
                    3) and (len(w) > len(true_solution)):
                true_solution = w

        out = solution(self.list_of_words)
        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 6
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = 0

        for n in self.list_of_numbers:
            if (n - self.number) % 3 == 0:
                true_solution = n

        out = solution(self.list_of_numbers, self.number)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 7
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = -1
        top_num_as = 0
        for idx, word in enumerate(self.list_of_words):
            act = sum([l.lower() == "a" for l in word])
            if act > top_num_as:
                true_solution = idx
                top_num_as = act

        out = solution(self.list_of_words)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 8
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = ""
        max_num = 0
        for word in self.list_of_words:
            letter_count = sum(
                [ll == self.letter.lower() for ll in word.lower()])
            if letter_count > max_num:
                max_num = letter_count
                true_solution = word

        out = solution(self.list_of_words, self.letter)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 9
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        sorted_nums = sorted(self.list_of_numbers)

        out = solution(self.list_of_numbers)

        bot_multi = sorted_nums[-1] * sorted_nums[-2]
        top_multi = sorted_nums[0] * sorted_nums[1]

        if bot_multi > top_multi:
            true_solution = bot_multi
        else:
            true_solution = top_multi

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 10
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        filtered = [
            x for x in self.list_of_numbers
            if ((x * 2) in self.list_of_numbers)
        ]

        try:
            true_solution = min(filtered)
        except ValueError:
            true_solution = 0

        out = solution(self.list_of_numbers)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 11
0
    def _evaluate(self, solution: Callable) -> CasePerformance:
        def check_sorted(num):
            sl = sorted(str(abs(num)))
            return "".join(sl) == str(abs(num))

        filtered = [x for x in self.list_of_numbers if check_sorted(x)]

        try:
            true_solution = max(filtered)
        except ValueError:
            true_solution = 0

        out = solution(self.list_of_numbers)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))
Ejemplo n.º 12
0
    def _evaluate(self, solution: Callable) -> CasePerformance:

        true_solution = None

        for n in self.list_of_numbers:
            if (n / self.number) % 2 == 0:
                if true_solution is None:
                    true_solution = n
                elif n > true_solution:
                    true_solution = n

        if true_solution is None:
            true_solution = 0

        out = solution(self.list_of_numbers, self.number)

        is_success = out == true_solution

        return CasePerformance(is_successful=is_success,
                               performance=int(is_success))