-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add text descriptions of the tasks (#54)
- Loading branch information
Showing
132 changed files
with
475 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
{ | ||
"tab_size": 2, | ||
"languages": { | ||
"Dafny": { | ||
"tab_size": 2, | ||
} | ||
}, | ||
"format_on_save": "off" | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from pathlib import Path | ||
import re | ||
|
||
DESCRIPTION_TEMPLATE = """\ | ||
You have to write {cnt} {functions} in dafny, using the given helper functions | ||
The {descriptions} as follows: | ||
""" | ||
|
||
SUBTASK_TEMPLATE = """\ | ||
function `{name}`: {task} | ||
""" | ||
|
||
NO_EXAMPLES = { | ||
"010": ["is_palindrome"], | ||
"041": ["car_race_collision"], | ||
"050": ["encode_shift", "decode_shift"], | ||
"083": ["starts_one_ends"], | ||
} | ||
|
||
POSSIBLE_ENDS = [ | ||
">>>", | ||
"Examples", | ||
"for example", | ||
"For example", | ||
"Example", | ||
"example", | ||
# "\"\"\"" | ||
] | ||
|
||
|
||
def description_from_match(number: str, name: str, task: str) -> str: | ||
if number in NO_EXAMPLES and name in NO_EXAMPLES[number]: | ||
end = len(task) | ||
else: | ||
end, pos = -1, 0 | ||
POSSIBLE_ENDS.append(name) | ||
while end == -1: | ||
end = task.find(POSSIBLE_ENDS[pos]) | ||
pos += 1 | ||
POSSIBLE_ENDS.pop() | ||
task = task[:end].replace(" ", "").replace("\n", " ").strip() | ||
while " " in task: | ||
task = task.replace(" ", " ") | ||
return SUBTASK_TEMPLATE.format(name=name, task=task) | ||
|
||
|
||
assert ( | ||
Path(".").absolute().stem == "HumanEval-Dafny" | ||
), "script should be run from HumanEval-Dafny directory" | ||
|
||
human_eval = Path(".").absolute().parent / "verified-cogen" / "benches" / "HumanEval" | ||
text_descriptions = Path() / "text-descriptions" | ||
text_descriptions.mkdir(exist_ok=True) | ||
|
||
desc_regex = re.compile(r"def ([a-zA-Z0-9_]*)\(.*\)(:?\s*->\s*.*)?:\n") | ||
|
||
files = sorted(Path(".").glob("*.dfy")) | ||
for i, file in enumerate(files): | ||
number = file.stem[:3] | ||
name = file.stem[4:].replace("-", "_") | ||
|
||
prompt_path = human_eval / f"{number}_{name}/{name}.prompt" | ||
print(f"Done {i + 1}/{len(files)} ({prompt_path.name})") | ||
prompt = prompt_path.read_text() | ||
|
||
matches = list(desc_regex.finditer(prompt)) | ||
desc = DESCRIPTION_TEMPLATE.format( | ||
cnt=len(matches), | ||
functions="function" if len(matches) == 1 else "functions", | ||
descriptions="description is" if len(matches) == 1 else "descriptions are", | ||
) | ||
for match in matches: | ||
desc_start = prompt.find('"""', match.end()) | ||
if desc_start == -1: | ||
desc_start = prompt.find("'''", match.end()) | ||
desc_end = prompt.find("'''", desc_start + 3) | ||
else: | ||
desc_end = prompt.find('"""', desc_start + 3) | ||
desc += description_from_match( | ||
number, match.groups()[0], prompt[desc_start + 3 : desc_end] | ||
) # type: ignore | ||
|
||
with (text_descriptions / f"{file.stem}.txt").open("w") as out: | ||
out.write(desc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
You have to write 2 functions in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `strlen`: Return length of given string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `get_positive`: Return only positive numbers in the list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `is_prime`: Return true if a given number is prime, and false otherwise. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `unique`: Return sorted unique elements in a list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `max_element`: Return maximum element in the list. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `incr_list`: Return list with elements incremented by 1. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `is_palindrome`: Checks if given string is a palindrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `is_palindrome`: Checks if given string is a palindrome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `modp`: Return 2^n modulo p (be aware of numerics). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
You have to write 2 functions in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `add`: Add two numbers x and y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `same_chars`: Check if two words have the same characters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `fib`: Return n-th Fibonacci number. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `monotonic`: Return True is list elements are monotonically increasing or decreasing. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, using the given helper functions | ||
The description is as follows: | ||
function `common`: Return sorted unique common elements for two lists. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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 []. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
You have to write 1 function in dafny, 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. |
Oops, something went wrong.