From 5e2393219aec517b76892a325d9524a929ebde93 Mon Sep 17 00:00:00 2001 From: alex28sh Date: Fri, 29 Nov 2024 10:33:52 +0100 Subject: [PATCH] pure helpers + text descriptions --- Bench/000-has-close-elements.py | 14 +++---- Bench/001-separate-paren-groups.py | 12 +++--- Bench/003-below-zero.py | 6 +-- Bench/005-intersperse.py | 2 +- Bench/006-parse_nested_parens.py | 10 ++--- Bench/007-filter_by_substring.py | 8 ++-- Bench/008-sum-product.py | 10 ++--- Bench/009-rolling-max.py | 6 +-- Bench/010-is_palindrome.py | 8 ++-- Bench/011-string_xor.py | 6 +-- Bench/012-longest.py | 6 +-- Bench/013-greatest-common-divisor.py | 2 +- Bench/016-count_distinct_characters.py | 10 ++--- Bench/020-find-closest-elements.py | 8 ++-- Bench/023-strlen.py | 2 +- Bench/024-largest-divisor.py | 2 +- Bench/026-remove_duplicates.py | 12 +++--- Bench/027-flip_case.py | 17 ++++---- Bench/029-filter_by_prefix.py | 10 ++--- Bench/030-get-positive.py | 2 +- Bench/031-is-prime.py | 2 +- Bench/033-sort_third.py | 2 +- Bench/034-unique.py | 4 +- Bench/036-fizz_buzz.py | 8 ++-- Bench/037-sort_even.py | 2 +- Bench/038-encode_cyclic.py | 2 +- Bench/040-triples-sum-to-zero.py | 2 +- Bench/043-pairs-sum-to-zero.py | 2 +- Bench/046-fib4.py | 4 +- Bench/049-modp.py | 4 +- Bench/050-encode_shift.py | 10 +++-- Bench/053-add.py | 2 +- Bench/054-same-chars.py | 2 +- Bench/055-fib.py | 6 +-- Bench/056-correct_bracketing.py | 6 +-- Bench/057-monotonic.py | 2 +- Bench/058-common.py | 8 ++-- Bench/059-largest-prime-factor.py | 6 +-- Bench/060-sum-to-n.py | 6 +-- Bench/063-fibfib.py | 4 +- Bench/064-vowel_count.py | 8 ++-- Bench/066-digitSum.py | 4 +- Bench/069-search.py | 5 ++- Bench/072-will_it_fly.py | 8 ++-- Bench/073-smallest_change.py | 6 +-- Bench/075-is_multiply_prime.py | 4 +- Bench/078-hex_key.py | 9 ++-- Bench/080-is_happy.py | 8 ++-- Bench/082-prime-length.py | 2 +- Bench/083-starts_one_ends.py | 4 +- Bench/084-solve.py | 4 +- Bench/085-add.py | 4 +- Bench/089-encrypt.py | 7 ++-- Bench/092-any_int.py | 2 +- Bench/093-encode.py | 12 +++--- Bench/096-count_up_to.py | 4 +- Bench/097-multiply.py | 5 ++- Bench/098-count_upper.py | 8 ++-- Bench/104-unique_digits.py | 8 ++-- Bench/105-by_length.py | 10 ++--- Bench/106-f.py | 10 ++--- Bench/108-count_nums.py | 12 +++--- Bench/109-move_one_ball.py | 5 ++- Bench/110-exchange.py | 9 ++-- Bench/112-reverse_delete.py | 16 +++---- Bench/114-minSubArraySum.py | 4 +- Bench/116-sort_array.py | 4 +- Bench/118-get_closest_vowel.py | 8 ++-- Bench/119-match_parens.py | 6 +-- Bench/121-solution.py | 4 +- Bench/122-add_elements.py | 6 +-- Bench/123-get_odd_collatz.py | 11 +++-- Bench/126-is_sorted.py | 5 +-- Bench/127-intersection.py | 15 ++++--- Bench/128-prod_signs.py | 13 +++--- Bench/133-sum-squares.py | 4 +- Bench/134-check_if_last_char_is_a_letter.py | 4 +- Bench/136-largest_smallest_integers.py | 4 +- Bench/139-special_factorial.py | 8 ++-- Bench/142-sum_squares.py | 9 ++-- Bench/146_specialFilter.py | 8 ++-- Bench/150-x_or_y.py | 4 +- Bench/151-double_the_difference.py | 13 +++--- Bench/152-compare.py | 4 +- Bench/154-cycpattern_check.py | 6 +-- Bench/155_even_odd_count.py | 8 ++-- Bench/159-eat.py | 2 +- Bench/161-solve.py | 8 ++-- Bench/163-generate_integers.py | 42 +++++++------------ .../000-has-close-elements.txt | 3 ++ .../001-separate-paren-groups.txt | 3 ++ Bench/text-descriptions/002-truncate.txt | 3 ++ Bench/text-descriptions/003-below-zero.txt | 3 ++ .../004-mean_absolute_derivation.txt | 3 ++ Bench/text-descriptions/005-intersperse.txt | 3 ++ .../006-parse_nested_parens.txt | 3 ++ .../007-filter_by_substring.txt | 3 ++ Bench/text-descriptions/008-sum-product.txt | 3 ++ Bench/text-descriptions/009-rolling-max.txt | 3 ++ Bench/text-descriptions/010-is_palindrome.txt | 4 ++ Bench/text-descriptions/011-string_xor.txt | 3 ++ Bench/text-descriptions/012-longest.txt | 3 ++ .../013-greatest-common-divisor.txt | 3 ++ Bench/text-descriptions/014-all_prefixes.txt | 3 ++ .../016-count_distinct_characters.txt | 3 ++ .../text-descriptions/018-how_many_times.txt | 3 ++ .../020-find-closest-elements.txt | 3 ++ .../text-descriptions/021-rescale_to_unit.txt | 3 ++ Bench/text-descriptions/023-strlen.txt | 3 ++ .../text-descriptions/024-largest-divisor.txt | 3 ++ Bench/text-descriptions/025-factorize.txt | 3 ++ .../026-remove_duplicates.txt | 3 ++ Bench/text-descriptions/027-flip_case.txt | 3 ++ .../029-filter_by_prefix.txt | 3 ++ Bench/text-descriptions/030-get-positive.txt | 3 ++ Bench/text-descriptions/031-is-prime.txt | 3 ++ Bench/text-descriptions/033-sort_third.txt | 3 ++ Bench/text-descriptions/034-unique.txt | 3 ++ Bench/text-descriptions/035-max-element.txt | 3 ++ Bench/text-descriptions/036-fizz_buzz.txt | 3 ++ Bench/text-descriptions/037-sort_even.txt | 3 ++ Bench/text-descriptions/038-encode_cyclic.txt | 4 ++ .../040-triples-sum-to-zero.txt | 3 ++ .../041-car_race_collision.txt | 3 ++ Bench/text-descriptions/042-incr-list.txt | 3 ++ .../043-pairs-sum-to-zero.txt | 3 ++ Bench/text-descriptions/045-triangle_area.txt | 3 ++ Bench/text-descriptions/046-fib4.txt | 3 ++ Bench/text-descriptions/048-is-palindrome.txt | 3 ++ Bench/text-descriptions/048-is_palindrome.txt | 3 ++ Bench/text-descriptions/049-modp.txt | 3 ++ Bench/text-descriptions/050-encode_shift.txt | 4 ++ Bench/text-descriptions/051-remove-vowels.txt | 3 ++ .../text-descriptions/052-below-threshold.txt | 3 ++ Bench/text-descriptions/053-add.txt | 3 ++ Bench/text-descriptions/054-same-chars.txt | 3 ++ Bench/text-descriptions/055-fib.txt | 3 ++ .../056-correct_bracketing.txt | 3 ++ Bench/text-descriptions/057-monotonic.txt | 3 ++ Bench/text-descriptions/058-common.txt | 3 ++ .../059-largest-prime-factor.txt | 3 ++ Bench/text-descriptions/060-sum-to-n.txt | 3 ++ Bench/text-descriptions/062-derivative.txt | 3 ++ Bench/text-descriptions/063-fibfib.txt | 3 ++ Bench/text-descriptions/064-vowels-count.txt | 3 ++ .../text-descriptions/065-circular_shift.txt | 3 ++ Bench/text-descriptions/066-digitSum.txt | 3 ++ Bench/text-descriptions/068-pluck.txt | 3 ++ Bench/text-descriptions/069-search.txt | 3 ++ .../070-strange_sort_list.txt | 3 ++ Bench/text-descriptions/072-will_it_fly.txt | 3 ++ .../text-descriptions/073-smallest_change.txt | 3 ++ Bench/text-descriptions/074-total_match.txt | 3 ++ .../075-is_multiply_prime.txt | 3 ++ .../text-descriptions/076-is_simple_power.txt | 3 ++ Bench/text-descriptions/077-iscube.txt | 3 ++ Bench/text-descriptions/078-hex_key.txt | 3 ++ .../079-decimal_to_binary.txt | 3 ++ Bench/text-descriptions/080-is_happy.txt | 3 ++ .../081-numerical_letter_grade.txt | 3 ++ Bench/text-descriptions/082-prime-length.txt | 3 ++ .../text-descriptions/083-starts_one_ends.txt | 3 ++ Bench/text-descriptions/084-solve.txt | 3 ++ Bench/text-descriptions/085-add.txt | 3 ++ Bench/text-descriptions/087-get_row.txt | 3 ++ Bench/text-descriptions/088-sort_array.txt | 3 ++ Bench/text-descriptions/089-encrypt.txt | 3 ++ Bench/text-descriptions/090-next_smallest.txt | 3 ++ Bench/text-descriptions/092-any_int.txt | 3 ++ Bench/text-descriptions/093-encode.txt | 3 ++ Bench/text-descriptions/094-skjkasdkd.txt | 3 ++ .../text-descriptions/095-check_dict_case.txt | 3 ++ Bench/text-descriptions/096-count_up_to.txt | 3 ++ Bench/text-descriptions/097-multiply.txt | 3 ++ Bench/text-descriptions/098-count_upper.txt | 3 ++ Bench/text-descriptions/100-make_a_pile.txt | 3 ++ Bench/text-descriptions/102-choose_num.txt | 3 ++ Bench/text-descriptions/104-unique_digits.txt | 3 ++ Bench/text-descriptions/105-by_length.txt | 3 ++ Bench/text-descriptions/106-f.txt | 3 ++ .../107-even_odd_palindrome.txt | 3 ++ Bench/text-descriptions/108-count_nums.txt | 3 ++ Bench/text-descriptions/109-move_one_ball.txt | 3 ++ Bench/text-descriptions/110-exchange.txt | 3 ++ Bench/text-descriptions/111-histogram.txt | 3 ++ .../text-descriptions/112-reverse_delete.txt | 3 ++ .../text-descriptions/114-minSubArraySum.txt | 3 ++ Bench/text-descriptions/115-max_fill.txt | 3 ++ Bench/text-descriptions/116-sort_array.txt | 3 ++ .../118-get_closest_vowel.txt | 3 ++ Bench/text-descriptions/119-match_parens.txt | 3 ++ Bench/text-descriptions/120-maximum.txt | 3 ++ Bench/text-descriptions/121-solution.txt | 3 ++ Bench/text-descriptions/122-add_elements.txt | 3 ++ .../text-descriptions/123-get_odd_collatz.txt | 3 ++ Bench/text-descriptions/126-is_sorted.txt | 3 ++ Bench/text-descriptions/127-intersection.txt | 3 ++ Bench/text-descriptions/128-prod_signs.txt | 3 ++ Bench/text-descriptions/130-tri.txt | 3 ++ Bench/text-descriptions/132-is_nested.txt | 3 ++ Bench/text-descriptions/133-sum-squares.txt | 3 ++ .../134-check_if_last_char_is_a_letter.txt | 3 ++ Bench/text-descriptions/135_can_arrange.txt | 3 ++ .../136-largest_smallest_integers.txt | 3 ++ .../138_is_equal_to_sum_even.txt | 3 ++ .../139-special_factorial.txt | 3 ++ Bench/text-descriptions/142-sum_squares.txt | 3 ++ .../text-descriptions/145-order_by_points.txt | 3 ++ Bench/text-descriptions/146_specialFilter.txt | 3 ++ Bench/text-descriptions/148-bf.txt | 3 ++ .../text-descriptions/149-sorted_list_sum.txt | 3 ++ Bench/text-descriptions/150-x_or_y.txt | 3 ++ .../151-double_the_difference.txt | 3 ++ Bench/text-descriptions/152-compare.txt | 3 ++ .../153-Strongest_Extension.txt | 3 ++ .../154-cycpattern_check.txt | 3 ++ .../text-descriptions/155_even_odd_count.txt | 3 ++ .../157-right_angle_triangle.txt | 3 ++ Bench/text-descriptions/158-find_max.txt | 3 ++ Bench/text-descriptions/159-eat.txt | 3 ++ Bench/text-descriptions/161-solve.txt | 3 ++ .../163-generate_integers.txt | 3 ++ 222 files changed, 706 insertions(+), 307 deletions(-) create mode 100644 Bench/text-descriptions/000-has-close-elements.txt create mode 100644 Bench/text-descriptions/001-separate-paren-groups.txt create mode 100644 Bench/text-descriptions/002-truncate.txt create mode 100644 Bench/text-descriptions/003-below-zero.txt create mode 100644 Bench/text-descriptions/004-mean_absolute_derivation.txt create mode 100644 Bench/text-descriptions/005-intersperse.txt create mode 100644 Bench/text-descriptions/006-parse_nested_parens.txt create mode 100644 Bench/text-descriptions/007-filter_by_substring.txt create mode 100644 Bench/text-descriptions/008-sum-product.txt create mode 100644 Bench/text-descriptions/009-rolling-max.txt create mode 100644 Bench/text-descriptions/010-is_palindrome.txt create mode 100644 Bench/text-descriptions/011-string_xor.txt create mode 100644 Bench/text-descriptions/012-longest.txt create mode 100644 Bench/text-descriptions/013-greatest-common-divisor.txt create mode 100644 Bench/text-descriptions/014-all_prefixes.txt create mode 100644 Bench/text-descriptions/016-count_distinct_characters.txt create mode 100644 Bench/text-descriptions/018-how_many_times.txt create mode 100644 Bench/text-descriptions/020-find-closest-elements.txt create mode 100644 Bench/text-descriptions/021-rescale_to_unit.txt create mode 100644 Bench/text-descriptions/023-strlen.txt create mode 100644 Bench/text-descriptions/024-largest-divisor.txt create mode 100644 Bench/text-descriptions/025-factorize.txt create mode 100644 Bench/text-descriptions/026-remove_duplicates.txt create mode 100644 Bench/text-descriptions/027-flip_case.txt create mode 100644 Bench/text-descriptions/029-filter_by_prefix.txt create mode 100644 Bench/text-descriptions/030-get-positive.txt create mode 100644 Bench/text-descriptions/031-is-prime.txt create mode 100644 Bench/text-descriptions/033-sort_third.txt create mode 100644 Bench/text-descriptions/034-unique.txt create mode 100644 Bench/text-descriptions/035-max-element.txt create mode 100644 Bench/text-descriptions/036-fizz_buzz.txt create mode 100644 Bench/text-descriptions/037-sort_even.txt create mode 100644 Bench/text-descriptions/038-encode_cyclic.txt create mode 100644 Bench/text-descriptions/040-triples-sum-to-zero.txt create mode 100644 Bench/text-descriptions/041-car_race_collision.txt create mode 100644 Bench/text-descriptions/042-incr-list.txt create mode 100644 Bench/text-descriptions/043-pairs-sum-to-zero.txt create mode 100644 Bench/text-descriptions/045-triangle_area.txt create mode 100644 Bench/text-descriptions/046-fib4.txt create mode 100644 Bench/text-descriptions/048-is-palindrome.txt create mode 100644 Bench/text-descriptions/048-is_palindrome.txt create mode 100644 Bench/text-descriptions/049-modp.txt create mode 100644 Bench/text-descriptions/050-encode_shift.txt create mode 100644 Bench/text-descriptions/051-remove-vowels.txt create mode 100644 Bench/text-descriptions/052-below-threshold.txt create mode 100644 Bench/text-descriptions/053-add.txt create mode 100644 Bench/text-descriptions/054-same-chars.txt create mode 100644 Bench/text-descriptions/055-fib.txt create mode 100644 Bench/text-descriptions/056-correct_bracketing.txt create mode 100644 Bench/text-descriptions/057-monotonic.txt create mode 100644 Bench/text-descriptions/058-common.txt create mode 100644 Bench/text-descriptions/059-largest-prime-factor.txt create mode 100644 Bench/text-descriptions/060-sum-to-n.txt create mode 100644 Bench/text-descriptions/062-derivative.txt create mode 100644 Bench/text-descriptions/063-fibfib.txt create mode 100644 Bench/text-descriptions/064-vowels-count.txt create mode 100644 Bench/text-descriptions/065-circular_shift.txt create mode 100644 Bench/text-descriptions/066-digitSum.txt create mode 100644 Bench/text-descriptions/068-pluck.txt create mode 100644 Bench/text-descriptions/069-search.txt create mode 100644 Bench/text-descriptions/070-strange_sort_list.txt create mode 100644 Bench/text-descriptions/072-will_it_fly.txt create mode 100644 Bench/text-descriptions/073-smallest_change.txt create mode 100644 Bench/text-descriptions/074-total_match.txt create mode 100644 Bench/text-descriptions/075-is_multiply_prime.txt create mode 100644 Bench/text-descriptions/076-is_simple_power.txt create mode 100644 Bench/text-descriptions/077-iscube.txt create mode 100644 Bench/text-descriptions/078-hex_key.txt create mode 100644 Bench/text-descriptions/079-decimal_to_binary.txt create mode 100644 Bench/text-descriptions/080-is_happy.txt create mode 100644 Bench/text-descriptions/081-numerical_letter_grade.txt create mode 100644 Bench/text-descriptions/082-prime-length.txt create mode 100644 Bench/text-descriptions/083-starts_one_ends.txt create mode 100644 Bench/text-descriptions/084-solve.txt create mode 100644 Bench/text-descriptions/085-add.txt create mode 100644 Bench/text-descriptions/087-get_row.txt create mode 100644 Bench/text-descriptions/088-sort_array.txt create mode 100644 Bench/text-descriptions/089-encrypt.txt create mode 100644 Bench/text-descriptions/090-next_smallest.txt create mode 100644 Bench/text-descriptions/092-any_int.txt create mode 100644 Bench/text-descriptions/093-encode.txt create mode 100644 Bench/text-descriptions/094-skjkasdkd.txt create mode 100644 Bench/text-descriptions/095-check_dict_case.txt create mode 100644 Bench/text-descriptions/096-count_up_to.txt create mode 100644 Bench/text-descriptions/097-multiply.txt create mode 100644 Bench/text-descriptions/098-count_upper.txt create mode 100644 Bench/text-descriptions/100-make_a_pile.txt create mode 100644 Bench/text-descriptions/102-choose_num.txt create mode 100644 Bench/text-descriptions/104-unique_digits.txt create mode 100644 Bench/text-descriptions/105-by_length.txt create mode 100644 Bench/text-descriptions/106-f.txt create mode 100644 Bench/text-descriptions/107-even_odd_palindrome.txt create mode 100644 Bench/text-descriptions/108-count_nums.txt create mode 100644 Bench/text-descriptions/109-move_one_ball.txt create mode 100644 Bench/text-descriptions/110-exchange.txt create mode 100644 Bench/text-descriptions/111-histogram.txt create mode 100644 Bench/text-descriptions/112-reverse_delete.txt create mode 100644 Bench/text-descriptions/114-minSubArraySum.txt create mode 100644 Bench/text-descriptions/115-max_fill.txt create mode 100644 Bench/text-descriptions/116-sort_array.txt create mode 100644 Bench/text-descriptions/118-get_closest_vowel.txt create mode 100644 Bench/text-descriptions/119-match_parens.txt create mode 100644 Bench/text-descriptions/120-maximum.txt create mode 100644 Bench/text-descriptions/121-solution.txt create mode 100644 Bench/text-descriptions/122-add_elements.txt create mode 100644 Bench/text-descriptions/123-get_odd_collatz.txt create mode 100644 Bench/text-descriptions/126-is_sorted.txt create mode 100644 Bench/text-descriptions/127-intersection.txt create mode 100644 Bench/text-descriptions/128-prod_signs.txt create mode 100644 Bench/text-descriptions/130-tri.txt create mode 100644 Bench/text-descriptions/132-is_nested.txt create mode 100644 Bench/text-descriptions/133-sum-squares.txt create mode 100644 Bench/text-descriptions/134-check_if_last_char_is_a_letter.txt create mode 100644 Bench/text-descriptions/135_can_arrange.txt create mode 100644 Bench/text-descriptions/136-largest_smallest_integers.txt create mode 100644 Bench/text-descriptions/138_is_equal_to_sum_even.txt create mode 100644 Bench/text-descriptions/139-special_factorial.txt create mode 100644 Bench/text-descriptions/142-sum_squares.txt create mode 100644 Bench/text-descriptions/145-order_by_points.txt create mode 100644 Bench/text-descriptions/146_specialFilter.txt create mode 100644 Bench/text-descriptions/148-bf.txt create mode 100644 Bench/text-descriptions/149-sorted_list_sum.txt create mode 100644 Bench/text-descriptions/150-x_or_y.txt create mode 100644 Bench/text-descriptions/151-double_the_difference.txt create mode 100644 Bench/text-descriptions/152-compare.txt create mode 100644 Bench/text-descriptions/153-Strongest_Extension.txt create mode 100644 Bench/text-descriptions/154-cycpattern_check.txt create mode 100644 Bench/text-descriptions/155_even_odd_count.txt create mode 100644 Bench/text-descriptions/157-right_angle_triangle.txt create mode 100644 Bench/text-descriptions/158-find_max.txt create mode 100644 Bench/text-descriptions/159-eat.txt create mode 100644 Bench/text-descriptions/161-solve.txt create mode 100644 Bench/text-descriptions/163-generate_integers.txt diff --git a/Bench/000-has-close-elements.py b/Bench/000-has-close-elements.py index c7e459b..47bee82 100644 --- a/Bench/000-has-close-elements.py +++ b/Bench/000-has-close-elements.py @@ -2,13 +2,11 @@ from nagini_contracts.contracts import * -@Pure def abs_value(val: int) -> int: # post-conditions-start Ensures(Implies(val < 0, Result() == -val)) Ensures(Implies(val >= 0, Result() == val)) # post-conditions-end - # impl-start if val < 0: return -val @@ -19,9 +17,9 @@ def abs_value(val: int) -> int: @Pure def abs1(x: int, threshold: int) -> bool: - # impl-start + # pure-start return x >= threshold or x <= -threshold - # impl-end + # pure-end @Pure def fn(x: int, numbers: List[int], threshold: int) -> bool: @@ -30,13 +28,13 @@ def fn(x: int, numbers: List[int], threshold: int) -> bool: Requires(Acc(list_pred(numbers))) Requires(x >= 0 and x < len(numbers)) # pre-conditions-end - - # impl-start + + # pure-start return Forall(range(len(numbers)), lambda y : x == y or abs1(numbers[x] - numbers[y], threshold) ) - # impl-end + # pure-end def has_close_elements(numbers: List[int], threshold: int) -> bool: @@ -85,4 +83,4 @@ def has_close_elements(numbers: List[int], threshold: int) -> bool: i += 1 return flag - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/001-separate-paren-groups.py b/Bench/001-separate-paren-groups.py index 5667139..33cc29b 100644 --- a/Bench/001-separate-paren-groups.py +++ b/Bench/001-separate-paren-groups.py @@ -8,7 +8,7 @@ def IsValidParentheses(s : List[int], i : int, depth : int) -> bool : Requires(i >= 0 and i <= len(s)) # pre-conditions-end - # impl-start + # pure-start if (i) == (len(s)): return (depth) >= (0) elif (depth) < (0): @@ -19,7 +19,7 @@ def IsValidParentheses(s : List[int], i : int, depth : int) -> bool : return ((depth) > (0)) and (IsValidParentheses(s, (i) + (1), (depth) - (1))) elif True: return IsValidParentheses(s, (i) + (1), depth) - # impl-end + # pure-end @Pure def IsValidParentheses2(s : List[int], i : int, depth : int) -> bool : @@ -28,7 +28,7 @@ def IsValidParentheses2(s : List[int], i : int, depth : int) -> bool : Requires(i >= 0 and i <= len(s)) # pre-conditions-end - # impl-start + # pure-start if (i) == (len(s)): return (depth) >= (0) elif (depth) < (0): @@ -39,7 +39,7 @@ def IsValidParentheses2(s : List[int], i : int, depth : int) -> bool : return ((depth) > (0)) and (IsValidParentheses(s, (i) + (1), (depth) - (1))) elif True: return IsValidParentheses(s, (i) + (1), depth) - # impl-end + # pure-end @Pure def IsValidParentheses1(s : List[int], i : int, depth : int) -> bool : @@ -48,7 +48,7 @@ def IsValidParentheses1(s : List[int], i : int, depth : int) -> bool : Requires(i >= 0 and i <= len(s)) # pre-conditions-end - # impl-start + # pure-start if (i) == (len(s)): return (depth) == (0) elif ((depth) <= (0)) and ((i) != (0)): @@ -59,7 +59,7 @@ def IsValidParentheses1(s : List[int], i : int, depth : int) -> bool : return ((depth) > (0)) and (IsValidParentheses1(s, (i) + (1), (depth) - (1))) elif True: return IsValidParentheses1(s, (i) + (1), depth) - # impl-end + # pure-end def separate__paren__groups(paren__string : List[int]) -> List[List[int]]: # pre-conditions-start diff --git a/Bench/003-below-zero.py b/Bench/003-below-zero.py index 14f432d..5843bbb 100644 --- a/Bench/003-below-zero.py +++ b/Bench/003-below-zero.py @@ -8,12 +8,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (s)[j - 1] + (psum(i, j - 1, s)) - # impl-end + # pure-end def below__zero(ops : List[int]) -> bool: # pre-conditions-start @@ -51,4 +51,4 @@ def below__zero(ops : List[int]) -> bool: d_4_i_ = (d_4_i_) + (1) return True - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/005-intersperse.py b/Bench/005-intersperse.py index df00967..0d2f0e5 100644 --- a/Bench/005-intersperse.py +++ b/Bench/005-intersperse.py @@ -35,4 +35,4 @@ def intersperse(numbers: List[int], delimiter: int) -> List[int]: res.append(numbers[i]) return res - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/006-parse_nested_parens.py b/Bench/006-parse_nested_parens.py index 5efe817..9d7271c 100644 --- a/Bench/006-parse_nested_parens.py +++ b/Bench/006-parse_nested_parens.py @@ -43,9 +43,9 @@ def get_len(s : List[int]) -> bool: Requires(Acc(list_pred(s), 1/2)) # pre-conditions-end - # impl-start + # pure-start return len(s) > 0 - # impl-end + # pure-end @Pure def contains12(s : List[int]) -> bool: @@ -53,10 +53,10 @@ def contains12(s : List[int]) -> bool: Requires(Acc(list_pred(s), 1/2)) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_0_i_: Implies(d_0_i_ >= 0 and d_0_i_ < len(s), s[d_0_i_] == 1 or s[d_0_i_] == 2)) - # impl-end + # pure-end def split(s : List[int]) -> List[List[int]]: # pre-conditions-start @@ -147,4 +147,4 @@ def parse__nested__parens(paren__string : List[int]) -> List[int]: res = (res) + [d_17_cur_] d_15_i_ = (d_15_i_) + (1) return res - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/007-filter_by_substring.py b/Bench/007-filter_by_substring.py index 6f1e11f..f13016a 100644 --- a/Bench/007-filter_by_substring.py +++ b/Bench/007-filter_by_substring.py @@ -51,9 +51,9 @@ def EqArrays(a : List[int], x : List[int]) -> bool : Requires(Acc(list_pred(x))) # pre-conditions-end - # impl-start + # pure-start return len(a) == len(x) and Forall(int, lambda d_0_i_: Implies(0 <= d_0_i_ and d_0_i_ < len(a), (a)[d_0_i_] == x[d_0_i_])) - # impl-end + # pure-end @Pure def InArray(a : List[List[int]], x : List[int]) -> bool : @@ -63,11 +63,11 @@ def InArray(a : List[List[int]], x : List[int]) -> bool : Requires(Forall(a, lambda d_0_s_: Acc(list_pred(d_0_s_)))) # pre-conditions-end - # impl-start + # pure-start return Exists(int, lambda d_0_s_: (Implies(((0) <= (d_0_s_)) and ((d_0_s_) < (len((a)))), EqArrays(a[d_0_s_], x)))) - # impl-end + # pure-end def filter__by__substring(strings : List[List[int]], substring : List[int]) -> List[List[int]]: diff --git a/Bench/008-sum-product.py b/Bench/008-sum-product.py index 5d92e1d..82ad4e6 100644 --- a/Bench/008-sum-product.py +++ b/Bench/008-sum-product.py @@ -8,12 +8,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (s)[j - 1] + (psum(i, j - 1, s)) - # impl-end + # pure-end @Pure def prod(i : int, j : int, s : List[int]) -> int : @@ -22,12 +22,12 @@ def prod(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 1 else: return (s)[j - 1] * (prod(i, j - 1, s)) - # impl-end + # pure-end def sum__product(numbers : List[int]) -> Tuple[int, int]: # pre-conditions-start @@ -63,4 +63,4 @@ def sum__product(numbers : List[int]) -> Tuple[int, int]: p = (p) * ((numbers)[d_2_i_]) d_2_i_ = (d_2_i_) + (1) return s, p - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/009-rolling-max.py b/Bench/009-rolling-max.py index 47f8a24..0f5abf2 100644 --- a/Bench/009-rolling-max.py +++ b/Bench/009-rolling-max.py @@ -6,9 +6,9 @@ def getVal(mx: Optional[int]) -> int: # pre-conditions-start Requires(mx is not None) # pre-conditions-end - # impl-start + # pure-start return mx - # impl-end + # pure-end def rolling_max(numbers: List[int]) -> List[int]: # pre-conditions-start @@ -48,4 +48,4 @@ def rolling_max(numbers: List[int]) -> List[int]: i += 1 return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/010-is_palindrome.py b/Bench/010-is_palindrome.py index 44768af..98e42db 100644 --- a/Bench/010-is_palindrome.py +++ b/Bench/010-is_palindrome.py @@ -44,10 +44,10 @@ def is__palindrome__fun(start : int, s : List[int]) -> bool : Requires(0 <= start and start < len(s)) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_4_k_: not (((start) <= (d_4_k_)) and ((d_4_k_) < (len(s)))) or (((s)[d_4_k_]) == ((s)[((len(s)) - (1)) - (d_4_k_ - start)]))) - # impl-end + # pure-end @Pure def starts__with(result : List[int], s : List[int]) -> bool : @@ -56,10 +56,10 @@ def starts__with(result : List[int], s : List[int]) -> bool : Requires(Acc(list_pred(result), 1/2)) # pre-conditions-end - # impl-start + # pure-start return ((len(result)) >= (len(s))) and (Forall(int, lambda d_5_k_: not (((0) <= (d_5_k_)) and ((d_5_k_) < (len(s)))) or (((result)[d_5_k_]) == ((s)[d_5_k_])))) - # impl-end + # pure-end def make__palindrome(s : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/011-string_xor.py b/Bench/011-string_xor.py index 8c6debc..526bcdc 100644 --- a/Bench/011-string_xor.py +++ b/Bench/011-string_xor.py @@ -7,14 +7,14 @@ def xor(a : int, b : int) -> int: Ensures((Result()) == ((0 if (a) == (b) else 1))) # pre-conditions-end - # impl-start + # pure-start result : int = int(0) if (a) == (b): result = 0 else: result = 1 return result - # impl-end + # pure-end def string__xor(a : List[int], b : List[int]) -> List[int]: # pre-conditions-start @@ -60,4 +60,4 @@ def string__xor(a : List[int], b : List[int]) -> List[int]: result = (result) + [d_6_bitResult_] d_4_i_ = (d_4_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/012-longest.py b/Bench/012-longest.py index ef85ba5..6627102 100644 --- a/Bench/012-longest.py +++ b/Bench/012-longest.py @@ -7,9 +7,9 @@ def getVal(mx: Optional[int]) -> int: Requires(mx is not None) # pre-conditions-end - # impl-start + # pure-start return mx - # impl-end + # pure-end def longest(strings : List[List[int]]) -> Optional[int]: # pre-conditions-start @@ -60,4 +60,4 @@ def longest(strings : List[List[int]]) -> Optional[int]: # assert-end d_5_i_ = (d_5_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/013-greatest-common-divisor.py b/Bench/013-greatest-common-divisor.py index 153a1e4..44a3df3 100644 --- a/Bench/013-greatest-common-divisor.py +++ b/Bench/013-greatest-common-divisor.py @@ -22,4 +22,4 @@ def greatest_common_divisor(a: int, b: int) -> int: x = temp return x - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/016-count_distinct_characters.py b/Bench/016-count_distinct_characters.py index 11a6f3f..3f71984 100644 --- a/Bench/016-count_distinct_characters.py +++ b/Bench/016-count_distinct_characters.py @@ -11,12 +11,12 @@ def contains_char(s : List[int], c : int, i : int, j : int) -> bool: Requires(((97) <= (c)) and ((c) <= (122))) # pre-conditions-end - # impl-start + # pure-start if i == j: return False else: return s[j - 1] == c or contains_char(s, c, i, j - 1) - # impl-end + # pure-end @Pure def count_chars_inter(s : List[int], c : int) -> int: @@ -27,12 +27,12 @@ def count_chars_inter(s : List[int], c : int) -> int: Requires(((97) <= (c)) and ((c) <= (123))) # pre-conditions-end - # impl-start + # pure-start if c == 97: return 0 else: return count_chars_inter(s, c - 1) + (1 if contains_char(s, c - 1, 0, len(s)) else 0) - # impl-end + # pure-end def count_distinct_characters(s : List[int]) -> int: # pre-conditions-start @@ -62,4 +62,4 @@ def count_distinct_characters(s : List[int]) -> int: c = c + 1 d_2_i_ = d_2_i_ + 1 return c - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/020-find-closest-elements.py b/Bench/020-find-closest-elements.py index ec74682..20a87d8 100644 --- a/Bench/020-find-closest-elements.py +++ b/Bench/020-find-closest-elements.py @@ -1,18 +1,19 @@ -from typing import cast, List, Dict, Set, Optional, Union, Tuple +from typing import List, Tuple from nagini_contracts.contracts import * +#use-as-unpure @Pure def dist(a : int, b : int) -> int : # pre-conditions-start Ensures(Result() >= 0) # pre-conditions-end - # impl-start + # pure-start if (a) < (b): return (b) - (a) else: return (a) - (b) - # impl-end + # pure-end def find__closest__elements(s : List[int]) -> Tuple[int, int]: # pre-conditions-start @@ -103,4 +104,3 @@ def find__closest__elements(s : List[int]) -> Tuple[int, int]: d_5_i_ = (d_5_i_) + (1) return (l, h) # impl-end - diff --git a/Bench/023-strlen.py b/Bench/023-strlen.py index e81ddec..c8d167a 100644 --- a/Bench/023-strlen.py +++ b/Bench/023-strlen.py @@ -7,4 +7,4 @@ def strlen(s : str) -> int: # impl-start return len(s) - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/024-largest-divisor.py b/Bench/024-largest-divisor.py index 8d3dd6b..f81d0a8 100644 --- a/Bench/024-largest-divisor.py +++ b/Bench/024-largest-divisor.py @@ -26,4 +26,4 @@ def largest__divisor(n : int) -> int: d = (d) - (1) d = 1 return d - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/026-remove_duplicates.py b/Bench/026-remove_duplicates.py index 6f8388d..cbc8690 100644 --- a/Bench/026-remove_duplicates.py +++ b/Bench/026-remove_duplicates.py @@ -53,10 +53,10 @@ def exists_check(a : List[int], x : int) -> bool: Requires(Acc(list_pred(a), 1/2)) # pre-conditions-end - # impl-start + # pure-start return Exists(int, lambda d_0_i_: ((((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))) and ((a)[d_0_i_]) == (x)))) - # impl-end + # pure-end @Pure def count_check(a : List[int], x : int) -> bool: @@ -64,9 +64,9 @@ def count_check(a : List[int], x : int) -> bool: Requires(Acc(list_pred(a), 1/2)) # pre-conditions-end - # impl-start + # pure-start return (count__rec(a, x, len(a))) == (1) - # impl-end + # pure-end @Pure def count__rec(a : List[int], x : int, i : int) -> int : @@ -75,9 +75,9 @@ def count__rec(a : List[int], x : int, i : int) -> int : Requires(((0) <= (i)) and ((i) <= (len(a)))) # pre-conditions-end - # impl-start + # pure-start if (i) == 0: return 0 else: return (((a)[i - 1]) == (x)) + (count__rec(a, x, (i) - (1))) - # impl-end + # pure-end diff --git a/Bench/027-flip_case.py b/Bench/027-flip_case.py index acf607b..2025b8d 100644 --- a/Bench/027-flip_case.py +++ b/Bench/027-flip_case.py @@ -3,37 +3,36 @@ @Pure def lower(c : int) -> bool : - # impl-start + # pure-start return ((0) <= (c)) and ((c) <= (25)) - # impl-end + # pure-end @Pure def upper(c : int) -> bool : - # impl-start + # pure-start return ((26) <= (c)) and ((c) <= (51)) - # impl-end + # pure-end @Pure def alpha(c : int) -> bool : - # impl-start + # pure-start return (lower(c)) or (upper(c)) - # impl-end + # pure-end -@Pure def flip__char(c : int) -> int : # pre-conditions-start Ensures(lower(c) == upper(Result())) Ensures(upper(c) == lower(Result())) # pre-conditions-end - # impl-start + # pure-start if lower(c): return ((c) - (0)) + (26) elif upper(c): return ((c) + (0)) - (26) elif True: return c - # impl-end + # pure-end def flip__case(s : List[int]) -> List[int] : # pre-conditions-start diff --git a/Bench/029-filter_by_prefix.py b/Bench/029-filter_by_prefix.py index 37eae55..e59a0d8 100644 --- a/Bench/029-filter_by_prefix.py +++ b/Bench/029-filter_by_prefix.py @@ -14,9 +14,9 @@ def starts__with(s : List[int], p : List[int], i : int) -> bool : Ensures(Implies(len(s) < len(p), not Result())) # post-conditions-end - # impl-start + # pure-start return len(s) >= len(p) and Forall(int, lambda x: Implies(x >= i and x < len(p), s[x] == p[x])) - # impl-end + # pure-end @Pure def starts__with__fun(s : List[int], p : List[int], i : int) -> bool : @@ -29,13 +29,13 @@ def starts__with__fun(s : List[int], p : List[int], i : int) -> bool : Ensures(Result() == starts__with(s, p, i)) # post-conditions-end - # impl-start + # pure-start if (len(p) == i): return True if (len(s) > i and len(s) >= len(p) and s[i] == p[i]): return starts__with(s, p, i + 1) return False - # impl-end + # pure-end def filter__by__prefix(xs : List[List[int]], p : List[int]) -> List[int]: # pre-conditions-start @@ -73,4 +73,4 @@ def filter__by__prefix(xs : List[List[int]], p : List[int]) -> List[int]: filtered = (filtered) + [d_1_i_] d_1_i_ = (d_1_i_) + (1) return filtered - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/030-get-positive.py b/Bench/030-get-positive.py index 5cccd48..fd36eee 100644 --- a/Bench/030-get-positive.py +++ b/Bench/030-get-positive.py @@ -58,4 +58,4 @@ def get__positive(l : List[int]) -> List[int]: # assert-end d_5_i_ = (d_5_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/031-is-prime.py b/Bench/031-is-prime.py index 17292e6..2e1b0c6 100644 --- a/Bench/031-is-prime.py +++ b/Bench/031-is-prime.py @@ -27,4 +27,4 @@ def is__prime(k : int) -> bool: result = False d_2_i_ = (d_2_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/033-sort_third.py b/Bench/033-sort_third.py index b45b8c5..532b787 100644 --- a/Bench/033-sort_third.py +++ b/Bench/033-sort_third.py @@ -120,4 +120,4 @@ def SortSeqPred(s : List[int], p : List[bool]) -> List[int]: (sorted)[d_15_minIndex_] = rhs0_ d_9_i_ = (d_9_i_) + (1) return sorted - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/034-unique.py b/Bench/034-unique.py index a309386..1dd8ff6 100644 --- a/Bench/034-unique.py +++ b/Bench/034-unique.py @@ -7,10 +7,10 @@ def InArray(a : List[int], x : int) -> bool: Requires(Acc(list_pred(a), 1/2)) # pre-conditions-end - # impl-start + # pure-start return Exists(int, lambda d_0_i_: ((((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))) and ((a)[d_0_i_]) == (x)))) - # impl-end + # pure-end diff --git a/Bench/036-fizz_buzz.py b/Bench/036-fizz_buzz.py index dadfa37..e6a6b96 100644 --- a/Bench/036-fizz_buzz.py +++ b/Bench/036-fizz_buzz.py @@ -36,12 +36,12 @@ def fizz_buzz_fun(n : int) -> int: Ensures(Result() >= 0) # post-conditions-end - # impl-start + # pure-start if n == 0: return 0 else: return (count7__r(n - 1) if ((n - 1) % 11 == 0 or (n - 1) % 13 == 0) else 0) + fizz_buzz_fun(n - 1) - # impl-end + # pure-end def count7(x : int) -> int: @@ -76,9 +76,9 @@ def count7__r(x : int) -> int : Ensures(Result() >= 0) # post-conditions-end - # impl-start + # pure-start if x == 0: return 0 else: return (x % 10 == 7) + count7__r(x // 10) - # impl-end + # pure-end diff --git a/Bench/037-sort_even.py b/Bench/037-sort_even.py index af2c38a..a4970aa 100644 --- a/Bench/037-sort_even.py +++ b/Bench/037-sort_even.py @@ -120,4 +120,4 @@ def SortSeqPred(s : List[int], p : List[bool]) -> List[int]: (sorted)[d_15_minIndex_] = rhs0_ d_9_i_ = (d_9_i_) + (1) return sorted - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/038-encode_cyclic.py b/Bench/038-encode_cyclic.py index 6a20b96..f8c05f4 100644 --- a/Bench/038-encode_cyclic.py +++ b/Bench/038-encode_cyclic.py @@ -65,4 +65,4 @@ def decode_cyclic(s: List[int]) -> List[int]: # impl-start return encode_cyclic(encode_cyclic(s)) - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/040-triples-sum-to-zero.py b/Bench/040-triples-sum-to-zero.py index d04b475..6121d99 100644 --- a/Bench/040-triples-sum-to-zero.py +++ b/Bench/040-triples-sum-to-zero.py @@ -62,4 +62,4 @@ def triples__sum__to__zero(l : List[int]) -> bool: d_13_j_ = (d_13_j_) + (1) d_6_i_ = (d_6_i_) + (1) return False - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/043-pairs-sum-to-zero.py b/Bench/043-pairs-sum-to-zero.py index 913e0a3..90bf5d0 100644 --- a/Bench/043-pairs-sum-to-zero.py +++ b/Bench/043-pairs-sum-to-zero.py @@ -49,4 +49,4 @@ def pairs__sum__to__zero(l : List[int]) -> bool: d_9_j_ = (d_9_j_) + (1) d_4_i_ = (d_4_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/046-fib4.py b/Bench/046-fib4.py index 0512772..2b801a9 100644 --- a/Bench/046-fib4.py +++ b/Bench/046-fib4.py @@ -7,14 +7,14 @@ def fib4__rec(n : int) -> int : Requires(n >= 0) # pre-conditions-end - # impl-start + # pure-start if (((n) == (0)) or ((n) == (1))) or ((n) == (2)): return 0 elif (n) == (3): return 1 elif True: return (((fib4__rec((n) - (1))) + (fib4__rec((n) - (2)))) + (fib4__rec((n) - (3)))) + (fib4__rec((n) - (4))) - # impl-end + # pure-end def fib4(n : int) -> int: # pre-conditions-start diff --git a/Bench/049-modp.py b/Bench/049-modp.py index e588828..063a278 100644 --- a/Bench/049-modp.py +++ b/Bench/049-modp.py @@ -8,12 +8,12 @@ def modp__rec(n : int, p : int) -> int : Requires((n) >= (0)) # pre-conditions-end - # impl-start + # pure-start if (n) == (0): return (1 % p) elif True: return ((modp__rec((n) - (1), p)) * (2)) % p - # impl-end + # pure-end def modp(n : int, p : int) -> int: # pre-conditions-start diff --git a/Bench/050-encode_shift.py b/Bench/050-encode_shift.py index 8689c94..02c71b6 100644 --- a/Bench/050-encode_shift.py +++ b/Bench/050-encode_shift.py @@ -1,17 +1,19 @@ from typing import cast, List, Dict, Set, Optional, Union, Tuple from nagini_contracts.contracts import * +#use-as-unpure @Pure def encode__char(c : int) -> int : - # impl-start + # pure-start return (c - 97 + 5) % 26 + 97 - # impl-end + # pure-end +#use-as-unpure @Pure def decode__char(c : int) -> int : - # impl-start + # pure-start return ((c) - (97) - (5)) % 26 + 97 - # impl-end + # pure-end def encode__shift(s : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/053-add.py b/Bench/053-add.py index cdb362b..d3b90eb 100644 --- a/Bench/053-add.py +++ b/Bench/053-add.py @@ -8,4 +8,4 @@ def add(x : int, y : int) -> int: # impl-start z : int = (x) + (y) return z - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/054-same-chars.py b/Bench/054-same-chars.py index 848190a..9ec395f 100644 --- a/Bench/054-same-chars.py +++ b/Bench/054-same-chars.py @@ -16,4 +16,4 @@ def same_chars(s0: List[int], s1: List[int]) -> bool: # impl-start return (Forall(int, lambda d_0_i_ : Implies(((0 <= d_0_i_) and (d_0_i_ < len(s0))), s0[d_0_i_] in s1)) and Forall(int, lambda d_1_i_ : Implies(((0 <= d_1_i_) and (d_1_i_ < len(s1))), s1[d_1_i_] in s0))) - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/055-fib.py b/Bench/055-fib.py index c2f1d6c..6237d44 100644 --- a/Bench/055-fib.py +++ b/Bench/055-fib.py @@ -10,14 +10,14 @@ def fib(n : int) -> int : Ensures(Result() >= 0) # post-conditions-end - # impl-start + # pure-start if (n) == (0): return 0 elif (n) == (1): return 1 elif True: return (fib((n) - (1))) + (fib((n) - (2))) - # impl-end + # pure-end def ComputeFib(n : int) -> int: # pre-conditions-start @@ -51,4 +51,4 @@ def ComputeFib(n : int) -> int: d_2_i_ = (d_2_i_) + (1) result = d_1_b_ return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/056-correct_bracketing.py b/Bench/056-correct_bracketing.py index d2d0018..6e9c582 100644 --- a/Bench/056-correct_bracketing.py +++ b/Bench/056-correct_bracketing.py @@ -8,12 +8,12 @@ def CalBal(s : List[int], i : int, j : int) -> int: Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (1 if s[j - 1] == 0 else -1) + CalBal(s, i, j - 1) - # impl-end + # pure-end def correct_bracketing(s : List[int]) -> bool: # pre-conditions-start @@ -56,4 +56,4 @@ def correct_bracketing(s : List[int]) -> bool: return False i = i + 1 return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/057-monotonic.py b/Bench/057-monotonic.py index aa8fd4c..2366113 100644 --- a/Bench/057-monotonic.py +++ b/Bench/057-monotonic.py @@ -39,4 +39,4 @@ def monotonic(xs : List[int]) -> bool: d_6_i_ = (d_6_i_) + (1) result : bool = (d_4_increasing_) or (d_5_decreasing_) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/058-common.py b/Bench/058-common.py index 7f05122..084068a 100644 --- a/Bench/058-common.py +++ b/Bench/058-common.py @@ -7,10 +7,10 @@ def NotInArray(a : List[int], x : int) -> bool : Requires(Acc(list_pred(a))) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_0_i_: (Implies(((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))), ((a)[d_0_i_]) != (x)), [[(a)[d_0_i_]]])) - # impl-end + # pure-end @Pure def ExistsBoth(a : List[int], b : List[int], x : int) -> bool: @@ -19,11 +19,11 @@ def ExistsBoth(a : List[int], b : List[int], x : int) -> bool: Requires(Acc(list_pred(b), 1/2)) # pre-conditions-end - # impl-start + # pure-start return Exists(int, lambda d_0_i_: (Implies(((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))), ((a)[d_0_i_]) == (x)))) and Exists(int, lambda d_0_i_: (Implies(((0) <= (d_0_i_)) and ((d_0_i_) < (len((b)))), ((b)[d_0_i_]) == (x)))) - # impl-end + # pure-end def common(l1 : List[int], l2 : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/059-largest-prime-factor.py b/Bench/059-largest-prime-factor.py index 8b8f46c..f13878a 100644 --- a/Bench/059-largest-prime-factor.py +++ b/Bench/059-largest-prime-factor.py @@ -26,9 +26,9 @@ def is_prime(k : int) -> bool: @Pure def is_prime_pred(k : int) -> bool: - # impl-start + # pure-start return Forall(int, lambda i : Implies((i >= 2) and (i < k), (k % i != 0))) - # impl-end + # pure-end def largest_prime_factor(n: int) -> int: # pre-conditions-start @@ -51,4 +51,4 @@ def largest_prime_factor(n: int) -> int: largest = max(largest, j) j = j + 1 return largest - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/060-sum-to-n.py b/Bench/060-sum-to-n.py index 0978827..ecb502c 100644 --- a/Bench/060-sum-to-n.py +++ b/Bench/060-sum-to-n.py @@ -7,12 +7,12 @@ def psum(i : int, j : int) -> int : Requires(0 <= i and i <= j + 1) # pre-conditions-end - # impl-start + # pure-start if i > j: return 0 else: return j + 1 + (psum(i, j - 1)) - # impl-end + # pure-end def sum__squares(n : int) -> int: # pre-conditions-start @@ -33,4 +33,4 @@ def sum__squares(n : int) -> int: r = (r) + ((d_2_k_) + (1)) d_2_k_ = (d_2_k_) + (1) return r - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/063-fibfib.py b/Bench/063-fibfib.py index 16577c6..25a6134 100644 --- a/Bench/063-fibfib.py +++ b/Bench/063-fibfib.py @@ -10,14 +10,14 @@ def fibfib(n : int) -> int : Ensures((Result()) >= (0)) # post-conditions-end - # impl-start + # pure-start if ((n) == (0)) or ((n) == (1)): return 0 elif (n) == (2): return 1 elif True: return ((fibfib((n) - (1))) + (fibfib((n) - (2)))) + (fibfib((n) - (3))) - # impl-end + # pure-end def ComputeFibFib(n : int) -> int: # pre-conditions-start diff --git a/Bench/064-vowel_count.py b/Bench/064-vowel_count.py index e7a1d5d..4ad923c 100644 --- a/Bench/064-vowel_count.py +++ b/Bench/064-vowel_count.py @@ -43,7 +43,7 @@ def count_fun(i : int, j : int, s : List[int]) -> int: Ensures((Result()) >= (0)) # post-conditions-end - # impl-start + # pure-start if i == j: return 0 else: @@ -51,10 +51,10 @@ def count_fun(i : int, j : int, s : List[int]) -> int: return (1) + (count_fun(i, j - 1, s)) else: return count_fun(i, j - 1, s) - # impl-end + # pure-end @Pure def is__vowel(c : int) -> bool : - # impl-start + # pure-start return ((((((((((c) == (97)) or ((c) == (101))) or ((c) == (105))) or ((c) == (111))) or ((c) == (117))) or ((c) == (65))) or ((c) == (69))) or ((c) == (73))) or ((c) == (79))) or ((c) == (85)) - # impl-end \ No newline at end of file + # pure-end diff --git a/Bench/066-digitSum.py b/Bench/066-digitSum.py index bbd3e38..cc3479f 100644 --- a/Bench/066-digitSum.py +++ b/Bench/066-digitSum.py @@ -8,12 +8,12 @@ def upper__sum__rec(i : int, j : int, s : List[int]) -> int : Requires(((0) <= (i)) and ((i) <= (j)) and ((j) <= (len(s)))) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return s[j - 1] + upper__sum__rec(i, j - 1, s) - # impl-end + # pure-end def upper__sum(s : List[int]) -> int: # pre-conditions-start diff --git a/Bench/069-search.py b/Bench/069-search.py index 43af781..1cb7c3f 100644 --- a/Bench/069-search.py +++ b/Bench/069-search.py @@ -8,12 +8,12 @@ def freq_req(i : int, j : int, s : List[int], x : int) -> int: Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return ((s)[j - 1] == x) + (freq_req(i, j - 1, s, x)) - # impl-end + # pure-end def freq(s : List[int], x : int) -> int: # pre-conditions-start @@ -42,3 +42,4 @@ def freq(s : List[int], x : int) -> int: d_1_i_ = (d_1_i_) + (1) return count # impl-end + diff --git a/Bench/072-will_it_fly.py b/Bench/072-will_it_fly.py index 63854c9..e923bcc 100644 --- a/Bench/072-will_it_fly.py +++ b/Bench/072-will_it_fly.py @@ -55,10 +55,10 @@ def is__palindrome__pred(s : List[int]) -> bool : Requires(Acc(list_pred(s))) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_4_k_: not (((0) <= (d_4_k_)) and ((d_4_k_) < (len(s)))) or (((s)[d_4_k_]) == ((s)[((len(s)) - (1)) - (d_4_k_)]))) - # impl-end + # pure-end @Pure def psum(i : int, j : int, s : List[int]) -> int : @@ -67,9 +67,9 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (s)[j - 1] + (psum(i, j - 1, s)) - # impl-end + # pure-end diff --git a/Bench/073-smallest_change.py b/Bench/073-smallest_change.py index 56041ef..dd36724 100644 --- a/Bench/073-smallest_change.py +++ b/Bench/073-smallest_change.py @@ -11,7 +11,7 @@ def smallest__change__fun(s : List[int], i : int, j : int) -> int: Ensures((Result()) >= (0)) # post-conditions-end - # impl-start + # pure-start if i == j: return 0 else: @@ -19,7 +19,7 @@ def smallest__change__fun(s : List[int], i : int, j : int) -> int: return 1 + (smallest__change__fun(s, i, j - 1)) else: return smallest__change__fun(s, i, j - 1) - # impl-end + # pure-end def smallest__change(s : List[int]) -> int: # pre-conditions-start @@ -48,4 +48,4 @@ def smallest__change(s : List[int]) -> int: c = (c) + (1) d_1_i_ = (d_1_i_) + (1) return c - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/075-is_multiply_prime.py b/Bench/075-is_multiply_prime.py index d0b5afb..b82b228 100644 --- a/Bench/075-is_multiply_prime.py +++ b/Bench/075-is_multiply_prime.py @@ -3,10 +3,10 @@ @Pure def Prime(p : int) -> bool : - # impl-start + # pure-start return ((p) > (1)) and (Forall(int, lambda d_0_k_: not (((1) < (d_0_k_)) and ((d_0_k_) < (p))) or (((p % d_0_k_)) != (0)))) - # impl-end + # pure-end def is__prime(k : int) -> bool: # pre-conditions-start diff --git a/Bench/078-hex_key.py b/Bench/078-hex_key.py index 31fc617..18f4e6b 100644 --- a/Bench/078-hex_key.py +++ b/Bench/078-hex_key.py @@ -1,11 +1,12 @@ from typing import cast, List, Dict, Set, Optional, Union, Tuple from nagini_contracts.contracts import * +#use-as-unpure @Pure def IsPrimeHexDigit(c : int) -> bool : - # impl-start + # pure-start return ((((((c) == (2)) or ((c) == (3))) or ((c) == (5))) or ((c) == (7))) or ((c) == (11))) or ((c) == (13)) - # impl-end + # pure-end @Pure def count__prime__hex__digits__rec(i : int, j : int, num : List[int]) -> int : @@ -14,12 +15,12 @@ def count__prime__hex__digits__rec(i : int, j : int, num : List[int]) -> int : Requires(((0) <= (i)) and ((i) <= (j)) and ((j) <= (len(num)))) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (1 if IsPrimeHexDigit(num[j - 1]) else 0) + count__prime__hex__digits__rec(i, j - 1, num) - # impl-end + # pure-end def count__prime__hex__digits(s : List[int]) -> int: diff --git a/Bench/080-is_happy.py b/Bench/080-is_happy.py index 8228b58..d255e40 100644 --- a/Bench/080-is_happy.py +++ b/Bench/080-is_happy.py @@ -8,9 +8,9 @@ def ThreeDistinct(s : List[int], i : int) -> bool : Requires(((0) < (i)) and ((i) < ((len(s)) - (1)))) # pre-conditions-end - # impl-start + # pure-start return ((((s)[(i) - (1)]) != ((s)[i])) and (((s)[i]) != ((s)[(i) + (1)]))) and (((s)[(i) - (1)]) != ((s)[(i) + (1)])) - # impl-end + # pure-end @Pure def Happy(s : List[int]) -> bool : @@ -18,10 +18,10 @@ def Happy(s : List[int]) -> bool : Requires(Acc(list_pred(s))) # pre-conditions-end - # impl-start + # pure-start return ((len(s)) >= (3)) and (Forall(int, lambda d_0_i_: Implies(((0) < (d_0_i_)) and ((d_0_i_) < ((len(s)) - (1))), ThreeDistinct(s, d_0_i_)))) - # impl-end + # pure-end def IsHappy(s : List[int]) -> bool: # pre-conditions-start diff --git a/Bench/082-prime-length.py b/Bench/082-prime-length.py index 159c422..61f8d18 100644 --- a/Bench/082-prime-length.py +++ b/Bench/082-prime-length.py @@ -27,4 +27,4 @@ def is__prime(s : str) -> bool: result = False d_2_i_ = (d_2_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/083-starts_one_ends.py b/Bench/083-starts_one_ends.py index c9527ce..5c24707 100644 --- a/Bench/083-starts_one_ends.py +++ b/Bench/083-starts_one_ends.py @@ -25,9 +25,9 @@ def Pow(base : int, exponent : int) -> int : Requires((exponent) >= (0)) # pre-conditions-end - # impl-start + # pure-start if (exponent) == (0): return 1 else: return (base) * (Pow(base, (exponent) - (1))) - # impl-end \ No newline at end of file + # pure-end diff --git a/Bench/084-solve.py b/Bench/084-solve.py index 7ce3d68..8352cae 100644 --- a/Bench/084-solve.py +++ b/Bench/084-solve.py @@ -30,10 +30,10 @@ def popcount(n : int) -> int : Requires(n >= 0) # pre-conditions-end - # impl-start + # pure-start if n == 0: return 0 else: return (n % 2) + popcount(n // 2) - # impl-end + # pure-end diff --git a/Bench/085-add.py b/Bench/085-add.py index 5b28e6b..11dcb05 100644 --- a/Bench/085-add.py +++ b/Bench/085-add.py @@ -8,12 +8,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j + 1 and j < len(s)) # pre-conditions-end - # impl-start + # pure-start if i > j: return 0 else: return ((s)[j] if ((((j) % 2) == 1) and ((s)[j] % 2 == 0)) else 0) + (psum(i, j - 1, s)) - # impl-end + # pure-end def add(v : List[int]) -> int: # pre-conditions-start diff --git a/Bench/089-encrypt.py b/Bench/089-encrypt.py index 39e2486..d7514c9 100644 --- a/Bench/089-encrypt.py +++ b/Bench/089-encrypt.py @@ -1,6 +1,7 @@ from typing import cast, List, Dict, Set, Optional, Union, Tuple from nagini_contracts.contracts import * +#use-as-unpure @Pure def rot__sym(c : int) -> int : # pre-conditions-start @@ -10,10 +11,10 @@ def rot__sym(c : int) -> int : Ensures(Result() >= 0 and Result() <= 25) # post-conditions-end - # impl-start + # pure-start d_0_alph_ : int = c - 0 return ((d_0_alph_) + ((2) * (2))) % 26 - # impl-end + # pure-end def encrypt(s : List[int]) -> List[int]: # pre-conditions-start @@ -47,7 +48,7 @@ def encrypt(s : List[int]) -> List[int]: Invariant(Forall(int, lambda d_1_i_: not (((0) <= (d_1_i_)) and ((d_1_i_) < (len(r)))) or (((0) <= ((r)[d_1_i_])) and (((r)[d_1_i_]) <= (25))))) Invariant(Forall(int, lambda d_4_j_: - not (((0) <= (d_4_j_)) and ((d_4_j_) < (d_3_i_))) or (((r)[d_4_j_]) == (rot__sym((s)[d_4_j_]))))) + (not (((0) <= (d_4_j_)) and ((d_4_j_) < (d_3_i_))) or (((r)[d_4_j_]) == (rot__sym((s)[d_4_j_]))), [[rot__sym((s)[d_4_j_])]]))) # invariants-end r = (r) + [rot__sym((s)[d_3_i_])] d_3_i_ = (d_3_i_) + (1) diff --git a/Bench/092-any_int.py b/Bench/092-any_int.py index eeb2016..63cda66 100644 --- a/Bench/092-any_int.py +++ b/Bench/092-any_int.py @@ -7,4 +7,4 @@ def any__int(a : int, b : int, c : int) -> bool: # impl-start return (((a) == ((b) + (c))) or ((b) == ((a) + (c)))) or ((c) == ((a) + (b))) - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/093-encode.py b/Bench/093-encode.py index 16a566c..4c70841 100644 --- a/Bench/093-encode.py +++ b/Bench/093-encode.py @@ -41,21 +41,21 @@ def encode(s : List[int]) -> List[int]: @Pure def swap__case(c : int) -> int : - # impl-start + # pure-start if ((97) <= (c)) and ((c) <= (122)): return (65) + ((c) - (97)) elif True: return (97) + ((c) - (65)) - # impl-end + # pure-end @Pure def rot2(c : int) -> int : - # impl-start + # pure-start return (c + 2) - # impl-end + # pure-end @Pure def is__vowel(c : int) -> bool : - # impl-start + # pure-start return ((((((c) == (97)) or ((c) == (101))) or ((c) == (105))) or ((c) == (111))) or ((c) == (117))) or ((((((c) == (65)) or ((c) == (69))) or ((c) == (73))) or ((c) == (79))) or ((c) == (85))) - # impl-end + # pure-end diff --git a/Bench/096-count_up_to.py b/Bench/096-count_up_to.py index fe70798..687427a 100644 --- a/Bench/096-count_up_to.py +++ b/Bench/096-count_up_to.py @@ -3,10 +3,10 @@ @Pure def IsPrime(n : int) -> bool : - # impl-start + # pure-start return ((n) > (1)) and (Forall(int, lambda d_0_k_: Implies(((2) <= (d_0_k_)) and ((d_0_k_) < (n)), ((n % d_0_k_)) != (0)))) - # impl-end + # pure-end def CountUpTo(n : int) -> List[int]: # pre-conditions-start diff --git a/Bench/097-multiply.py b/Bench/097-multiply.py index 0c71621..84d5350 100644 --- a/Bench/097-multiply.py +++ b/Bench/097-multiply.py @@ -1,13 +1,14 @@ from nagini_contracts.contracts import * +#use-as-unpure @Pure def last__digit(n : int) -> int : - # impl-start + # pure-start if (n) < (0): return (((0) - (n)) % 10) elif True: return (n % 10) - # impl-end + # pure-end def multiply(a : int, b : int) -> int: # pre-conditions-start diff --git a/Bench/098-count_upper.py b/Bench/098-count_upper.py index 722d7fe..5e8c522 100644 --- a/Bench/098-count_upper.py +++ b/Bench/098-count_upper.py @@ -11,7 +11,7 @@ def count__upper__fun(s : List[int], i : int, j : int) -> int: Ensures((Result()) >= (0)) # post-conditions-end - # impl-start + # pure-start if i == j: return 0 else: @@ -19,7 +19,7 @@ def count__upper__fun(s : List[int], i : int, j : int) -> int: return (1) + (count__upper__fun(s, i, j - 1)) else: return count__upper__fun(s, i, j - 1) - # impl-end + # pure-end def count__upper(s : List[int]) -> int: @@ -57,6 +57,6 @@ def count__upper(s : List[int]) -> int: @Pure def is__upper__vowel(c : int) -> bool : - # impl-start + # pure-start return (((((c) == (0)) or ((c) == (1))) or ((c) == (2))) or ((c) == (3))) or ((c) == (4)) - # impl-end + # pure-end diff --git a/Bench/104-unique_digits.py b/Bench/104-unique_digits.py index 909dfb0..7f66eff 100644 --- a/Bench/104-unique_digits.py +++ b/Bench/104-unique_digits.py @@ -8,10 +8,10 @@ def InArray(a : List[int], x : int) -> bool: Requires(Acc(list_pred(a), 1/2)) # pre-conditions-end - # impl-start + # pure-start return Exists(int, lambda d_0_i_: ((((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))) and ((a)[d_0_i_]) == (x)))) - # impl-end + # pure-end @Pure def HasNoEvenDigit(n : int) -> bool : @@ -19,9 +19,9 @@ def HasNoEvenDigit(n : int) -> bool : Requires(((0) <= (n))) # pre-conditions-end - # impl-start + # pure-start return (n == 0 or (((((n % 10) % 2)) != (0)) and (HasNoEvenDigit((n // 10))))) - # impl-end + # pure-end def UniqueDigits(x : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/105-by_length.py b/Bench/105-by_length.py index 182515c..dc89834 100644 --- a/Bench/105-by_length.py +++ b/Bench/105-by_length.py @@ -3,15 +3,15 @@ @Pure def WithinRange(n : int) -> bool: - # impl-start + # pure-start return ((n) >= (1)) and ((n) <= (9)) - # impl-end + # pure-end @Pure def WithinRangeString(s : str) -> bool: - # impl-start + # pure-start return (s == "One" or s == "Two" or s == "Three" or s == "Four" or s == "Five" or s == "Six" or s == "Seven" or s == "Eight" or s == "Nine") - # impl-end + # pure-end def SortReverseAndName(arr : List[int]) -> List[str]: # pre-conditions-start @@ -231,4 +231,4 @@ def NumberToName(n : int) -> str : if (n) == (9): return "Nine" - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/106-f.py b/Bench/106-f.py index 24fd9a4..e796398 100644 --- a/Bench/106-f.py +++ b/Bench/106-f.py @@ -10,12 +10,12 @@ def factorial__spec(n : int) -> int : Ensures(Result() >= 0) # post-conditions-end - # impl-start + # pure-start if n == -1: return 1 else: return (n + 1) * factorial__spec(n - 1) - # impl-end + # pure-end @Pure def sum__spec(n : int) -> int : @@ -26,12 +26,12 @@ def sum__spec(n : int) -> int : Ensures(Result() >= 0) # post-conditions-end - # impl-start + # pure-start if 0 > n: return 0 else: return n + 1 + sum__spec(n - 1) - # impl-end + # pure-end def f(n : int) -> List[int]: # pre-conditions-start @@ -97,4 +97,4 @@ def f(n : int) -> List[int]: result = (result) + [d_9_x_] d_4_i_ = (d_4_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/108-count_nums.py b/Bench/108-count_nums.py index f4717ad..4bfb513 100644 --- a/Bench/108-count_nums.py +++ b/Bench/108-count_nums.py @@ -38,21 +38,21 @@ def get_positive(i : int, j : int, s : List[int]) -> int: Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (digits__sum(s[j - 1]) > 0) + get_positive(i, j - 1, s) - # impl-end + # pure-end @Pure def digits__sum(x : int) -> int : - # impl-start + # pure-start if abs(x) < 10: return x % 10 else: return (10 - x % 10) + digits__sum(x // 10) - # impl-end + # pure-end @Pure def abs(x : int) -> int : @@ -61,9 +61,9 @@ def abs(x : int) -> int : Ensures((Result()) == (x) or (Result()) == (0) - (x)) # pre-conditions-end - # impl-start + # pure-start if (x) >= (0): return x elif True: return (0) - (x) - # impl-end \ No newline at end of file + # pure-end diff --git a/Bench/109-move_one_ball.py b/Bench/109-move_one_ball.py index c72b06b..7d51aa0 100644 --- a/Bench/109-move_one_ball.py +++ b/Bench/109-move_one_ball.py @@ -1,6 +1,7 @@ from typing import cast, List, Dict, Set, Optional, Union from nagini_contracts.contracts import * +#use-as-unpure @Pure def is__sorted(a : List[int], l : int, r : int) -> bool : # pre-conditions-start @@ -8,11 +9,11 @@ def is__sorted(a : List[int], l : int, r : int) -> bool : Requires(((0) <= (l)) and ((l) <= (r)) and ((r) <= (len(a)))) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_0_i_: Forall(int, lambda d_1_j_: not ((((l) <= (d_0_i_)) and ((d_0_i_) < (d_1_j_))) and ((d_1_j_) < (r))) or (((a)[d_0_i_]) <= ((a)[d_1_j_])))) - # impl-end + # pure-end def move__one__ball(a : List[int]) -> bool: # pre-conditions-start diff --git a/Bench/110-exchange.py b/Bench/110-exchange.py index 8a22b62..6dccd71 100644 --- a/Bench/110-exchange.py +++ b/Bench/110-exchange.py @@ -7,10 +7,11 @@ def IsEven(n : int) -> bool: Ensures(((Result()) == (True)) or ((Result()) == (False))) # pre-conditions-end - # impl-start + # pure-start return (n % 2) == 0 - # impl-end + # pure-end +#use-as-unpure @Pure def CountEvens(i : int, lst : List[int]) -> int: # pre-conditions-start @@ -22,11 +23,11 @@ def CountEvens(i : int, lst : List[int]) -> int: Ensures((Result()) <= (len(lst) - i)) # post-conditions-end - # impl-start + # pure-start if len(lst) == i: return 0 return CountEvens(i + 1, lst) + IsEven(lst[i]) - # impl-end + # pure-end def Exchange(lst1 : List[int], lst2 : List[int]) -> str: # pre-conditions-start diff --git a/Bench/112-reverse_delete.py b/Bench/112-reverse_delete.py index 105a9ae..78263d6 100644 --- a/Bench/112-reverse_delete.py +++ b/Bench/112-reverse_delete.py @@ -7,10 +7,10 @@ def InArray(a : List[int], x : int) -> bool : Requires(Acc(list_pred(a))) # pre-conditions-end - # impl-start + # pure-start return Exists(int, lambda d_0_i_: ((((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))) and ((a)[d_0_i_]) == (x)))) - # impl-end + # pure-end @Pure def NotInArray(a : List[int], x : int) -> bool : @@ -18,10 +18,10 @@ def NotInArray(a : List[int], x : int) -> bool : Requires(Acc(list_pred(a))) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_0_i_: (Implies(((0) <= (d_0_i_)) and ((d_0_i_) < (len((a)))), ((a)[d_0_i_]) != (x)))) - # impl-end + # pure-end @Pure def implArrays(chars : List[int], res : List[int], x : int) -> bool: @@ -30,9 +30,9 @@ def implArrays(chars : List[int], res : List[int], x : int) -> bool: Requires(Acc(list_pred(res))) # pre-conditions-end - # impl-start + # pure-start return Implies(NotInArray(chars, x), InArray(res, x)) - # impl-end + # pure-end def reverse__delete(s : List[int], chars : List[int]) -> Tuple[List[int], bool]: # pre-conditions-start @@ -108,7 +108,7 @@ def is__palindrome__pred(s : List[int]) -> bool : Requires(Acc(list_pred(s), 1/2)) # pre-conditions-end - # impl-start + # pure-start return Forall(int, lambda d_10_k_: (not (((0) <= (d_10_k_)) and ((d_10_k_) < (len(s)))) or (((s)[d_10_k_]) == ((s)[((len(s)) - (1)) - (d_10_k_)])))) - # impl-end + # pure-end diff --git a/Bench/114-minSubArraySum.py b/Bench/114-minSubArraySum.py index 8b5ebf2..acda110 100644 --- a/Bench/114-minSubArraySum.py +++ b/Bench/114-minSubArraySum.py @@ -8,12 +8,12 @@ def Sum(a : List[int], s : int, t : int) -> int : Requires(((0) <= (s)) and ((s) <= (t)) and ((t) <= (len(a)))) # pre-conditions-end - # impl-start + # pure-start if s == t: return 0 else: return (a)[t - 1] + (Sum(a, s, t - 1)) - # impl-end + # pure-end def minSubArraySum(a : List[int]) -> int: # pre-conditions-start diff --git a/Bench/116-sort_array.py b/Bench/116-sort_array.py index 26efd3a..fcd5fa9 100644 --- a/Bench/116-sort_array.py +++ b/Bench/116-sort_array.py @@ -7,12 +7,12 @@ def popcount(n : int) -> int : Requires(n >= 0) # pre-conditions-end - # impl-start + # pure-start if n == 0: return 0 else: return ((n % 2)) + popcount(n // 10) - # impl-end + # pure-end def BubbleSort(a1 : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/118-get_closest_vowel.py b/Bench/118-get_closest_vowel.py index e449299..9febf47 100644 --- a/Bench/118-get_closest_vowel.py +++ b/Bench/118-get_closest_vowel.py @@ -3,15 +3,15 @@ @Pure def IsVowel(c : int) -> bool : - # impl-start + # pure-start return ((((((((((c) == (97)) or ((c) == (101))) or ((c) == (105))) or ((c) == (111))) or ((c) == (117))) or ((c) == (65))) or ((c) == (69))) or ((c) == (73))) or ((c) == (79))) or ((c) == (85)) - # impl-end + # pure-end @Pure def IsConsonant(c : int) -> bool : - # impl-start + # pure-start return ((((65) <= (c)) and ((c) <= (90))) or (((97) <= (c)) and ((c) <= (122)))) and (not(IsVowel(c))) - # impl-end + # pure-end def get__closest__vowel(word : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/119-match_parens.py b/Bench/119-match_parens.py index 61e665d..82e79d3 100644 --- a/Bench/119-match_parens.py +++ b/Bench/119-match_parens.py @@ -8,12 +8,12 @@ def CalBal(s : List[int], i : int, j : int, acc : int) -> int: Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return acc else: return (1 if s[j - 1] == 0 else -1) + CalBal(s, i, j - 1, acc) - # impl-end + # pure-end def checkFixed(s1 : List[int], s2 : List[int]) -> bool: # pre-conditions-start @@ -101,4 +101,4 @@ def checkFixed(s1 : List[int], s2 : List[int]) -> bool: i = i + 1 return True - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/121-solution.py b/Bench/121-solution.py index 312d6e9..a20fb51 100644 --- a/Bench/121-solution.py +++ b/Bench/121-solution.py @@ -8,12 +8,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j + 1 and j < len(s)) # pre-conditions-end - # impl-start + # pure-start if i > j: return 0 else: return ((s)[j] if ((((j) % 2) == 0) and ((s)[j] % 2 == 1)) else 0) + (psum(i, j - 1, s)) - # impl-end + # pure-end def add(v : List[int]) -> int: # pre-conditions-start diff --git a/Bench/122-add_elements.py b/Bench/122-add_elements.py index 23cacb7..3aaa71a 100644 --- a/Bench/122-add_elements.py +++ b/Bench/122-add_elements.py @@ -8,12 +8,12 @@ def sum__chars__rec(i : int, j : int, lst : List[int]) -> int : Requires(((0) <= (i)) and ((i) <= (j)) and ((j) <= (len(lst)))) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return ((lst)[j - 1] if (lst)[j - 1] < 100 else 0) + sum__chars__rec(i, j - 1, lst) - # impl-end + # pure-end def SumElementsWithAtMostTwoDigits(lst : List[int], k : int) -> int: # pre-conditions-start @@ -44,4 +44,4 @@ def SumElementsWithAtMostTwoDigits(lst : List[int], k : int) -> int: sum = (sum) + ((lst)[d_3_i_]) d_3_i_ = (d_3_i_) + (1) return sum - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/123-get_odd_collatz.py b/Bench/123-get_odd_collatz.py index 4107008..75788ca 100644 --- a/Bench/123-get_odd_collatz.py +++ b/Bench/123-get_odd_collatz.py @@ -12,12 +12,12 @@ def iterate__to__odd(n : int) -> int : Ensures(Result() > 0) # post-conditions-end - # impl-start + # pure-start if (n // 2) % 2 == 1: return n // 2 else: return iterate__to__odd(n // 2) - # impl-end + # pure-end @Pure def next__odd__collatz(n : int) -> int : @@ -29,13 +29,12 @@ def next__odd__collatz(n : int) -> int : Ensures(Result() % 2 == 1) # post-conditions-end - # impl-start + # pure-start if ((n % 2)) == (0): return iterate__to__odd(n) else: return iterate__to__odd(((3) * (n)) + (1)) - # impl-end - + # pure-end def next__odd__collatz__iter(n : int) -> int: # pre-conditions-start @@ -102,7 +101,7 @@ def get__odd__collatz__unsorted(n : int) -> List[int]: Invariant(Forall(int, lambda d_5_i_: (not (((1) <= (d_5_i_)) and ((d_5_i_) < (len(odd__collatz)))) or (((odd__collatz)[d_5_i_]) == (next__odd__collatz((odd__collatz)[(d_5_i_) - (1)]))), [[next__odd__collatz((odd__collatz)[(d_5_i_) - (1)])]]))) # invariants-end - odd__collatz = (odd__collatz) + [next__odd__collatz((odd__collatz)[(len(odd__collatz)) - (1)])] + odd__collatz = (odd__collatz) + [next__odd__collatz__iter((odd__collatz)[(len(odd__collatz)) - (1)])] # assert-start Assert(Forall(int, lambda d_5_i_: (not (((1) <= (d_5_i_)) and ((d_5_i_) < (len(odd__collatz)))) or (((odd__collatz)[d_5_i_]) == (next__odd__collatz((odd__collatz)[(d_5_i_) - (1)]))), [[next__odd__collatz((odd__collatz)[(d_5_i_) - (1)])]]))) diff --git a/Bench/126-is_sorted.py b/Bench/126-is_sorted.py index 42b2a2e..18bd95d 100644 --- a/Bench/126-is_sorted.py +++ b/Bench/126-is_sorted.py @@ -71,10 +71,9 @@ def count_set(a : List[int], x : int, i : int) -> int: # post-conditions-start # post-conditions-end - # impl-start + # pure-start if (i) == 0: return 0 else: return (count_set(a, x, (i) - (1))) + (((a)[(i) - (1)]) == (x)) - # impl-end - + # pure-end diff --git a/Bench/127-intersection.py b/Bench/127-intersection.py index 0a16d63..e389ed0 100644 --- a/Bench/127-intersection.py +++ b/Bench/127-intersection.py @@ -1,30 +1,33 @@ from typing import cast, List, Dict, Set, Optional, Union from nagini_contracts.contracts import * +#use-as-unpure @Pure def IsPrime(n : int) -> bool : - # impl-start + # pure-start return ((n) > (1)) and (Forall(int, lambda d_0_k_: not (((2) <= (d_0_k_)) and ((d_0_k_) < (n))) or (((n % d_0_k_)) != (0)))) - # impl-end + # pure-end +#use-as-unpure @Pure def min(a : int, b : int) -> int : - # impl-start + # pure-start if (a) <= (b): return a elif True: return b - # impl-end + # pure-end +#use-as-unpure @Pure def max(a : int, b : int) -> int : - # impl-start + # pure-start if (a) >= (b): return a elif True: return b - # impl-end + # pure-end def Intersection(start1 : int, end1 : int, start2 : int, end2 : int) -> str: # pre-conditions-start diff --git a/Bench/128-prod_signs.py b/Bench/128-prod_signs.py index b219ce9..f75f548 100644 --- a/Bench/128-prod_signs.py +++ b/Bench/128-prod_signs.py @@ -1,14 +1,15 @@ from typing import cast, List, Dict, Set, Optional, Union, Tuple from nagini_contracts.contracts import * +#use-as-unpure @Pure def abs(x : int) -> int : - # impl-start + # pure-start if (x) >= (0): return x elif True: return (0) - (x) - # impl-end + # pure-end @Pure def sum__abs(i : int, j : int, s : List[int]) -> int : @@ -17,12 +18,12 @@ def sum__abs(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return abs(s[j - 1]) + sum__abs(i, j - 1, s) - # impl-end + # pure-end @Pure def count_negatives(i : int, j : int, s : List[int]) -> int: @@ -31,12 +32,12 @@ def count_negatives(i : int, j : int, s : List[int]) -> int: Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (1 if s[j - 1] < 0 else 0) + count_negatives(i, j - 1, s) - # impl-end + # pure-end def prod__signs(numbers : List[int]) -> int: # pre-conditions-start diff --git a/Bench/133-sum-squares.py b/Bench/133-sum-squares.py index 96a28b1..c5c9d7a 100644 --- a/Bench/133-sum-squares.py +++ b/Bench/133-sum-squares.py @@ -8,12 +8,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return (s)[j - 1] * (s)[j - 1] + (psum(i, j - 1, s)) - # impl-end + # pure-end def sum__squares(lst : List[int]) -> int: # pre-conditions-start diff --git a/Bench/134-check_if_last_char_is_a_letter.py b/Bench/134-check_if_last_char_is_a_letter.py index 41aaa8f..f60874e 100644 --- a/Bench/134-check_if_last_char_is_a_letter.py +++ b/Bench/134-check_if_last_char_is_a_letter.py @@ -17,6 +17,6 @@ def check__if__last__char__is__a__letter(s : List[int]) -> bool: @Pure def is__alpha(c : int) -> bool : - # impl-start + # pure-start return (((97) <= (c)) and ((c) <= (122))) or (((65) <= (c)) and ((c) <= (90))) - # impl-end + # pure-end diff --git a/Bench/136-largest_smallest_integers.py b/Bench/136-largest_smallest_integers.py index 35d27f4..5f86bbe 100644 --- a/Bench/136-largest_smallest_integers.py +++ b/Bench/136-largest_smallest_integers.py @@ -7,9 +7,9 @@ def getVal(mx: Optional[int]) -> int: Requires(mx is not None) # pre-conditions-end - # impl-start + # pure-start return mx - # impl-end + # pure-end def largest__smallest__integers(arr : List[int]) -> Tuple[Optional[int], Optional[int]]: # pre-conditions-start diff --git a/Bench/139-special_factorial.py b/Bench/139-special_factorial.py index 38e8125..f1722e9 100644 --- a/Bench/139-special_factorial.py +++ b/Bench/139-special_factorial.py @@ -10,12 +10,12 @@ def factorial(n : int) -> int : Ensures((Result()) >= (0)) # post-conditions-end - # impl-start + # pure-start if (n) == (0): return 1 else: return (n) * (factorial((n) - (1))) - # impl-end + # pure-end @Pure def special__factorial__rec(n : int) -> int : @@ -26,12 +26,12 @@ def special__factorial__rec(n : int) -> int : Ensures((Result()) >= (0)) # post-conditions-end - # impl-start + # pure-start if (n) == (0): return 1 else: return factorial(n) * (special__factorial__rec((n) - (1))) - # impl-end + # pure-end def special__factorial(n : int) -> int: # pre-conditions-start diff --git a/Bench/142-sum_squares.py b/Bench/142-sum_squares.py index 848636f..2e4fe05 100644 --- a/Bench/142-sum_squares.py +++ b/Bench/142-sum_squares.py @@ -1,16 +1,17 @@ from typing import cast, List, Dict, Set, Optional, Union from nagini_contracts.contracts import * +#use-as-unpure @Pure def checkVal(x : int) -> int: - # impl-start + # pure-start if x % 3 == 0: return x * x elif x % 4 == 0 and x % 3 != 0: return x * x * x else: return x - # impl-end + # pure-end @Pure def psum(i : int, j : int, s : List[int]) -> int : @@ -19,12 +20,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return checkVal((s)[j - 1]) + (psum(i, j - 1, s)) - # impl-end + # pure-end def sum__squares(lst : List[int]) -> int: # pre-conditions-start diff --git a/Bench/146_specialFilter.py b/Bench/146_specialFilter.py index 28ec032..6014d76 100644 --- a/Bench/146_specialFilter.py +++ b/Bench/146_specialFilter.py @@ -10,18 +10,18 @@ def first__digit(n : int) -> int : Ensures(0 <= Result() and (Result()) < (10)) # post-conditions-end - # impl-start + # pure-start if n < 10: return n else: return first__digit(n // 10) - # impl-end + # pure-end @Pure def last__digit(n : int) -> int : - # impl-start + # pure-start return (n % 10) - # impl-end + # pure-end def specialFilter(s : List[int]) -> List[int]: # pre-conditions-start diff --git a/Bench/150-x_or_y.py b/Bench/150-x_or_y.py index 33447c6..5ff9105 100644 --- a/Bench/150-x_or_y.py +++ b/Bench/150-x_or_y.py @@ -3,10 +3,10 @@ @Pure def IsPrime(n : int) -> bool : - # impl-start + # pure-start return ((n) > (1)) and (Forall(int, lambda d_0_k_: not (((2) <= (d_0_k_)) and ((d_0_k_) < (n))) or (((n % d_0_k_)) != (0)))) - # impl-end + # pure-end def x__or__y(n : int, x : int, y : int) -> int: diff --git a/Bench/151-double_the_difference.py b/Bench/151-double_the_difference.py index b0adb19..9b12989 100644 --- a/Bench/151-double_the_difference.py +++ b/Bench/151-double_the_difference.py @@ -1,15 +1,16 @@ from typing import cast, List, Dict, Set, Optional, Union from nagini_contracts.contracts import * +#use-as-unpure @Pure def checkVal(x : int) -> int: - # impl-start + # pure-start if x > 0 and x % 2 != 0: return x * x else: return 0 - # impl-end - + # pure-end + @Pure def psum(i : int, j : int, s : List[int]) -> int : # pre-conditions-start @@ -17,12 +18,12 @@ def psum(i : int, j : int, s : List[int]) -> int : Requires(0 <= i and i <= j and j <= len(s)) # pre-conditions-end - # impl-start + # pure-start if i == j: return 0 else: return checkVal((s)[j - 1]) + (psum(i, j - 1, s)) - # impl-end + # pure-end def double__the__difference(lst : List[int]) -> int: @@ -48,4 +49,4 @@ def double__the__difference(lst : List[int]) -> int: r = (r) + checkVal(((lst)[d_3_k_])) d_3_k_ = (d_3_k_) + (1) return r - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/152-compare.py b/Bench/152-compare.py index 71810e1..e7ed6cd 100644 --- a/Bench/152-compare.py +++ b/Bench/152-compare.py @@ -38,9 +38,9 @@ def Compare(scores : List[int], guesses : List[int]) -> List[int]: @Pure def abs(x : int) -> int : - # impl-start + # pure-start if (x) < (0): return (0) - (x) elif True: return x - # impl-end \ No newline at end of file + # pure-end diff --git a/Bench/154-cycpattern_check.py b/Bench/154-cycpattern_check.py index 9f4046b..9584094 100644 --- a/Bench/154-cycpattern_check.py +++ b/Bench/154-cycpattern_check.py @@ -8,11 +8,11 @@ def IsSubstring(s : List[int], sub : List[int], n : int) -> bool : Requires(Acc(list_pred(sub))) # pre-conditions-end - # impl-start + # pure-start return ((len(s)) >= (len(sub))) and (Exists(int, lambda d_0_i_: (((0) <= (d_0_i_)) and ((d_0_i_) < 1 + ((len(s)) - (len(sub))))) and ( Forall(int, lambda y: (Implies(y >= 0 and y < len(sub), sub[(n + y) % len(sub)] == s[d_0_i_ + y]), [[sub[(n + y) % len(sub)] == s[d_0_i_ + y]]]))))) - # impl-end + # pure-end def CycpatternCheck(word : List[int], pattern : List[int]) -> bool: # pre-conditions-start @@ -42,4 +42,4 @@ def CycpatternCheck(word : List[int], pattern : List[int]) -> bool: return True d_3_i_ = (d_3_i_) + (1) return False - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/155_even_odd_count.py b/Bench/155_even_odd_count.py index eed874a..7a168ef 100644 --- a/Bench/155_even_odd_count.py +++ b/Bench/155_even_odd_count.py @@ -33,12 +33,12 @@ def odd__count(n : int) -> int : Requires(n >= 0) # pre-conditions-end - # impl-start + # pure-start if n == 0: return 0 else: return (n % 2) + odd__count(n // 10) - # impl-end + # pure-end @Pure def even__count(n : int) -> int : @@ -46,9 +46,9 @@ def even__count(n : int) -> int : Requires(n >= 0) # pre-conditions-end - # impl-start + # pure-start if n == 0: return 0 else: return ((n % 2) == 0) + even__count(n // 10) - # impl-end + # pure-end diff --git a/Bench/159-eat.py b/Bench/159-eat.py index 5280fce..19ca200 100644 --- a/Bench/159-eat.py +++ b/Bench/159-eat.py @@ -20,4 +20,4 @@ def eat(number : int, need : int, remaining : int) -> List[int]: result[0] = (number) + (need) result[1] = (remaining) - (need) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/161-solve.py b/Bench/161-solve.py index dd45a72..8bde156 100644 --- a/Bench/161-solve.py +++ b/Bench/161-solve.py @@ -81,15 +81,15 @@ def reverse(str : List[int]) -> List[int]: @Pure def is__alpha(c : int) -> bool : - # impl-start + # pure-start return (((97) <= (c)) and ((c) <= (122))) or (((65) <= (c)) and ((c) <= (90))) - # impl-end + # pure-end @Pure def flip__case(c : int) -> int : - # impl-start + # pure-start if ((97) <= (c)) and ((c) <= (122)): return ((c) - (97)) + (65) elif True: return ((c) - (65)) + (97) - # impl-end + # pure-end diff --git a/Bench/163-generate_integers.py b/Bench/163-generate_integers.py index 4992647..3d32544 100644 --- a/Bench/163-generate_integers.py +++ b/Bench/163-generate_integers.py @@ -1,37 +1,25 @@ from typing import cast, List, Dict, Set, Optional, Union from nagini_contracts.contracts import * +#use-as-unpure @Pure -def min(a : int, b : int) -> int: - # pre-conditions-start - Ensures(((Result()) == (a)) or ((Result()) == (b))) - Ensures(((Result()) <= (a)) and ((Result()) <= (b))) - # pre-conditions-end - - # impl-start - m : int = int(0) - if (a) < (b): - m = a +def min(a : int, b : int) -> int : + # pure-start + if (a) <= (b): + return a elif True: - m = b - return m - # impl-end + return b + # pure-end +#use-as-unpure @Pure -def max(a : int, b : int) -> int: - # pre-conditions-start - Ensures(((Result()) == (a)) or ((Result()) == (b))) - Ensures(((Result()) >= (a)) and ((Result()) >= (b))) - # pre-conditions-end - - # impl-start - m : int = int(0) - if (a) > (b): - m = a +def max(a : int, b : int) -> int : + # pure-start + if (a) >= (b): + return a elif True: - m = b - return m - # impl-end + return b + # pure-end def generate__integers(a : int, b : int) -> List[int]: # post-conditions-start @@ -65,4 +53,4 @@ def generate__integers(a : int, b : int) -> List[int]: result = (result) + (([d_6_i_])) d_6_i_ = (d_6_i_) + (1) return result - # impl-end \ No newline at end of file + # impl-end diff --git a/Bench/text-descriptions/000-has-close-elements.txt b/Bench/text-descriptions/000-has-close-elements.txt new file mode 100644 index 0000000..6dd9a8e --- /dev/null +++ b/Bench/text-descriptions/000-has-close-elements.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `has_close_elements`: Check if in given list of numbers, are any two numbers closer to each other than given threshold. diff --git a/Bench/text-descriptions/001-separate-paren-groups.txt b/Bench/text-descriptions/001-separate-paren-groups.txt new file mode 100644 index 0000000..abdb6fc --- /dev/null +++ b/Bench/text-descriptions/001-separate-paren-groups.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `separate_paren_groups`: Input to this function is a string containing multiple groups of nested parentheses. Your goal is to separate those group into separate strings and return the list of those. Separate groups are balanced (each open brace is properly closed) and not nested within each other Ignore any spaces in the input string. diff --git a/Bench/text-descriptions/002-truncate.txt b/Bench/text-descriptions/002-truncate.txt new file mode 100644 index 0000000..e0dcf49 --- /dev/null +++ b/Bench/text-descriptions/002-truncate.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `truncate_number`: Given a positive floating point number, it can be decomposed into and integer part (largest integer smaller than given number) and decimals (leftover part always smaller than 1). Return the decimal part of the number. diff --git a/Bench/text-descriptions/003-below-zero.txt b/Bench/text-descriptions/003-below-zero.txt new file mode 100644 index 0000000..0cf4c3d --- /dev/null +++ b/Bench/text-descriptions/003-below-zero.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `below_zero`: You're given a list of deposit and withdrawal operations on a bank account that starts with zero balance. Your task is to detect if at any point the balance of account fallls below zero, and at that point function should return True. Otherwise it should return False. diff --git a/Bench/text-descriptions/004-mean_absolute_derivation.txt b/Bench/text-descriptions/004-mean_absolute_derivation.txt new file mode 100644 index 0000000..f2f7b41 --- /dev/null +++ b/Bench/text-descriptions/004-mean_absolute_derivation.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `mean_absolute_deviation`: For a given list of input numbers, calculate Mean Absolute Deviation around the mean of this dataset. Mean Absolute Deviation is the average absolute difference between each element and a centerpoint (mean in this case): MAD = average | x - x_mean | diff --git a/Bench/text-descriptions/005-intersperse.txt b/Bench/text-descriptions/005-intersperse.txt new file mode 100644 index 0000000..c755c62 --- /dev/null +++ b/Bench/text-descriptions/005-intersperse.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `intersperse`: Insert a number 'delimeter' between every two consecutive elements of input list `numbers' diff --git a/Bench/text-descriptions/006-parse_nested_parens.txt b/Bench/text-descriptions/006-parse_nested_parens.txt new file mode 100644 index 0000000..56859f1 --- /dev/null +++ b/Bench/text-descriptions/006-parse_nested_parens.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `parse_nested_parens`: Input to this function is a string represented multiple groups for nested parentheses separated by spaces. For each of the group, output the deepest level of nesting of parentheses. E.g. (()()) has maximum two levels of nesting while ((())) has three. diff --git a/Bench/text-descriptions/007-filter_by_substring.txt b/Bench/text-descriptions/007-filter_by_substring.txt new file mode 100644 index 0000000..a0f57ce --- /dev/null +++ b/Bench/text-descriptions/007-filter_by_substring.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `filter_by_substring`: Filter an input list of strings only for ones that contain given substring diff --git a/Bench/text-descriptions/008-sum-product.txt b/Bench/text-descriptions/008-sum-product.txt new file mode 100644 index 0000000..cd02eb1 --- /dev/null +++ b/Bench/text-descriptions/008-sum-product.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sum_product`: For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list. Empty sum should be equal to 0 and empty product should be equal to 1. diff --git a/Bench/text-descriptions/009-rolling-max.txt b/Bench/text-descriptions/009-rolling-max.txt new file mode 100644 index 0000000..c00804d --- /dev/null +++ b/Bench/text-descriptions/009-rolling-max.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `rolling_max`: From a given list of integers, generate a list of rolling maximum element found until given moment in the sequence. diff --git a/Bench/text-descriptions/010-is_palindrome.txt b/Bench/text-descriptions/010-is_palindrome.txt new file mode 100644 index 0000000..1f88be1 --- /dev/null +++ b/Bench/text-descriptions/010-is_palindrome.txt @@ -0,0 +1,4 @@ +You have to write 2 functions in nagini (python verification framework), using the given helper functions +The descriptions are as follows: +function `is_palindrome`: Test if given string is a palindrome +function `make_palindrome`: Find the shortest palindrome that begins with a supplied string. Algorithm idea is simple: - Find the longest postfix of supplied string that is a palindrome. - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix. diff --git a/Bench/text-descriptions/011-string_xor.txt b/Bench/text-descriptions/011-string_xor.txt new file mode 100644 index 0000000..85d1cba --- /dev/null +++ b/Bench/text-descriptions/011-string_xor.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `string_xor`: Input are two strings a and b consisting only of 1s and 0s. Perform binary XOR on these inputs and return result also as a string. diff --git a/Bench/text-descriptions/012-longest.txt b/Bench/text-descriptions/012-longest.txt new file mode 100644 index 0000000..c424e96 --- /dev/null +++ b/Bench/text-descriptions/012-longest.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `longest`: Out of list of strings, return the longest one. Return the first one in case of multiple strings of the same length. Return None in case the input list is empty. diff --git a/Bench/text-descriptions/013-greatest-common-divisor.txt b/Bench/text-descriptions/013-greatest-common-divisor.txt new file mode 100644 index 0000000..971ecd5 --- /dev/null +++ b/Bench/text-descriptions/013-greatest-common-divisor.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `greatest_common_divisor`: Return a greatest common divisor of two integers a and b diff --git a/Bench/text-descriptions/014-all_prefixes.txt b/Bench/text-descriptions/014-all_prefixes.txt new file mode 100644 index 0000000..42d86bc --- /dev/null +++ b/Bench/text-descriptions/014-all_prefixes.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `all_prefixes`: Return list of all prefixes from shortest to longest of the input string diff --git a/Bench/text-descriptions/016-count_distinct_characters.txt b/Bench/text-descriptions/016-count_distinct_characters.txt new file mode 100644 index 0000000..f6a9414 --- /dev/null +++ b/Bench/text-descriptions/016-count_distinct_characters.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `count_distinct_characters`: Given a string, find out how many distinct characters (regardless of case) does it consist of diff --git a/Bench/text-descriptions/018-how_many_times.txt b/Bench/text-descriptions/018-how_many_times.txt new file mode 100644 index 0000000..1c1b7a4 --- /dev/null +++ b/Bench/text-descriptions/018-how_many_times.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `how_many_times`: Find how many times a given substring can be found in the original string. Count overlaping cases. diff --git a/Bench/text-descriptions/020-find-closest-elements.txt b/Bench/text-descriptions/020-find-closest-elements.txt new file mode 100644 index 0000000..7f5bf58 --- /dev/null +++ b/Bench/text-descriptions/020-find-closest-elements.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `find_closest_elements`: From a supplied list of numbers (of length at least two) select and return two that are the closest to each other and return them in order (smaller number, larger number). diff --git a/Bench/text-descriptions/021-rescale_to_unit.txt b/Bench/text-descriptions/021-rescale_to_unit.txt new file mode 100644 index 0000000..4d4a288 --- /dev/null +++ b/Bench/text-descriptions/021-rescale_to_unit.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `rescale_to_unit`: Given list of numbers (of at least two elements), apply a linear transform to that list, such that the smallest number will become 0 and the largest will become 1 diff --git a/Bench/text-descriptions/023-strlen.txt b/Bench/text-descriptions/023-strlen.txt new file mode 100644 index 0000000..b80de6c --- /dev/null +++ b/Bench/text-descriptions/023-strlen.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `strlen`: Return length of given string diff --git a/Bench/text-descriptions/024-largest-divisor.txt b/Bench/text-descriptions/024-largest-divisor.txt new file mode 100644 index 0000000..88550c8 --- /dev/null +++ b/Bench/text-descriptions/024-largest-divisor.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `largest_divisor`: For a given number n, find the largest number that divides n evenly, smaller than n diff --git a/Bench/text-descriptions/025-factorize.txt b/Bench/text-descriptions/025-factorize.txt new file mode 100644 index 0000000..66aa7cb --- /dev/null +++ b/Bench/text-descriptions/025-factorize.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `factorize`: Return list of prime factors of given integer in the order from smallest to largest. Each of the factors should be listed number of times corresponding to how many times it appeares in factorization. Input number should be equal to the product of all factors diff --git a/Bench/text-descriptions/026-remove_duplicates.txt b/Bench/text-descriptions/026-remove_duplicates.txt new file mode 100644 index 0000000..eee9bf4 --- /dev/null +++ b/Bench/text-descriptions/026-remove_duplicates.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `remove_duplicates`: From a list of integers, remove all elements that occur more than once. Keep order of elements left the same as in the input. diff --git a/Bench/text-descriptions/027-flip_case.txt b/Bench/text-descriptions/027-flip_case.txt new file mode 100644 index 0000000..9f311a9 --- /dev/null +++ b/Bench/text-descriptions/027-flip_case.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `flip_case`: For a given string, flip lowercase characters to uppercase and uppercase to lowercase. diff --git a/Bench/text-descriptions/029-filter_by_prefix.txt b/Bench/text-descriptions/029-filter_by_prefix.txt new file mode 100644 index 0000000..7cdd294 --- /dev/null +++ b/Bench/text-descriptions/029-filter_by_prefix.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `filter_by_prefix`: Filter an input list of strings only for ones that start with a given prefix. diff --git a/Bench/text-descriptions/030-get-positive.txt b/Bench/text-descriptions/030-get-positive.txt new file mode 100644 index 0000000..7f4df50 --- /dev/null +++ b/Bench/text-descriptions/030-get-positive.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `get_positive`: Return only positive numbers in the list. diff --git a/Bench/text-descriptions/031-is-prime.txt b/Bench/text-descriptions/031-is-prime.txt new file mode 100644 index 0000000..cf57b13 --- /dev/null +++ b/Bench/text-descriptions/031-is-prime.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_prime`: Return true if a given number is prime, and false otherwise. diff --git a/Bench/text-descriptions/033-sort_third.txt b/Bench/text-descriptions/033-sort_third.txt new file mode 100644 index 0000000..137b844 --- /dev/null +++ b/Bench/text-descriptions/033-sort_third.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sort_third`: This function takes a list l and returns a list l' such that l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal to the values of the corresponding indicies of l, but sorted. diff --git a/Bench/text-descriptions/034-unique.txt b/Bench/text-descriptions/034-unique.txt new file mode 100644 index 0000000..296e83f --- /dev/null +++ b/Bench/text-descriptions/034-unique.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `unique`: Return sorted unique elements in a list diff --git a/Bench/text-descriptions/035-max-element.txt b/Bench/text-descriptions/035-max-element.txt new file mode 100644 index 0000000..326dd3d --- /dev/null +++ b/Bench/text-descriptions/035-max-element.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `max_element`: Return maximum element in the list. diff --git a/Bench/text-descriptions/036-fizz_buzz.txt b/Bench/text-descriptions/036-fizz_buzz.txt new file mode 100644 index 0000000..c98108e --- /dev/null +++ b/Bench/text-descriptions/036-fizz_buzz.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `fizz_buzz`: Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13. diff --git a/Bench/text-descriptions/037-sort_even.txt b/Bench/text-descriptions/037-sort_even.txt new file mode 100644 index 0000000..3ccb3a8 --- /dev/null +++ b/Bench/text-descriptions/037-sort_even.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sort_even`: This function takes a list l and returns a list l' such that l' is identical to l in the odd indicies, while its values at the even indicies are equal to the values of the even indicies of l, but sorted. diff --git a/Bench/text-descriptions/038-encode_cyclic.txt b/Bench/text-descriptions/038-encode_cyclic.txt new file mode 100644 index 0000000..d71265f --- /dev/null +++ b/Bench/text-descriptions/038-encode_cyclic.txt @@ -0,0 +1,4 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `encode_cyclic`: returns encoded string by cycling groups of three characters. +function `decode_cyclic`: takes as input string encoded with encode_cyclic function. Returns decoded string. \ No newline at end of file diff --git a/Bench/text-descriptions/040-triples-sum-to-zero.txt b/Bench/text-descriptions/040-triples-sum-to-zero.txt new file mode 100644 index 0000000..7007a66 --- /dev/null +++ b/Bench/text-descriptions/040-triples-sum-to-zero.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `triples_sum_to_zero`: triples_sum_to_zero takes a list of integers as an input. it returns True if there are three distinct elements in the list that sum to zero, and False otherwise. diff --git a/Bench/text-descriptions/041-car_race_collision.txt b/Bench/text-descriptions/041-car_race_collision.txt new file mode 100644 index 0000000..2f06b46 --- /dev/null +++ b/Bench/text-descriptions/041-car_race_collision.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `car_race_collision`: Imagine a road that's a perfectly straight infinitely long line. n cars are driving left to right; simultaneously, a different set of n cars are driving right to left. The two sets of cars start out being very far from each other. All cars move in the same speed. Two cars are said to collide when a car that's moving left to right hits a car that's moving right to left. However, the cars are infinitely sturdy and strong; as a result, they continue moving in their trajectory as if they did not collide. This function outputs the number of such collisions. diff --git a/Bench/text-descriptions/042-incr-list.txt b/Bench/text-descriptions/042-incr-list.txt new file mode 100644 index 0000000..bc75889 --- /dev/null +++ b/Bench/text-descriptions/042-incr-list.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `incr_list`: Return list with elements incremented by 1. diff --git a/Bench/text-descriptions/043-pairs-sum-to-zero.txt b/Bench/text-descriptions/043-pairs-sum-to-zero.txt new file mode 100644 index 0000000..e81274a --- /dev/null +++ b/Bench/text-descriptions/043-pairs-sum-to-zero.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `pairs_sum_to_zero`: pairs_sum_to_zero takes a list of integers as an input. it returns True if there are two distinct elements in the list that sum to zero, and False otherwise. diff --git a/Bench/text-descriptions/045-triangle_area.txt b/Bench/text-descriptions/045-triangle_area.txt new file mode 100644 index 0000000..a5dbd2f --- /dev/null +++ b/Bench/text-descriptions/045-triangle_area.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `triangle_area`: Given length of a side and high return area for a triangle. diff --git a/Bench/text-descriptions/046-fib4.txt b/Bench/text-descriptions/046-fib4.txt new file mode 100644 index 0000000..4918887 --- /dev/null +++ b/Bench/text-descriptions/046-fib4.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `fib4`: The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: fib4(0) -> 0 fib4(1) -> 0 fib4(2) -> 2 fib4(3) -> 0 fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4). Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion. diff --git a/Bench/text-descriptions/048-is-palindrome.txt b/Bench/text-descriptions/048-is-palindrome.txt new file mode 100644 index 0000000..33ec6f1 --- /dev/null +++ b/Bench/text-descriptions/048-is-palindrome.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_palindrome`: Checks if given string is a palindrome diff --git a/Bench/text-descriptions/048-is_palindrome.txt b/Bench/text-descriptions/048-is_palindrome.txt new file mode 100644 index 0000000..33ec6f1 --- /dev/null +++ b/Bench/text-descriptions/048-is_palindrome.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_palindrome`: Checks if given string is a palindrome diff --git a/Bench/text-descriptions/049-modp.txt b/Bench/text-descriptions/049-modp.txt new file mode 100644 index 0000000..73a4398 --- /dev/null +++ b/Bench/text-descriptions/049-modp.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `modp`: Return 2^n modulo p (be aware of numerics). diff --git a/Bench/text-descriptions/050-encode_shift.txt b/Bench/text-descriptions/050-encode_shift.txt new file mode 100644 index 0000000..e68a4a4 --- /dev/null +++ b/Bench/text-descriptions/050-encode_shift.txt @@ -0,0 +1,4 @@ +You have to write 2 functions in nagini (python verification framework), using the given helper functions +The descriptions are as follows: +function `encode_shift`: returns encoded string by shifting every character by 5 in the alphabet. +function `decode_shift`: takes as input string encoded with encode_shift function. Returns decoded string. diff --git a/Bench/text-descriptions/051-remove-vowels.txt b/Bench/text-descriptions/051-remove-vowels.txt new file mode 100644 index 0000000..9b6c88a --- /dev/null +++ b/Bench/text-descriptions/051-remove-vowels.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `remove_vowels`: remove_vowels is a function that takes string and returns string without vowels. diff --git a/Bench/text-descriptions/052-below-threshold.txt b/Bench/text-descriptions/052-below-threshold.txt new file mode 100644 index 0000000..8564793 --- /dev/null +++ b/Bench/text-descriptions/052-below-threshold.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `below_threshold`: Return True if all numbers in the list l are below threshold t. diff --git a/Bench/text-descriptions/053-add.txt b/Bench/text-descriptions/053-add.txt new file mode 100644 index 0000000..5147f99 --- /dev/null +++ b/Bench/text-descriptions/053-add.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `add`: Add two numbers x and y diff --git a/Bench/text-descriptions/054-same-chars.txt b/Bench/text-descriptions/054-same-chars.txt new file mode 100644 index 0000000..9fb840d --- /dev/null +++ b/Bench/text-descriptions/054-same-chars.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `same_chars`: Check if two words have the same characters. diff --git a/Bench/text-descriptions/055-fib.txt b/Bench/text-descriptions/055-fib.txt new file mode 100644 index 0000000..a98eb36 --- /dev/null +++ b/Bench/text-descriptions/055-fib.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `fib`: Return n-th Fibonacci number. diff --git a/Bench/text-descriptions/056-correct_bracketing.txt b/Bench/text-descriptions/056-correct_bracketing.txt new file mode 100644 index 0000000..c24e551 --- /dev/null +++ b/Bench/text-descriptions/056-correct_bracketing.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function ``: brackets is a string of "<" and ">". return True if every opening bracket has a corresponding closing bracket. \ No newline at end of file diff --git a/Bench/text-descriptions/057-monotonic.txt b/Bench/text-descriptions/057-monotonic.txt new file mode 100644 index 0000000..aa9d82b --- /dev/null +++ b/Bench/text-descriptions/057-monotonic.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `monotonic`: Return True is list elements are monotonically increasing or decreasing. diff --git a/Bench/text-descriptions/058-common.txt b/Bench/text-descriptions/058-common.txt new file mode 100644 index 0000000..081d5c8 --- /dev/null +++ b/Bench/text-descriptions/058-common.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `common`: Return sorted unique common elements for two lists. diff --git a/Bench/text-descriptions/059-largest-prime-factor.txt b/Bench/text-descriptions/059-largest-prime-factor.txt new file mode 100644 index 0000000..43a3589 --- /dev/null +++ b/Bench/text-descriptions/059-largest-prime-factor.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `largest_prime_factor`: Return the largest prime factor of n. Assume n > 1 and is not a prime. diff --git a/Bench/text-descriptions/060-sum-to-n.txt b/Bench/text-descriptions/060-sum-to-n.txt new file mode 100644 index 0000000..9146266 --- /dev/null +++ b/Bench/text-descriptions/060-sum-to-n.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sum_to_n`: sum_to_n is a function that sums numbers from 1 to n. diff --git a/Bench/text-descriptions/062-derivative.txt b/Bench/text-descriptions/062-derivative.txt new file mode 100644 index 0000000..16b8c5a --- /dev/null +++ b/Bench/text-descriptions/062-derivative.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `derivative`: xs represent coefficients of a polynomial. xs[0] + xs[1] * x + xs[2] * x^2 + .... Return derivative of this polynomial in the same form. diff --git a/Bench/text-descriptions/063-fibfib.txt b/Bench/text-descriptions/063-fibfib.txt new file mode 100644 index 0000000..f9ee22a --- /dev/null +++ b/Bench/text-descriptions/063-fibfib.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `fibfib`: The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows: fibfib(0) == 0 fibfib(1) == 0 fibfib(2) == 1 fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3). Please write a function to efficiently compute the n-th element of the fibfib number sequence. diff --git a/Bench/text-descriptions/064-vowels-count.txt b/Bench/text-descriptions/064-vowels-count.txt new file mode 100644 index 0000000..cfba82c --- /dev/null +++ b/Bench/text-descriptions/064-vowels-count.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `vowels_count`: Write a function vowels_count which takes a string representing a word as input and returns the number of vowels in the string. Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a vowel, but only when it is at the end of the given word. Example: diff --git a/Bench/text-descriptions/065-circular_shift.txt b/Bench/text-descriptions/065-circular_shift.txt new file mode 100644 index 0000000..9230ad4 --- /dev/null +++ b/Bench/text-descriptions/065-circular_shift.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `circular_shift`: Circular shift the digits of the integer x, shift the digits right by shift and return the result as a string. If shift > number of digits, return digits reversed. diff --git a/Bench/text-descriptions/066-digitSum.txt b/Bench/text-descriptions/066-digitSum.txt new file mode 100644 index 0000000..60bf426 --- /dev/null +++ b/Bench/text-descriptions/066-digitSum.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `digitSum`: Task Write a function that takes a string as input and returns the sum of the upper characters only' ASCII codes. diff --git a/Bench/text-descriptions/068-pluck.txt b/Bench/text-descriptions/068-pluck.txt new file mode 100644 index 0000000..12af69b --- /dev/null +++ b/Bench/text-descriptions/068-pluck.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `pluck`: "Given an array representing a branch of a tree that has non-negative integer nodes your task is to pluck one of the nodes and return it. The plucked node should be the node with the smallest even value. If multiple nodes with the same smallest even value are found return the node that has smallest index. The plucked node should be returned in a list, [ smalest_value, its index ], If there are no even values or the given array is empty, return []. diff --git a/Bench/text-descriptions/069-search.txt b/Bench/text-descriptions/069-search.txt new file mode 100644 index 0000000..c290d21 --- /dev/null +++ b/Bench/text-descriptions/069-search.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `search`: You are given a non-empty list of positive integers. Return the greatest integer that is greater than zero, and has a frequency greater than or equal to the value of the integer itself. The frequency of an integer is the number of times it appears in the list. If no such a value exist, return -1. diff --git a/Bench/text-descriptions/070-strange_sort_list.txt b/Bench/text-descriptions/070-strange_sort_list.txt new file mode 100644 index 0000000..fbf02aa --- /dev/null +++ b/Bench/text-descriptions/070-strange_sort_list.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `strange_sort_list`: Given list of integers, return list in strange order. Strange sorting, is when you start with the minimum value, then maximum of the remaining integers, then minimum and so on. diff --git a/Bench/text-descriptions/072-will_it_fly.txt b/Bench/text-descriptions/072-will_it_fly.txt new file mode 100644 index 0000000..6aa2fa7 --- /dev/null +++ b/Bench/text-descriptions/072-will_it_fly.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `will_it_fly`: Write a function that returns True if the object q will fly, and False otherwise. The object q will fly if it's balanced (it is a palindromic list) and the sum of its elements is less than or equal the maximum possible weight w. diff --git a/Bench/text-descriptions/073-smallest_change.txt b/Bench/text-descriptions/073-smallest_change.txt new file mode 100644 index 0000000..7190b04 --- /dev/null +++ b/Bench/text-descriptions/073-smallest_change.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `smallest_change`: Given an array arr of integers, find the minimum number of elements that need to be changed to make the array palindromic. A palindromic array is an array that is read the same backwards and forwards. In one change, you can change one element to any other element. diff --git a/Bench/text-descriptions/074-total_match.txt b/Bench/text-descriptions/074-total_match.txt new file mode 100644 index 0000000..09998c3 --- /dev/null +++ b/Bench/text-descriptions/074-total_match.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `total_match`: Write a function that accepts two lists of strings and returns the list that has total number of chars in the all strings of the list less than the other list. if the two lists have the same number of chars, return the first list. diff --git a/Bench/text-descriptions/075-is_multiply_prime.txt b/Bench/text-descriptions/075-is_multiply_prime.txt new file mode 100644 index 0000000..f0303aa --- /dev/null +++ b/Bench/text-descriptions/075-is_multiply_prime.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_multiply_prime`: Write a function that returns true if the given number is the multiplication of 3 prime numbers and false otherwise. Knowing that (a) is less then 100. diff --git a/Bench/text-descriptions/076-is_simple_power.txt b/Bench/text-descriptions/076-is_simple_power.txt new file mode 100644 index 0000000..9203fd6 --- /dev/null +++ b/Bench/text-descriptions/076-is_simple_power.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_simple_power`: Your task is to write a function that returns true if a number x is a simple power of n and false in other cases. x is a simple power of n if n**int=x diff --git a/Bench/text-descriptions/077-iscube.txt b/Bench/text-descriptions/077-iscube.txt new file mode 100644 index 0000000..7394c1f --- /dev/null +++ b/Bench/text-descriptions/077-iscube.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `iscube`: Write a function that takes an integer a and returns True if this ingeger is a cube of some integer number. Note: you may assume the input is always valid. diff --git a/Bench/text-descriptions/078-hex_key.txt b/Bench/text-descriptions/078-hex_key.txt new file mode 100644 index 0000000..13847fc --- /dev/null +++ b/Bench/text-descriptions/078-hex_key.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `hex_key`: You have been tasked to write a function that receives a hexadecimal number as a string and counts the number of hexadecimal digits that are primes (prime number, or a prime, is a natural number greater than 1 that is not a product of two smaller natural numbers). Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Prime numbers are 2, 3, 5, 7, 11, 13, 17,... So you have to determine a number of the following digits: 2, 3, 5, 7, B (=decimal 11), D (=decimal 13). Note: you may assume the input is always correct or empty string, and symbols A,B,C,D,E,F are always uppercase. diff --git a/Bench/text-descriptions/079-decimal_to_binary.txt b/Bench/text-descriptions/079-decimal_to_binary.txt new file mode 100644 index 0000000..f54e87b --- /dev/null +++ b/Bench/text-descriptions/079-decimal_to_binary.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `decimal_to_binary`: You will be given a number in decimal form and your task is to convert it to binary format. The function should return a string, with each character representing a binary number. Each character in the string will be '0' or '1'. There will be an extra couple of characters 'db' at the beginning and at the end of the string. The extra characters are there to help with the format. diff --git a/Bench/text-descriptions/080-is_happy.txt b/Bench/text-descriptions/080-is_happy.txt new file mode 100644 index 0000000..e62061e --- /dev/null +++ b/Bench/text-descriptions/080-is_happy.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_happy`: You are given a string s. Your task is to check if the string is happy or not. A string is happy if its length is at least 3 and every 3 consecutive letters are distinct diff --git a/Bench/text-descriptions/081-numerical_letter_grade.txt b/Bench/text-descriptions/081-numerical_letter_grade.txt new file mode 100644 index 0000000..da33237 --- /dev/null +++ b/Bench/text-descriptions/081-numerical_letter_grade.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `numerical_letter_grade`: It is the last week of the semester and the teacher has to give the grades to students. The teacher has been making her own algorithm for grading. The only problem is, she has lost the code she used for grading. She has given you a list of GPAs for some students and you have to write a function that can output a list of letter grades using the following table: GPA |Letter grade 4.0A+ > 3.7A > 3.3A- > 3.0B+ > 2.7B > 2.3B- > 2.0C+ > 1.7C > 1.3C- > 1.0D+ > 0.7D > 0.0D- 0.0E diff --git a/Bench/text-descriptions/082-prime-length.txt b/Bench/text-descriptions/082-prime-length.txt new file mode 100644 index 0000000..acc558a --- /dev/null +++ b/Bench/text-descriptions/082-prime-length.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `prime_length`: Write a function that takes a string and returns True if the string length is a prime number or False otherwise diff --git a/Bench/text-descriptions/083-starts_one_ends.txt b/Bench/text-descriptions/083-starts_one_ends.txt new file mode 100644 index 0000000..7760ae4 --- /dev/null +++ b/Bench/text-descriptions/083-starts_one_ends.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `starts_one_ends`: Given a positive integer n, return the count of the numbers of n-digit positive integers that start or end with 1. diff --git a/Bench/text-descriptions/084-solve.txt b/Bench/text-descriptions/084-solve.txt new file mode 100644 index 0000000..8689ec7 --- /dev/null +++ b/Bench/text-descriptions/084-solve.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `solve`: Given a positive integer N, return the total sum of its digits in binary. diff --git a/Bench/text-descriptions/085-add.txt b/Bench/text-descriptions/085-add.txt new file mode 100644 index 0000000..bef1a3b --- /dev/null +++ b/Bench/text-descriptions/085-add.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `add`: Given a non-empty list of integers lst. add the even elements that are at odd indices.. diff --git a/Bench/text-descriptions/087-get_row.txt b/Bench/text-descriptions/087-get_row.txt new file mode 100644 index 0000000..b91da99 --- /dev/null +++ b/Bench/text-descriptions/087-get_row.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `get_row`: You are given a 2 dimensional data, as a nested lists, which is similar to matrix, however, unlike matrices, each row may contain a different number of columns. Given lst, and integer x, find integers x in the list, and return list of tuples, [(x1, y1), (x2, y2) ...] such that each tuple is a coordinate - (row, columns), starting with 0. Sort coordinates initially by rows in ascending order. Also, sort coordinates of the row by columns in descending order. diff --git a/Bench/text-descriptions/088-sort_array.txt b/Bench/text-descriptions/088-sort_array.txt new file mode 100644 index 0000000..2054ded --- /dev/null +++ b/Bench/text-descriptions/088-sort_array.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sort_array`: Given an array of non-negative integers, return a copy of the given array after sorting, you will sort the given array in ascending order if the sum( first index value, last index value) is odd, or sort it in descending order if the sum( first index value, last index value) is even. Note: * don't change the given array. diff --git a/Bench/text-descriptions/089-encrypt.txt b/Bench/text-descriptions/089-encrypt.txt new file mode 100644 index 0000000..bca6c9a --- /dev/null +++ b/Bench/text-descriptions/089-encrypt.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `encrypt`: Create a function encrypt that takes a string as an argument and returns a string encrypted with the alphabet being rotated. The alphabet should be rotated in a manner such that the letters shift down by two multiplied to two places. diff --git a/Bench/text-descriptions/090-next_smallest.txt b/Bench/text-descriptions/090-next_smallest.txt new file mode 100644 index 0000000..d4ce844 --- /dev/null +++ b/Bench/text-descriptions/090-next_smallest.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `next_smallest`: You are given a list of integers. Write a function next_smallest() that returns the 2nd smallest element of the list. Return None if there is no such element. \ No newline at end of file diff --git a/Bench/text-descriptions/092-any_int.txt b/Bench/text-descriptions/092-any_int.txt new file mode 100644 index 0000000..3ab080b --- /dev/null +++ b/Bench/text-descriptions/092-any_int.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `any_int`: Create a function that takes 3 numbers. Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers. Returns false in any other cases. diff --git a/Bench/text-descriptions/093-encode.txt b/Bench/text-descriptions/093-encode.txt new file mode 100644 index 0000000..7562d3d --- /dev/null +++ b/Bench/text-descriptions/093-encode.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `encode`: Write a function that takes a message, and encodes in such a way that it swaps case of all letters, replaces all vowels in the message with the letter that appears 2 places ahead of that vowel in the english alphabet. Assume only letters. Examples: diff --git a/Bench/text-descriptions/094-skjkasdkd.txt b/Bench/text-descriptions/094-skjkasdkd.txt new file mode 100644 index 0000000..a064db6 --- /dev/null +++ b/Bench/text-descriptions/094-skjkasdkd.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `skjkasdkd`: You are given a list of integers. You need to find the largest prime value and return the sum of its digits. diff --git a/Bench/text-descriptions/095-check_dict_case.txt b/Bench/text-descriptions/095-check_dict_case.txt new file mode 100644 index 0000000..a4e28d0 --- /dev/null +++ b/Bench/text-descriptions/095-check_dict_case.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `check_dict_case`: Given a dictionary, return True if all keys are strings in lower case or all keys are strings in upper case, else return False. The function should return False is the given dictionary is empty. diff --git a/Bench/text-descriptions/096-count_up_to.txt b/Bench/text-descriptions/096-count_up_to.txt new file mode 100644 index 0000000..85403bc --- /dev/null +++ b/Bench/text-descriptions/096-count_up_to.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `count_up_to`: Implement a function that takes an non-negative integer and returns an array of the first n integers that are prime numbers and less than n. diff --git a/Bench/text-descriptions/097-multiply.txt b/Bench/text-descriptions/097-multiply.txt new file mode 100644 index 0000000..b92338b --- /dev/null +++ b/Bench/text-descriptions/097-multiply.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `multiply`: Complete the function that takes two integers and returns the product of their unit digits. Assume the input is always valid. diff --git a/Bench/text-descriptions/098-count_upper.txt b/Bench/text-descriptions/098-count_upper.txt new file mode 100644 index 0000000..1e1f345 --- /dev/null +++ b/Bench/text-descriptions/098-count_upper.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `count_upper`: Given a string s, count the number of uppercase vowels in even indices. diff --git a/Bench/text-descriptions/100-make_a_pile.txt b/Bench/text-descriptions/100-make_a_pile.txt new file mode 100644 index 0000000..5a1135f --- /dev/null +++ b/Bench/text-descriptions/100-make_a_pile.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `make_a_pile`: Given a positive integer n, you have to make a pile of n levels of stones. The first level has n stones. The number of stones in the next level is: - the next odd number if n is odd. - the next even number if n is even. Return the number of stones in each level in a list, where element at index i represents the number of stones in the level (i+1). Examples: diff --git a/Bench/text-descriptions/102-choose_num.txt b/Bench/text-descriptions/102-choose_num.txt new file mode 100644 index 0000000..5162a2f --- /dev/null +++ b/Bench/text-descriptions/102-choose_num.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `choose_num`: This function takes two positive numbers x and y and returns the biggest even integer number that is in the range [x, y] inclusive. If there's no such number, then the function should return -1. diff --git a/Bench/text-descriptions/104-unique_digits.txt b/Bench/text-descriptions/104-unique_digits.txt new file mode 100644 index 0000000..1bc5109 --- /dev/null +++ b/Bench/text-descriptions/104-unique_digits.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `unique_digits`: Given a list of positive integers x. return a sorted list of all elements that hasn't any even digit. Note: Returned list should be sorted in increasing order. For example: diff --git a/Bench/text-descriptions/105-by_length.txt b/Bench/text-descriptions/105-by_length.txt new file mode 100644 index 0000000..cb8e406 --- /dev/null +++ b/Bench/text-descriptions/105-by_length.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `by_length`: Given an array of integers, sort the integers that are between 1 and 9 inclusive, reverse the resulting array, and then replace each digit by its corresponding name from "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine". diff --git a/Bench/text-descriptions/106-f.txt b/Bench/text-descriptions/106-f.txt new file mode 100644 index 0000000..e1d424d --- /dev/null +++ b/Bench/text-descriptions/106-f.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `f`: Implement the function f that takes n as a parameter, and returns a list of size n, such that the value of the element at index i is the factorial of i if i is even or the sum of numbers from 1 to i otherwise. i starts from 1. the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i). diff --git a/Bench/text-descriptions/107-even_odd_palindrome.txt b/Bench/text-descriptions/107-even_odd_palindrome.txt new file mode 100644 index 0000000..da2deed --- /dev/null +++ b/Bench/text-descriptions/107-even_odd_palindrome.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `even_odd_palindrome`: Given a positive integer n, return a tuple that has the number of even and odd integer palindromes that fall within the range(1, n), inclusive. diff --git a/Bench/text-descriptions/108-count_nums.txt b/Bench/text-descriptions/108-count_nums.txt new file mode 100644 index 0000000..0d045b5 --- /dev/null +++ b/Bench/text-descriptions/108-count_nums.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `count_nums`: Write a function count_nums which takes an array of integers and returns the number of elements which has a sum of digits > 0. If a number is negative, then its first signed digit will be negative: e.g. -123 has signed digits -1, 2, and 3. diff --git a/Bench/text-descriptions/109-move_one_ball.txt b/Bench/text-descriptions/109-move_one_ball.txt new file mode 100644 index 0000000..dd4506e --- /dev/null +++ b/Bench/text-descriptions/109-move_one_ball.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `move_one_ball`: We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The numbers in the array will be randomly ordered. Your task is to determine if it is possible to get an array sorted in non-decreasing order by performing the following operation on the given array: You are allowed to perform right shift operation any number of times. One right shift operation means shifting all elements of the array by one position in the right direction. The last element of the array will be moved to the starting position in the array i.e. 0th index. If it is possible to obtain the sorted array by performing the above operation then return True else return False. If the given array is empty then return True. Note: The given list is guaranteed to have unique elements. For diff --git a/Bench/text-descriptions/110-exchange.txt b/Bench/text-descriptions/110-exchange.txt new file mode 100644 index 0000000..1f0b897 --- /dev/null +++ b/Bench/text-descriptions/110-exchange.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `exchange`: In this problem, you will implement a function that takes two lists of numbers, and determines whether it is possible to perform an exchange of elements between them to make lst1 a list of only even numbers. There is no limit on the number of exchanged elements between lst1 and lst2. If it is possible to exchange elements between the lst1 and lst2 to make all the elements of lst1 to be even, return "YES". Otherwise, return "NO". diff --git a/Bench/text-descriptions/111-histogram.txt b/Bench/text-descriptions/111-histogram.txt new file mode 100644 index 0000000..bc0cda2 --- /dev/null +++ b/Bench/text-descriptions/111-histogram.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `histogram`: Given a string representing a space separated lowercase letters, return a dictionary of the letter with the most repetition and containing the corresponding count. If several letters have the same occurrence, return all of them. diff --git a/Bench/text-descriptions/112-reverse_delete.txt b/Bench/text-descriptions/112-reverse_delete.txt new file mode 100644 index 0000000..d91013b --- /dev/null +++ b/Bench/text-descriptions/112-reverse_delete.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `reverse_delete`: Task We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c then check if the result string is palindrome. A string is called palindrome if it reads the same backward as forward. You should return a tuple containing the result string and True/False for the check. diff --git a/Bench/text-descriptions/114-minSubArraySum.txt b/Bench/text-descriptions/114-minSubArraySum.txt new file mode 100644 index 0000000..6990ed1 --- /dev/null +++ b/Bench/text-descriptions/114-minSubArraySum.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `minSubArraySum`: Given an array of integers nums, find the minimum sum of any non-empty sub-array of nums. diff --git a/Bench/text-descriptions/115-max_fill.txt b/Bench/text-descriptions/115-max_fill.txt new file mode 100644 index 0000000..41c004d --- /dev/null +++ b/Bench/text-descriptions/115-max_fill.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `max_fill`: You are given a rectangular grid of wells. Each row represents a single well, and each 1 in a row represents a single unit of water. Each well has a corresponding bucket that can be used to extract water from it, and all buckets have the same capacity. Your task is to use the buckets to empty the wells. Output the number of times you need to lower the buckets. diff --git a/Bench/text-descriptions/116-sort_array.txt b/Bench/text-descriptions/116-sort_array.txt new file mode 100644 index 0000000..858586a --- /dev/null +++ b/Bench/text-descriptions/116-sort_array.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sort_array`: In this Kata, you have to sort an array of non-negative integers according to number of ones in their binary representation in ascending order. For similar number of ones, sort based on decimal value. It must be implemented like this: diff --git a/Bench/text-descriptions/118-get_closest_vowel.txt b/Bench/text-descriptions/118-get_closest_vowel.txt new file mode 100644 index 0000000..81e61dc --- /dev/null +++ b/Bench/text-descriptions/118-get_closest_vowel.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `get_closest_vowel`: You are given a word. Your task is to find the closest vowel that stands between two consonants from the right side of the word (case sensitive). Vowels in the beginning and ending doesn't count. Return empty string if you didn't find any vowel met the above condition. You may assume that the given string contains English letter only. diff --git a/Bench/text-descriptions/119-match_parens.txt b/Bench/text-descriptions/119-match_parens.txt new file mode 100644 index 0000000..c503348 --- /dev/null +++ b/Bench/text-descriptions/119-match_parens.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `match_parens`: You are given a list of two strings, both strings consist of open parentheses '(' or close parentheses ')' only. Your job is to check if it is possible to concatenate the two strings in some order, that the resulting string will be good. A string S is considered to be good if and only if all parentheses in S are balanced. For example: the string '(())()' is good, while the string '())' is not. Return 'Yes' if there's a way to make a good string, and return 'No' otherwise. diff --git a/Bench/text-descriptions/120-maximum.txt b/Bench/text-descriptions/120-maximum.txt new file mode 100644 index 0000000..d287201 --- /dev/null +++ b/Bench/text-descriptions/120-maximum.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `maximum`: Given an array arr of integers and a positive integer k, return a sorted list of length k with the maximum k numbers in arr. diff --git a/Bench/text-descriptions/121-solution.txt b/Bench/text-descriptions/121-solution.txt new file mode 100644 index 0000000..b3da611 --- /dev/null +++ b/Bench/text-descriptions/121-solution.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `solution`: Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions. diff --git a/Bench/text-descriptions/122-add_elements.txt b/Bench/text-descriptions/122-add_elements.txt new file mode 100644 index 0000000..b41b6b6 --- /dev/null +++ b/Bench/text-descriptions/122-add_elements.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `add_elements`: Given a non-empty array of integers arr and an integer k, return the sum of the elements with at most two digits from the first k elements of arr. diff --git a/Bench/text-descriptions/123-get_odd_collatz.txt b/Bench/text-descriptions/123-get_odd_collatz.txt new file mode 100644 index 0000000..f720171 --- /dev/null +++ b/Bench/text-descriptions/123-get_odd_collatz.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `get_odd_collatz`: Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence. The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows: start with any positive integer n. Then each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1. Note: 1. Collatz(1) is [1]. 2. returned list sorted in increasing order. diff --git a/Bench/text-descriptions/126-is_sorted.txt b/Bench/text-descriptions/126-is_sorted.txt new file mode 100644 index 0000000..5e8c31b --- /dev/null +++ b/Bench/text-descriptions/126-is_sorted.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_sorted`: Given a list of numbers, return whether or not they are sorted in ascending order. If list has more than 1 duplicate of the same number, return False. Assume no negative numbers and only integers. diff --git a/Bench/text-descriptions/127-intersection.txt b/Bench/text-descriptions/127-intersection.txt new file mode 100644 index 0000000..a95a83a --- /dev/null +++ b/Bench/text-descriptions/127-intersection.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `intersection`: You are given two intervals, where each interval is a pair of integers. diff --git a/Bench/text-descriptions/128-prod_signs.txt b/Bench/text-descriptions/128-prod_signs.txt new file mode 100644 index 0000000..2c19341 --- /dev/null +++ b/Bench/text-descriptions/128-prod_signs.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `prod_signs`: You are given an array arr of integers and you need to return sum of magnitudes of integers multiplied by product of all signs of each number in the array, represented by 1, -1 or 0. Note: return None for empty arr. Example: diff --git a/Bench/text-descriptions/130-tri.txt b/Bench/text-descriptions/130-tri.txt new file mode 100644 index 0000000..5bca523 --- /dev/null +++ b/Bench/text-descriptions/130-tri.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `tri`: Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in the last couple centuries. However, what people don't know is Tribonacci sequence. Tribonacci sequence is defined by the recurrence: tri(1) = 3 tri(n) = 1 + n / 2, if n is even. tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd. For example: tri(2) = 1 + (2 / 2) = 2 tri(4) = 3 tri(3) = tri(2) + tri(1) + tri(4) = 2 + 3 + 3 = 8 You are given a non-negative integer number n, you have to a return a list of the first n + 1 numbers of the Tribonacci sequence. diff --git a/Bench/text-descriptions/132-is_nested.txt b/Bench/text-descriptions/132-is_nested.txt new file mode 100644 index 0000000..d5b2a1f --- /dev/null +++ b/Bench/text-descriptions/132-is_nested.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_nested`: Create a function that takes a string as input which contains only square brackets. The function should return True if and only if there is a valid subsequence of brackets where at least one bracket in the subsequence is nested. \ No newline at end of file diff --git a/Bench/text-descriptions/133-sum-squares.txt b/Bench/text-descriptions/133-sum-squares.txt new file mode 100644 index 0000000..84be9e7 --- /dev/null +++ b/Bench/text-descriptions/133-sum-squares.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sum_squares`: You are given a list of numbers. You need to return the sum of squared numbers in the given list, round each element in the list to the upper int(Ceiling) first. diff --git a/Bench/text-descriptions/134-check_if_last_char_is_a_letter.txt b/Bench/text-descriptions/134-check_if_last_char_is_a_letter.txt new file mode 100644 index 0000000..d41e796 --- /dev/null +++ b/Bench/text-descriptions/134-check_if_last_char_is_a_letter.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `check_if_last_char_is_a_letter`: Create a function that returns True if the last character of a given string is an alphabetical character and is not a part of a word, and False otherwise. Note: "word" is a group of characters separated by space. diff --git a/Bench/text-descriptions/135_can_arrange.txt b/Bench/text-descriptions/135_can_arrange.txt new file mode 100644 index 0000000..acb7a09 --- /dev/null +++ b/Bench/text-descriptions/135_can_arrange.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `can_arrange`: Create a function which returns the largest index of an element which is not greater than or equal to the element immediately preceding it. If no such element exists then return -1. The given array will not contain duplicate values. diff --git a/Bench/text-descriptions/136-largest_smallest_integers.txt b/Bench/text-descriptions/136-largest_smallest_integers.txt new file mode 100644 index 0000000..2eed20c --- /dev/null +++ b/Bench/text-descriptions/136-largest_smallest_integers.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `largest_smallest_integers`: Create a function that returns a tuple (a, b), where 'a' is the largest of negative integers, and 'b' is the smallest of positive integers in a list. If there is no negative or positive integers, return them as None. diff --git a/Bench/text-descriptions/138_is_equal_to_sum_even.txt b/Bench/text-descriptions/138_is_equal_to_sum_even.txt new file mode 100644 index 0000000..ddc1437 --- /dev/null +++ b/Bench/text-descriptions/138_is_equal_to_sum_even.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `is_equal_to_sum_even`: Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers diff --git a/Bench/text-descriptions/139-special_factorial.txt b/Bench/text-descriptions/139-special_factorial.txt new file mode 100644 index 0000000..ceae244 --- /dev/null +++ b/Bench/text-descriptions/139-special_factorial.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `special_factorial`: The Brazilian factorial is defined as: brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1! where n > 0 For example: diff --git a/Bench/text-descriptions/142-sum_squares.txt b/Bench/text-descriptions/142-sum_squares.txt new file mode 100644 index 0000000..f48c866 --- /dev/null +++ b/Bench/text-descriptions/142-sum_squares.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sum_squares`: " This function will take a list of integers. For all entries in the list, the function shall square the integer entry if its index is a multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not change the entries in the list whose indexes are not a multiple of 3 or 4. The function shall then return the sum of all entries. diff --git a/Bench/text-descriptions/145-order_by_points.txt b/Bench/text-descriptions/145-order_by_points.txt new file mode 100644 index 0000000..527d511 --- /dev/null +++ b/Bench/text-descriptions/145-order_by_points.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `order_by_points`: Write a function which sorts the given list of integers in ascending order according to the sum of their digits. Note: if there are several items with similar sum of their digits, order them based on their index in original list. For example: diff --git a/Bench/text-descriptions/146_specialFilter.txt b/Bench/text-descriptions/146_specialFilter.txt new file mode 100644 index 0000000..7ba1191 --- /dev/null +++ b/Bench/text-descriptions/146_specialFilter.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `specialFilter`: Write a function that takes an array of numbers as input and returns the number of elements in the array that are greater than 10 and both first and last digits of a number are odd (1, 3, 5, 7, 9). diff --git a/Bench/text-descriptions/148-bf.txt b/Bench/text-descriptions/148-bf.txt new file mode 100644 index 0000000..20538cf --- /dev/null +++ b/Bench/text-descriptions/148-bf.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `bf`: There are eight planets in our solar system: the closerst to the Sun is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn, Uranus, Neptune. Write a function that takes two planet names as strings planet1 and planet2. The function should return a tuple containing all planets whose orbits are located between the orbit of planet1 and the orbit of planet2, sorted by the proximity to the sun. The function should return an empty tuple if planet1 or planet2 are not correct planet names. diff --git a/Bench/text-descriptions/149-sorted_list_sum.txt b/Bench/text-descriptions/149-sorted_list_sum.txt new file mode 100644 index 0000000..ceec453 --- /dev/null +++ b/Bench/text-descriptions/149-sorted_list_sum.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `sorted_list_sum`: Write a function that accepts a list of strings as a parameter, deletes the strings that have odd lengths from it, and returns the resulted list with a sorted order, The list is always a list of strings and never an array of numbers, and it may contain duplicates. The order of the list should be ascending by length of each word, and you should return the list sorted by that rule. If two words have the same length, sort the list alphabetically. The function should return a list of strings in sorted order. You may assume that all words will have the same length. diff --git a/Bench/text-descriptions/150-x_or_y.txt b/Bench/text-descriptions/150-x_or_y.txt new file mode 100644 index 0000000..8728259 --- /dev/null +++ b/Bench/text-descriptions/150-x_or_y.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `x_or_y`: A simple program which should return the value of x if n is a prime number and should return the value of y otherwise. diff --git a/Bench/text-descriptions/151-double_the_difference.txt b/Bench/text-descriptions/151-double_the_difference.txt new file mode 100644 index 0000000..bd45c41 --- /dev/null +++ b/Bench/text-descriptions/151-double_the_difference.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `double_the_difference`: Given a list of numbers, return the sum of squares of the numbers in the list that are odd. Ignore numbers that are negative or not integers. diff --git a/Bench/text-descriptions/152-compare.txt b/Bench/text-descriptions/152-compare.txt new file mode 100644 index 0000000..935041b --- /dev/null +++ b/Bench/text-descriptions/152-compare.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `compare`: I think we all remember that feeling when the result of some long-awaited event is finally known. The feelings and thoughts you have at that moment are definitely worth noting down and comparing. Your task is to determine if a person correctly guessed the results of a number of matches. You are given two arrays of scores and guesses of equal length, where each index shows a match. Return an array of the same length denoting how far off each guess was. If they have guessed correctly, the value is 0, and if not, the value is the absolute difference between the guess and the score. diff --git a/Bench/text-descriptions/153-Strongest_Extension.txt b/Bench/text-descriptions/153-Strongest_Extension.txt new file mode 100644 index 0000000..357d247 --- /dev/null +++ b/Bench/text-descriptions/153-Strongest_Extension.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `Strongest_Extension`: You will be given the name of a class (a string) and a list of extensions. The extensions are to be used to load additional classes to the class. The strength of the extension is as follows: Let CAP be the number of the uppercase letters in the extension's name, and let SM be the number of lowercase letters in the extension's name, the strength is given by the fraction CAP - SM. You should find the strongest extension and return a string in this format: ClassName.StrongestExtensionName. If there are two or more extensions with the same strength, you should choose the one that comes first in the list. diff --git a/Bench/text-descriptions/154-cycpattern_check.txt b/Bench/text-descriptions/154-cycpattern_check.txt new file mode 100644 index 0000000..28b2811 --- /dev/null +++ b/Bench/text-descriptions/154-cycpattern_check.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `cycpattern_check`: You are given 2 words. You need to return True if the second word or any of its rotations is a substring in the first word diff --git a/Bench/text-descriptions/155_even_odd_count.txt b/Bench/text-descriptions/155_even_odd_count.txt new file mode 100644 index 0000000..0cfe786 --- /dev/null +++ b/Bench/text-descriptions/155_even_odd_count.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `even_odd_count`: Given an integer. return a tuple that has the number of even and odd digits respectively. diff --git a/Bench/text-descriptions/157-right_angle_triangle.txt b/Bench/text-descriptions/157-right_angle_triangle.txt new file mode 100644 index 0000000..94fbe6e --- /dev/null +++ b/Bench/text-descriptions/157-right_angle_triangle.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `right_angle_triangle`: Given the lengths of the three sides of a triangle. Return True if the three sides form a right-angled triangle, False otherwise. A right-angled triangle is a triangle in which one angle is right angle or 90 degree. diff --git a/Bench/text-descriptions/158-find_max.txt b/Bench/text-descriptions/158-find_max.txt new file mode 100644 index 0000000..84eb0b9 --- /dev/null +++ b/Bench/text-descriptions/158-find_max.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `find_max`: Write a function that accepts a list of strings. The list contains different words. Return the word with maximum number of unique characters. If multiple strings have maximum number of unique characters, return the one which comes first in lexicographical order. diff --git a/Bench/text-descriptions/159-eat.txt b/Bench/text-descriptions/159-eat.txt new file mode 100644 index 0000000..1151b39 --- /dev/null +++ b/Bench/text-descriptions/159-eat.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `eat`: You're a hungry rabbit, and you already have eaten a certain number of carrots, but now you need to eat more carrots to complete the day's meals. you should return an array of [ total number of eaten carrots after your meals, the number of carrots left after your meals ] if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry. diff --git a/Bench/text-descriptions/161-solve.txt b/Bench/text-descriptions/161-solve.txt new file mode 100644 index 0000000..7f17c44 --- /dev/null +++ b/Bench/text-descriptions/161-solve.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `solve`: You are given a string s. if s[i] is a letter, reverse its case from lower to upper or vise versa, otherwise keep it as it is. If the string contains no letters, reverse the string. The function should return the resulted string. diff --git a/Bench/text-descriptions/163-generate_integers.txt b/Bench/text-descriptions/163-generate_integers.txt new file mode 100644 index 0000000..5658bda --- /dev/null +++ b/Bench/text-descriptions/163-generate_integers.txt @@ -0,0 +1,3 @@ +You have to write 1 function in nagini (python verification framework), using the given helper functions +The description is as follows: +function `generate_integers`: Given two positive integers a and b, return the even digits between a and b, in ascending order.