zhihengchen commited on
Commit
07ad488
·
verified ·
1 Parent(s): 6e57841

Upload 68 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. data/.DS_Store +0 -0
  2. data/coding/.DS_Store +0 -0
  3. data/coding/humaneval/.DS_Store +0 -0
  4. data/coding/humaneval/csv/1.csv +2413 -0
  5. data/coding/humaneval/csv/2.csv +2413 -0
  6. data/coding/humaneval/csv/3.csv +2413 -0
  7. data/coding/humaneval/csv/4.csv +2413 -0
  8. data/coding/humaneval/csv/5.csv +2413 -0
  9. data/coding/humaneval/json/1.json +500 -0
  10. data/coding/humaneval/json/2.json +500 -0
  11. data/coding/humaneval/json/3.json +500 -0
  12. data/coding/humaneval/json/4.json +500 -0
  13. data/coding/humaneval/json/5.json +500 -0
  14. data/coding/humaneval/weight/1.zip +3 -0
  15. data/coding/humaneval/weight/2.zip +3 -0
  16. data/coding/humaneval/weight/3.zip +3 -0
  17. data/coding/humaneval/weight/4.zip +3 -0
  18. data/coding/humaneval/weight/5.zip +3 -0
  19. data/common/.DS_Store +0 -0
  20. data/common/arc_c/.DS_Store +0 -0
  21. data/common/arc_c/csv/1.csv +0 -0
  22. data/common/arc_c/csv/2.csv +0 -0
  23. data/common/arc_c/csv/3.csv +0 -0
  24. data/common/arc_c/csv/4.csv +0 -0
  25. data/common/arc_c/csv/5.csv +0 -0
  26. data/common/arc_c/json/1.jsonl +0 -0
  27. data/common/arc_c/json/2.jsonl +0 -0
  28. data/common/arc_c/json/3.jsonl +0 -0
  29. data/common/arc_c/json/4.jsonl +0 -0
  30. data/common/arc_c/json/5.jsonl +0 -0
  31. data/common/arc_c/weight/1.zip +3 -0
  32. data/common/arc_c/weight/2.zip +3 -0
  33. data/common/arc_c/weight/3.zip +3 -0
  34. data/common/arc_c/weight/4.zip +3 -0
  35. data/common/arc_c/weight/5.zip +3 -0
  36. data/common/obqa/.DS_Store +0 -0
  37. data/common/obqa/csv/1.csv +0 -0
  38. data/common/obqa/csv/2.csv +0 -0
  39. data/common/obqa/csv/3.csv +0 -0
  40. data/common/obqa/csv/4.csv +0 -0
  41. data/common/obqa/csv/5.csv +0 -0
  42. data/common/obqa/json/1.jsonl +0 -0
  43. data/common/obqa/json/2.jsonl +0 -0
  44. data/common/obqa/json/3.jsonl +0 -0
  45. data/common/obqa/json/4.jsonl +0 -0
  46. data/common/obqa/json/5.jsonl +0 -0
  47. data/common/obqa/weight/1.zip +3 -0
  48. data/common/obqa/weight/2.zip +3 -0
  49. data/common/obqa/weight/3.zip +3 -0
  50. data/common/obqa/weight/4.zip +3 -0
data/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/coding/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/coding/humaneval/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/coding/humaneval/csv/1.csv ADDED
@@ -0,0 +1,2413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt,pass@1,pass@5,pass@10
2
+ "from typing import List
3
+
4
+
5
+ def has_close_elements(numbers: List[float], threshold: float) -> bool:
6
+ """""" Check if in given list of numbers, are any two numbers closer to each other than
7
+ given threshold.
8
+ >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
9
+ False
10
+ >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
11
+ True
12
+ """"""
13
+ ",0.5499999999999998,0.9918730650154799,1.0
14
+ "from typing import List
15
+
16
+
17
+ def separate_paren_groups(paren_string: str) -> List[str]:
18
+ """""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
19
+ separate those group into separate strings and return the list of those.
20
+ Separate groups are balanced (each open brace is properly closed) and not nested within each other
21
+ Ignore any spaces in the input string.
22
+ >>> separate_paren_groups('( ) (( )) (( )( ))')
23
+ ['()', '(())', '(()())']
24
+ """"""
25
+ ",0.0,0.0,0.0
26
+ "
27
+
28
+ def truncate_number(number: float) -> float:
29
+ """""" Given a positive floating point number, it can be decomposed into
30
+ and integer part (largest integer smaller than given number) and decimals
31
+ (leftover part always smaller than 1).
32
+
33
+ Return the decimal part of the number.
34
+ >>> truncate_number(3.5)
35
+ 0.5
36
+ """"""
37
+ ",0.4,0.9489164086687306,0.9996427720885925
38
+ "from typing import List
39
+
40
+
41
+ def below_zero(operations: List[int]) -> bool:
42
+ """""" You're given a list of deposit and withdrawal operations on a bank account that starts with
43
+ zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
44
+ at that point function should return True. Otherwise it should return False.
45
+ >>> below_zero([1, 2, 3])
46
+ False
47
+ >>> below_zero([1, 2, -4, 5])
48
+ True
49
+ """"""
50
+ ",1.0,1.0,1.0
51
+ "from typing import List
52
+
53
+
54
+ def mean_absolute_deviation(numbers: List[float]) -> float:
55
+ """""" For a given list of input numbers, calculate Mean Absolute Deviation
56
+ around the mean of this dataset.
57
+ Mean Absolute Deviation is the average absolute difference between each
58
+ element and a centerpoint (mean in this case):
59
+ MAD = average | x - x_mean |
60
+ >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
61
+ 1.0
62
+ """"""
63
+ ",1.0,1.0,1.0
64
+ "from typing import List
65
+
66
+
67
+ def intersperse(numbers: List[int], delimeter: int) -> List[int]:
68
+ """""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
69
+ >>> intersperse([], 4)
70
+ []
71
+ >>> intersperse([1, 2, 3], 4)
72
+ [1, 4, 2, 4, 3]
73
+ """"""
74
+ ",0.0,0.0,0.0
75
+ "from typing import List
76
+
77
+
78
+ def parse_nested_parens(paren_string: str) -> List[int]:
79
+ """""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
80
+ For each of the group, output the deepest level of nesting of parentheses.
81
+ E.g. (()()) has maximum two levels of nesting while ((())) has three.
82
+
83
+ >>> parse_nested_parens('(()()) ((())) () ((())()())')
84
+ [2, 3, 1, 3]
85
+ """"""
86
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
87
+ "from typing import List
88
+
89
+
90
+ def filter_by_substring(strings: List[str], substring: str) -> List[str]:
91
+ """""" Filter an input list of strings only for ones that contain given substring
92
+ >>> filter_by_substring([], 'a')
93
+ []
94
+ >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
95
+ ['abc', 'bacd', 'array']
96
+ """"""
97
+ ",0.8999999999999999,1.0,1.0
98
+ "from typing import List, Tuple
99
+
100
+
101
+ def sum_product(numbers: List[int]) -> Tuple[int, int]:
102
+ """""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
103
+ Empty sum should be equal to 0 and empty product should be equal to 1.
104
+ >>> sum_product([])
105
+ (0, 1)
106
+ >>> sum_product([1, 2, 3, 4])
107
+ (10, 24)
108
+ """"""
109
+ ",1.0,1.0,1.0
110
+ "from typing import List, Tuple
111
+
112
+
113
+ def rolling_max(numbers: List[int]) -> List[int]:
114
+ """""" From a given list of integers, generate a list of rolling maximum element found until given moment
115
+ in the sequence.
116
+ >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
117
+ [1, 2, 3, 3, 3, 4, 4]
118
+ """"""
119
+ ",0.4,0.9489164086687306,0.9996427720885925
120
+ "
121
+
122
+ def is_palindrome(string: str) -> bool:
123
+ """""" Test if given string is a palindrome """"""
124
+ return string == string[::-1]
125
+
126
+
127
+ def make_palindrome(string: str) -> str:
128
+ """""" Find the shortest palindrome that begins with a supplied string.
129
+ Algorithm idea is simple:
130
+ - Find the longest postfix of supplied string that is a palindrome.
131
+ - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
132
+ >>> make_palindrome('')
133
+ ''
134
+ >>> make_palindrome('cat')
135
+ 'catac'
136
+ >>> make_palindrome('cata')
137
+ 'catac'
138
+ """"""
139
+ ",0.0,0.0,0.0
140
+ "from typing import List
141
+
142
+
143
+ def string_xor(a: str, b: str) -> str:
144
+ """""" Input are two strings a and b consisting only of 1s and 0s.
145
+ Perform binary XOR on these inputs and return result also as a string.
146
+ >>> string_xor('010', '110')
147
+ '100'
148
+ """"""
149
+ ",0.6000000000000001,0.9963880288957688,1.0
150
+ "from typing import List, Optional
151
+
152
+
153
+ def longest(strings: List[str]) -> Optional[str]:
154
+ """""" Out of list of strings, return the longest one. Return the first one in case of multiple
155
+ strings of the same length. Return None in case the input list is empty.
156
+ >>> longest([])
157
+
158
+ >>> longest(['a', 'b', 'c'])
159
+ 'a'
160
+ >>> longest(['a', 'bb', 'ccc'])
161
+ 'ccc'
162
+ """"""
163
+ ",1.0,1.0,1.0
164
+ "
165
+
166
+ def greatest_common_divisor(a: int, b: int) -> int:
167
+ """""" Return a greatest common divisor of two integers a and b
168
+ >>> greatest_common_divisor(3, 5)
169
+ 1
170
+ >>> greatest_common_divisor(25, 15)
171
+ 5
172
+ """"""
173
+ ",0.6000000000000001,0.9963880288957688,1.0
174
+ "from typing import List
175
+
176
+
177
+ def all_prefixes(string: str) -> List[str]:
178
+ """""" Return list of all prefixes from shortest to longest of the input string
179
+ >>> all_prefixes('abc')
180
+ ['a', 'ab', 'abc']
181
+ """"""
182
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
183
+ "
184
+
185
+ def string_sequence(n: int) -> str:
186
+ """""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
187
+ >>> string_sequence(0)
188
+ '0'
189
+ >>> string_sequence(5)
190
+ '0 1 2 3 4 5'
191
+ """"""
192
+ ",0.7,0.9996130030959752,1.0
193
+ "
194
+
195
+ def count_distinct_characters(string: str) -> int:
196
+ """""" Given a string, find out how many distinct characters (regardless of case) does it consist of
197
+ >>> count_distinct_characters('xyzXYZ')
198
+ 3
199
+ >>> count_distinct_characters('Jerry')
200
+ 4
201
+ """"""
202
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
203
+ "from typing import List
204
+
205
+
206
+ def parse_music(music_string: str) -> List[int]:
207
+ """""" Input to this function is a string representing musical notes in a special ASCII format.
208
+ Your task is to parse this string and return list of integers corresponding to how many beats does each
209
+ not last.
210
+
211
+ Here is a legend:
212
+ 'o' - whole note, lasts four beats
213
+ 'o|' - half note, lasts two beats
214
+ '.|' - quater note, lasts one beat
215
+
216
+ >>> parse_music('o o| .| o| o| .| .| .| .| o o')
217
+ [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
218
+ """"""
219
+ ",0.6000000000000001,0.9963880288957688,1.0
220
+ "
221
+
222
+ def how_many_times(string: str, substring: str) -> int:
223
+ """""" Find how many times a given substring can be found in the original string. Count overlaping cases.
224
+ >>> how_many_times('', 'a')
225
+ 0
226
+ >>> how_many_times('aaa', 'a')
227
+ 3
228
+ >>> how_many_times('aaaa', 'aa')
229
+ 3
230
+ """"""
231
+ ",0.7999999999999999,1.0,1.0
232
+ "from typing import List
233
+
234
+
235
+ def sort_numbers(numbers: str) -> str:
236
+ """""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
237
+ Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
238
+ Return the string with numbers sorted from smallest to largest
239
+ >>> sort_numbers('three one five')
240
+ 'one three five'
241
+ """"""
242
+ ",0.0,0.0,0.0
243
+ "from typing import List, Tuple
244
+
245
+
246
+ def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
247
+ """""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
248
+ other and return them in order (smaller number, larger number).
249
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
250
+ (2.0, 2.2)
251
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
252
+ (2.0, 2.0)
253
+ """"""
254
+ ",0.5499999999999998,0.9918730650154799,1.0
255
+ "from typing import List
256
+
257
+
258
+ def rescale_to_unit(numbers: List[float]) -> List[float]:
259
+ """""" Given list of numbers (of at least two elements), apply a linear transform to that list,
260
+ such that the smallest number will become 0 and the largest will become 1
261
+ >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
262
+ [0.0, 0.25, 0.5, 0.75, 1.0]
263
+ """"""
264
+ ",0.75,0.9999355005159959,1.0
265
+ "from typing import List, Any
266
+
267
+
268
+ def filter_integers(values: List[Any]) -> List[int]:
269
+ """""" Filter given list of any python values only for integers
270
+ >>> filter_integers(['a', 3.14, 5])
271
+ [5]
272
+ >>> filter_integers([1, 2, 3, 'abc', {}, []])
273
+ [1, 2, 3]
274
+ """"""
275
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
276
+ "
277
+
278
+ def strlen(string: str) -> int:
279
+ """""" Return length of given string
280
+ >>> strlen('')
281
+ 0
282
+ >>> strlen('abc')
283
+ 3
284
+ """"""
285
+ ",0.8999999999999999,1.0,1.0
286
+ "
287
+
288
+ def largest_divisor(n: int) -> int:
289
+ """""" For a given number n, find the largest number that divides n evenly, smaller than n
290
+ >>> largest_divisor(15)
291
+ 5
292
+ """"""
293
+ ",0.0,0.0,0.0
294
+ "from typing import List
295
+
296
+
297
+ def factorize(n: int) -> List[int]:
298
+ """""" Return list of prime factors of given integer in the order from smallest to largest.
299
+ Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
300
+ Input number should be equal to the product of all factors
301
+ >>> factorize(8)
302
+ [2, 2, 2]
303
+ >>> factorize(25)
304
+ [5, 5]
305
+ >>> factorize(70)
306
+ [2, 5, 7]
307
+ """"""
308
+ ",1.0,1.0,1.0
309
+ "from typing import List
310
+
311
+
312
+ def remove_duplicates(numbers: List[int]) -> List[int]:
313
+ """""" From a list of integers, remove all elements that occur more than once.
314
+ Keep order of elements left the same as in the input.
315
+ >>> remove_duplicates([1, 2, 3, 2, 4])
316
+ [1, 3, 4]
317
+ """"""
318
+ ",0.050000000000000044,0.25,0.5
319
+ "
320
+
321
+ def flip_case(string: str) -> str:
322
+ """""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
323
+ >>> flip_case('Hello')
324
+ 'hELLO'
325
+ """"""
326
+ ",0.7999999999999999,1.0,1.0
327
+ "from typing import List
328
+
329
+
330
+ def concatenate(strings: List[str]) -> str:
331
+ """""" Concatenate list of strings into a single string
332
+ >>> concatenate([])
333
+ ''
334
+ >>> concatenate(['a', 'b', 'c'])
335
+ 'abc'
336
+ """"""
337
+ ",0.95,1.0,1.0
338
+ "from typing import List
339
+
340
+
341
+ def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
342
+ """""" Filter an input list of strings only for ones that start with a given prefix.
343
+ >>> filter_by_prefix([], 'a')
344
+ []
345
+ >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
346
+ ['abc', 'array']
347
+ """"""
348
+ ",0.8999999999999999,1.0,1.0
349
+ "
350
+
351
+ def get_positive(l: list):
352
+ """"""Return only positive numbers in the list.
353
+ >>> get_positive([-1, 2, -4, 5, 6])
354
+ [2, 5, 6]
355
+ >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
356
+ [5, 3, 2, 3, 9, 123, 1]
357
+ """"""
358
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
359
+ "
360
+
361
+ def is_prime(n):
362
+ """"""Return true if a given number is prime, and false otherwise.
363
+ >>> is_prime(6)
364
+ False
365
+ >>> is_prime(101)
366
+ True
367
+ >>> is_prime(11)
368
+ True
369
+ >>> is_prime(13441)
370
+ True
371
+ >>> is_prime(61)
372
+ True
373
+ >>> is_prime(4)
374
+ False
375
+ >>> is_prime(1)
376
+ False
377
+ """"""
378
+ ",0.6000000000000001,0.9963880288957688,1.0
379
+ "import math
380
+
381
+
382
+ def poly(xs: list, x: float):
383
+ """"""
384
+ Evaluates polynomial with coefficients xs at point x.
385
+ return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
386
+ """"""
387
+ return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])
388
+
389
+
390
+ def find_zero(xs: list):
391
+ """""" xs are coefficients of a polynomial.
392
+ find_zero find x such that poly(x) = 0.
393
+ find_zero returns only only zero point, even if there are many.
394
+ Moreover, find_zero only takes list xs having even number of coefficients
395
+ and largest non zero coefficient as it guarantees
396
+ a solution.
397
+ >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
398
+ -0.5
399
+ >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
400
+ 1.0
401
+ """"""
402
+ ",0.0,0.0,0.0
403
+ "
404
+
405
+ def sort_third(l: list):
406
+ """"""This function takes a list l and returns a list l' such that
407
+ 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
408
+ to the values of the corresponding indicies of l, but sorted.
409
+ >>> sort_third([1, 2, 3])
410
+ [1, 2, 3]
411
+ >>> sort_third([5, 6, 3, 4, 8, 9, 2])
412
+ [2, 6, 3, 4, 8, 9, 5]
413
+ """"""
414
+ ",0.050000000000000044,0.25,0.5
415
+ "
416
+
417
+ def unique(l: list):
418
+ """"""Return sorted unique elements in a list
419
+ >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
420
+ [0, 2, 3, 5, 9, 123]
421
+ """"""
422
+ ",0.7,0.9996130030959752,1.0
423
+ "
424
+
425
+ def max_element(l: list):
426
+ """"""Return maximum element in the list.
427
+ >>> max_element([1, 2, 3])
428
+ 3
429
+ >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
430
+ 123
431
+ """"""
432
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
433
+ "
434
+
435
+ def fizz_buzz(n: int):
436
+ """"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
437
+ >>> fizz_buzz(50)
438
+ 0
439
+ >>> fizz_buzz(78)
440
+ 2
441
+ >>> fizz_buzz(79)
442
+ 3
443
+ """"""
444
+ ",0.0,0.0,0.0
445
+ "
446
+
447
+ def sort_even(l: list):
448
+ """"""This function takes a list l and returns a list l' such that
449
+ l' is identical to l in the odd indicies, while its values at the even indicies are equal
450
+ to the values of the even indicies of l, but sorted.
451
+ >>> sort_even([1, 2, 3])
452
+ [1, 2, 3]
453
+ >>> sort_even([5, 6, 3, 4])
454
+ [3, 6, 5, 4]
455
+ """"""
456
+ ",0.050000000000000044,0.25,0.5
457
+ "
458
+
459
+ def encode_cyclic(s: str):
460
+ """"""
461
+ returns encoded string by cycling groups of three characters.
462
+ """"""
463
+ # split string to groups. Each of length 3.
464
+ groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
465
+ # cycle elements in each group. Unless group has fewer elements than 3.
466
+ groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
467
+ return """".join(groups)
468
+
469
+
470
+ def decode_cyclic(s: str):
471
+ """"""
472
+ takes as input string encoded with encode_cyclic function. Returns decoded string.
473
+ """"""
474
+ ",0.0,0.0,0.0
475
+ "
476
+
477
+ def prime_fib(n: int):
478
+ """"""
479
+ prime_fib returns n-th number that is a Fibonacci number and it's also prime.
480
+ >>> prime_fib(1)
481
+ 2
482
+ >>> prime_fib(2)
483
+ 3
484
+ >>> prime_fib(3)
485
+ 5
486
+ >>> prime_fib(4)
487
+ 13
488
+ >>> prime_fib(5)
489
+ 89
490
+ """"""
491
+ ",0.0,0.0,0.0
492
+ "
493
+
494
+ def triples_sum_to_zero(l: list):
495
+ """"""
496
+ triples_sum_to_zero takes a list of integers as an input.
497
+ it returns True if there are three distinct elements in the list that
498
+ sum to zero, and False otherwise.
499
+
500
+ >>> triples_sum_to_zero([1, 3, 5, 0])
501
+ False
502
+ >>> triples_sum_to_zero([1, 3, -2, 1])
503
+ True
504
+ >>> triples_sum_to_zero([1, 2, 3, 7])
505
+ False
506
+ >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
507
+ True
508
+ >>> triples_sum_to_zero([1])
509
+ False
510
+ """"""
511
+ ",0.7,0.9996130030959752,1.0
512
+ "
513
+
514
+ def car_race_collision(n: int):
515
+ """"""
516
+ Imagine a road that's a perfectly straight infinitely long line.
517
+ n cars are driving left to right; simultaneously, a different set of n cars
518
+ are driving right to left. The two sets of cars start out being very far from
519
+ each other. All cars move in the same speed. Two cars are said to collide
520
+ when a car that's moving left to right hits a car that's moving right to left.
521
+ However, the cars are infinitely sturdy and strong; as a result, they continue moving
522
+ in their trajectory as if they did not collide.
523
+
524
+ This function outputs the number of such collisions.
525
+ """"""
526
+ ",0.0,0.0,0.0
527
+ "
528
+
529
+ def incr_list(l: list):
530
+ """"""Return list with elements incremented by 1.
531
+ >>> incr_list([1, 2, 3])
532
+ [2, 3, 4]
533
+ >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
534
+ [6, 4, 6, 3, 4, 4, 10, 1, 124]
535
+ """"""
536
+ ",0.5499999999999998,0.9918730650154799,1.0
537
+ "
538
+
539
+ def pairs_sum_to_zero(l):
540
+ """"""
541
+ pairs_sum_to_zero takes a list of integers as an input.
542
+ it returns True if there are two distinct elements in the list that
543
+ sum to zero, and False otherwise.
544
+ >>> pairs_sum_to_zero([1, 3, 5, 0])
545
+ False
546
+ >>> pairs_sum_to_zero([1, 3, -2, 1])
547
+ False
548
+ >>> pairs_sum_to_zero([1, 2, 3, 7])
549
+ False
550
+ >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
551
+ True
552
+ >>> pairs_sum_to_zero([1])
553
+ False
554
+ """"""
555
+ ",0.7,0.9996130030959752,1.0
556
+ "
557
+
558
+ def change_base(x: int, base: int):
559
+ """"""Change numerical base of input number x to base.
560
+ return string representation after the conversion.
561
+ base numbers are less than 10.
562
+ >>> change_base(8, 3)
563
+ '22'
564
+ >>> change_base(8, 2)
565
+ '1000'
566
+ >>> change_base(7, 2)
567
+ '111'
568
+ """"""
569
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
570
+ "
571
+
572
+ def triangle_area(a, h):
573
+ """"""Given length of a side and high return area for a triangle.
574
+ >>> triangle_area(5, 3)
575
+ 7.5
576
+ """"""
577
+ ",1.0,1.0,1.0
578
+ "
579
+
580
+ def fib4(n: int):
581
+ """"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
582
+ fib4(0) -> 0
583
+ fib4(1) -> 0
584
+ fib4(2) -> 2
585
+ fib4(3) -> 0
586
+ fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
587
+ Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
588
+ >>> fib4(5)
589
+ 4
590
+ >>> fib4(6)
591
+ 8
592
+ >>> fib4(7)
593
+ 14
594
+ """"""
595
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
596
+ "
597
+
598
+ def median(l: list):
599
+ """"""Return median of elements in the list l.
600
+ >>> median([3, 1, 2, 4, 5])
601
+ 3
602
+ >>> median([-10, 4, 6, 1000, 10, 20])
603
+ 15.0
604
+ """"""
605
+ ",0.85,1.0,1.0
606
+ "
607
+
608
+ def is_palindrome(text: str):
609
+ """"""
610
+ Checks if given string is a palindrome
611
+ >>> is_palindrome('')
612
+ True
613
+ >>> is_palindrome('aba')
614
+ True
615
+ >>> is_palindrome('aaaaa')
616
+ True
617
+ >>> is_palindrome('zbcd')
618
+ False
619
+ """"""
620
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
621
+ "
622
+
623
+ def modp(n: int, p: int):
624
+ """"""Return 2^n modulo p (be aware of numerics).
625
+ >>> modp(3, 5)
626
+ 3
627
+ >>> modp(1101, 101)
628
+ 2
629
+ >>> modp(0, 101)
630
+ 1
631
+ >>> modp(3, 11)
632
+ 8
633
+ >>> modp(100, 101)
634
+ 1
635
+ """"""
636
+ ",0.0,0.0,0.0
637
+ "
638
+
639
+ def encode_shift(s: str):
640
+ """"""
641
+ returns encoded string by shifting every character by 5 in the alphabet.
642
+ """"""
643
+ return """".join([chr(((ord(ch) + 5 - ord(""a"")) % 26) + ord(""a"")) for ch in s])
644
+
645
+
646
+ def decode_shift(s: str):
647
+ """"""
648
+ takes as input string encoded with encode_shift function. Returns decoded string.
649
+ """"""
650
+ ",1.0,1.0,1.0
651
+ "
652
+
653
+ def remove_vowels(text):
654
+ """"""
655
+ remove_vowels is a function that takes string and returns string without vowels.
656
+ >>> remove_vowels('')
657
+ ''
658
+ >>> remove_vowels(""abcdef\nghijklm"")
659
+ 'bcdf\nghjklm'
660
+ >>> remove_vowels('abcdef')
661
+ 'bcdf'
662
+ >>> remove_vowels('aaaaa')
663
+ ''
664
+ >>> remove_vowels('aaBAA')
665
+ 'B'
666
+ >>> remove_vowels('zbcd')
667
+ 'zbcd'
668
+ """"""
669
+ ",0.7999999999999999,1.0,1.0
670
+ "
671
+
672
+ def below_threshold(l: list, t: int):
673
+ """"""Return True if all numbers in the list l are below threshold t.
674
+ >>> below_threshold([1, 2, 4, 10], 100)
675
+ True
676
+ >>> below_threshold([1, 20, 4, 10], 5)
677
+ False
678
+ """"""
679
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
680
+ "
681
+
682
+ def add(x: int, y: int):
683
+ """"""Add two numbers x and y
684
+ >>> add(2, 3)
685
+ 5
686
+ >>> add(5, 7)
687
+ 12
688
+ """"""
689
+ ",0.8999999999999999,1.0,1.0
690
+ "
691
+
692
+ def same_chars(s0: str, s1: str):
693
+ """"""
694
+ Check if two words have the same characters.
695
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
696
+ True
697
+ >>> same_chars('abcd', 'dddddddabc')
698
+ True
699
+ >>> same_chars('dddddddabc', 'abcd')
700
+ True
701
+ >>> same_chars('eabcd', 'dddddddabc')
702
+ False
703
+ >>> same_chars('abcd', 'dddddddabce')
704
+ False
705
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
706
+ False
707
+ """"""
708
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
709
+ "
710
+
711
+ def fib(n: int):
712
+ """"""Return n-th Fibonacci number.
713
+ >>> fib(10)
714
+ 55
715
+ >>> fib(1)
716
+ 1
717
+ >>> fib(8)
718
+ 21
719
+ """"""
720
+ ",0.5499999999999998,0.9918730650154799,1.0
721
+ "
722
+
723
+ def correct_bracketing(brackets: str):
724
+ """""" brackets is a string of ""<"" and "">"".
725
+ return True if every opening bracket has a corresponding closing bracket.
726
+
727
+ >>> correct_bracketing(""<"")
728
+ False
729
+ >>> correct_bracketing(""<>"")
730
+ True
731
+ >>> correct_bracketing(""<<><>>"")
732
+ True
733
+ >>> correct_bracketing(""><<>"")
734
+ False
735
+ """"""
736
+ ",0.6000000000000001,0.9963880288957688,1.0
737
+ "
738
+
739
+ def monotonic(l: list):
740
+ """"""Return True is list elements are monotonically increasing or decreasing.
741
+ >>> monotonic([1, 2, 4, 20])
742
+ True
743
+ >>> monotonic([1, 20, 4, 10])
744
+ False
745
+ >>> monotonic([4, 1, 0, -10])
746
+ True
747
+ """"""
748
+ ",0.65,0.9986455108359134,1.0
749
+ "
750
+
751
+ def common(l1: list, l2: list):
752
+ """"""Return sorted unique common elements for two lists.
753
+ >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
754
+ [1, 5, 653]
755
+ >>> common([5, 3, 2, 8], [3, 2])
756
+ [2, 3]
757
+
758
+ """"""
759
+ ",0.8999999999999999,1.0,1.0
760
+ "
761
+
762
+ def largest_prime_factor(n: int):
763
+ """"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
764
+ >>> largest_prime_factor(13195)
765
+ 29
766
+ >>> largest_prime_factor(2048)
767
+ 2
768
+ """"""
769
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
770
+ "
771
+
772
+ def sum_to_n(n: int):
773
+ """"""sum_to_n is a function that sums numbers from 1 to n.
774
+ >>> sum_to_n(30)
775
+ 465
776
+ >>> sum_to_n(100)
777
+ 5050
778
+ >>> sum_to_n(5)
779
+ 15
780
+ >>> sum_to_n(10)
781
+ 55
782
+ >>> sum_to_n(1)
783
+ 1
784
+ """"""
785
+ ",0.6000000000000001,0.9963880288957688,1.0
786
+ "
787
+
788
+ def correct_bracketing(brackets: str):
789
+ """""" brackets is a string of ""("" and "")"".
790
+ return True if every opening bracket has a corresponding closing bracket.
791
+
792
+ >>> correct_bracketing(""("")
793
+ False
794
+ >>> correct_bracketing(""()"")
795
+ True
796
+ >>> correct_bracketing(""(()())"")
797
+ True
798
+ >>> correct_bracketing("")(()"")
799
+ False
800
+ """"""
801
+ ",0.25,0.8063080495356036,0.9837461300309598
802
+ "
803
+
804
+ def derivative(xs: list):
805
+ """""" xs represent coefficients of a polynomial.
806
+ xs[0] + xs[1] * x + xs[2] * x^2 + ....
807
+ Return derivative of this polynomial in the same form.
808
+ >>> derivative([3, 1, 2, 4, 5])
809
+ [1, 4, 12, 20]
810
+ >>> derivative([1, 2, 3])
811
+ [2, 6]
812
+ """"""
813
+ ",0.25,0.8063080495356036,0.9837461300309598
814
+ "
815
+
816
+ def fibfib(n: int):
817
+ """"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
818
+ fibfib(0) == 0
819
+ fibfib(1) == 0
820
+ fibfib(2) == 1
821
+ fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
822
+ Please write a function to efficiently compute the n-th element of the fibfib number sequence.
823
+ >>> fibfib(1)
824
+ 0
825
+ >>> fibfib(5)
826
+ 4
827
+ >>> fibfib(8)
828
+ 24
829
+ """"""
830
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
831
+ "
832
+ FIX = """"""
833
+ Add more test cases.
834
+ """"""
835
+
836
+ def vowels_count(s):
837
+ """"""Write a function vowels_count which takes a string representing
838
+ a word as input and returns the number of vowels in the string.
839
+ Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
840
+ vowel, but only when it is at the end of the given word.
841
+
842
+ Example:
843
+ >>> vowels_count(""abcde"")
844
+ 2
845
+ >>> vowels_count(""ACEDY"")
846
+ 3
847
+ """"""
848
+ ",0.7,0.9996130030959752,1.0
849
+ "
850
+ def circular_shift(x, shift):
851
+ """"""Circular shift the digits of the integer x, shift the digits right by shift
852
+ and return the result as a string.
853
+ If shift > number of digits, return digits reversed.
854
+ >>> circular_shift(12, 1)
855
+ ""21""
856
+ >>> circular_shift(12, 2)
857
+ ""12""
858
+ """"""
859
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
860
+ "
861
+ def digitSum(s):
862
+ """"""Task
863
+ Write a function that takes a string as input and returns the sum of the upper characters only'
864
+ ASCII codes.
865
+
866
+ Examples:
867
+ digitSum("""") => 0
868
+ digitSum(""abAB"") => 131
869
+ digitSum(""abcCd"") => 67
870
+ digitSum(""helloE"") => 69
871
+ digitSum(""woArBld"") => 131
872
+ digitSum(""aAaaaXa"") => 153
873
+ """"""
874
+ ",0.65,0.9986455108359134,1.0
875
+ "
876
+ def fruit_distribution(s,n):
877
+ """"""
878
+ In this task, you will be given a string that represents a number of apples and oranges
879
+ that are distributed in a basket of fruit this basket contains
880
+ apples, oranges, and mango fruits. Given the string that represents the total number of
881
+ the oranges and apples and an integer that represent the total number of the fruits
882
+ in the basket return the number of the mango fruits in the basket.
883
+ for examble:
884
+ fruit_distribution(""5 apples and 6 oranges"", 19) ->19 - 5 - 6 = 8
885
+ fruit_distribution(""0 apples and 1 oranges"",3) -> 3 - 0 - 1 = 2
886
+ fruit_distribution(""2 apples and 3 oranges"", 100) -> 100 - 2 - 3 = 95
887
+ fruit_distribution(""100 apples and 1 oranges"",120) -> 120 - 100 - 1 = 19
888
+ """"""
889
+ ",0.0,0.0,0.0
890
+ "
891
+ def pluck(arr):
892
+ """"""
893
+ ""Given an array representing a branch of a tree that has non-negative integer nodes
894
+ your task is to pluck one of the nodes and return it.
895
+ The plucked node should be the node with the smallest even value.
896
+ If multiple nodes with the same smallest even value are found return the node that has smallest index.
897
+
898
+ The plucked node should be returned in a list, [ smalest_value, its index ],
899
+ If there are no even values or the given array is empty, return [].
900
+
901
+ Example 1:
902
+ Input: [4,2,3]
903
+ Output: [2, 1]
904
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
905
+
906
+ Example 2:
907
+ Input: [1,2,3]
908
+ Output: [2, 1]
909
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
910
+
911
+ Example 3:
912
+ Input: []
913
+ Output: []
914
+
915
+ Example 4:
916
+ Input: [5, 0, 3, 0, 4, 2]
917
+ Output: [0, 1]
918
+ Explanation: 0 is the smallest value, but there are two zeros,
919
+ so we will choose the first zero, which has the smallest index.
920
+
921
+ Constraints:
922
+ * 1 <= nodes.length <= 10000
923
+ * 0 <= node.value
924
+ """"""
925
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
926
+ "
927
+ def search(lst):
928
+ '''
929
+ You are given a non-empty list of positive integers. Return the greatest integer that is greater than
930
+ zero, and has a frequency greater than or equal to the value of the integer itself.
931
+ The frequency of an integer is the number of times it appears in the list.
932
+ If no such a value exist, return -1.
933
+ Examples:
934
+ search([4, 1, 2, 2, 3, 1]) == 2
935
+ search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
936
+ search([5, 5, 4, 4, 4]) == -1
937
+ '''
938
+ ",0.25,0.8063080495356036,0.9837461300309598
939
+ "
940
+ def strange_sort_list(lst):
941
+ '''
942
+ Given list of integers, return list in strange order.
943
+ Strange sorting, is when you start with the minimum value,
944
+ then maximum of the remaining integers, then minimum and so on.
945
+
946
+ Examples:
947
+ strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
948
+ strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
949
+ strange_sort_list([]) == []
950
+ '''
951
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
952
+ "
953
+ def triangle_area(a, b, c):
954
+ '''
955
+ Given the lengths of the three sides of a triangle. Return the area of
956
+ the triangle rounded to 2 decimal points if the three sides form a valid triangle.
957
+ Otherwise return -1
958
+ Three sides make a valid triangle when the sum of any two sides is greater
959
+ than the third side.
960
+ Example:
961
+ triangle_area(3, 4, 5) == 6.00
962
+ triangle_area(1, 2, 10) == -1
963
+ '''
964
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
965
+ "
966
+ def will_it_fly(q,w):
967
+ '''
968
+ Write a function that returns True if the object q will fly, and False otherwise.
969
+ 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.
970
+
971
+ Example:
972
+ will_it_fly([1, 2], 5) ➞ False
973
+ # 1+2 is less than the maximum possible weight, but it's unbalanced.
974
+
975
+ will_it_fly([3, 2, 3], 1) ➞ False
976
+ # it's balanced, but 3+2+3 is more than the maximum possible weight.
977
+
978
+ will_it_fly([3, 2, 3], 9) ➞ True
979
+ # 3+2+3 is less than the maximum possible weight, and it's balanced.
980
+
981
+ will_it_fly([3], 5) ➞ True
982
+ # 3 is less than the maximum possible weight, and it's balanced.
983
+ '''
984
+ ",0.5499999999999998,0.9918730650154799,1.0
985
+ "
986
+ def smallest_change(arr):
987
+ """"""
988
+ Given an array arr of integers, find the minimum number of elements that
989
+ need to be changed to make the array palindromic. A palindromic array is an array that
990
+ is read the same backwards and forwards. In one change, you can change one element to any other element.
991
+
992
+ For example:
993
+ smallest_change([1,2,3,5,4,7,9,6]) == 4
994
+ smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
995
+ smallest_change([1, 2, 3, 2, 1]) == 0
996
+ """"""
997
+ ",0.0,0.0,0.0
998
+ "
999
+ def total_match(lst1, lst2):
1000
+ '''
1001
+ Write a function that accepts two lists of strings and returns the list that has
1002
+ total number of chars in the all strings of the list less than the other list.
1003
+
1004
+ if the two lists have the same number of chars, return the first list.
1005
+
1006
+ Examples
1007
+ total_match([], []) ➞ []
1008
+ total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
1009
+ total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
1010
+ total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
1011
+ total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
1012
+ '''
1013
+ ",0.0,0.0,0.0
1014
+ "
1015
+ def is_multiply_prime(a):
1016
+ """"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
1017
+ and false otherwise.
1018
+ Knowing that (a) is less then 100.
1019
+ Example:
1020
+ is_multiply_prime(30) == True
1021
+ 30 = 2 * 3 * 5
1022
+ """"""
1023
+ ",0.0,0.0,0.0
1024
+ "
1025
+ def is_simple_power(x, n):
1026
+ """"""Your task is to write a function that returns true if a number x is a simple
1027
+ power of n and false in other cases.
1028
+ x is a simple power of n if n**int=x
1029
+ For example:
1030
+ is_simple_power(1, 4) => true
1031
+ is_simple_power(2, 2) => true
1032
+ is_simple_power(8, 2) => true
1033
+ is_simple_power(3, 2) => false
1034
+ is_simple_power(3, 1) => false
1035
+ is_simple_power(5, 3) => false
1036
+ """"""
1037
+ ",0.0,0.0,0.0
1038
+ "
1039
+ def iscube(a):
1040
+ '''
1041
+ Write a function that takes an integer a and returns True
1042
+ if this ingeger is a cube of some integer number.
1043
+ Note: you may assume the input is always valid.
1044
+ Examples:
1045
+ iscube(1) ==> True
1046
+ iscube(2) ==> False
1047
+ iscube(-1) ==> True
1048
+ iscube(64) ==> True
1049
+ iscube(0) ==> True
1050
+ iscube(180) ==> False
1051
+ '''
1052
+ ",0.0,0.0,0.0
1053
+ "
1054
+ def hex_key(num):
1055
+ """"""You have been tasked to write a function that receives
1056
+ a hexadecimal number as a string and counts the number of hexadecimal
1057
+ digits that are primes (prime number, or a prime, is a natural number
1058
+ greater than 1 that is not a product of two smaller natural numbers).
1059
+ Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
1060
+ Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
1061
+ So you have to determine a number of the following digits: 2, 3, 5, 7,
1062
+ B (=decimal 11), D (=decimal 13).
1063
+ Note: you may assume the input is always correct or empty string,
1064
+ and symbols A,B,C,D,E,F are always uppercase.
1065
+ Examples:
1066
+ For num = ""AB"" the output should be 1.
1067
+ For num = ""1077E"" the output should be 2.
1068
+ For num = ""ABED1A33"" the output should be 4.
1069
+ For num = ""123456789ABCDEF0"" the output should be 6.
1070
+ For num = ""2020"" the output should be 2.
1071
+ """"""
1072
+ ",0.4,0.9489164086687306,0.9996427720885925
1073
+ "
1074
+ def decimal_to_binary(decimal):
1075
+ """"""You will be given a number in decimal form and your task is to convert it to
1076
+ binary format. The function should return a string, with each character representing a binary
1077
+ number. Each character in the string will be '0' or '1'.
1078
+
1079
+ There will be an extra couple of characters 'db' at the beginning and at the end of the string.
1080
+ The extra characters are there to help with the format.
1081
+
1082
+ Examples:
1083
+ decimal_to_binary(15) # returns ""db1111db""
1084
+ decimal_to_binary(32) # returns ""db100000db""
1085
+ """"""
1086
+ ",0.85,1.0,1.0
1087
+ "
1088
+ def is_happy(s):
1089
+ """"""You are given a string s.
1090
+ Your task is to check if the string is happy or not.
1091
+ A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
1092
+ For example:
1093
+ is_happy(a) => False
1094
+ is_happy(aa) => False
1095
+ is_happy(abcd) => True
1096
+ is_happy(aabb) => False
1097
+ is_happy(adb) => True
1098
+ is_happy(xyy) => False
1099
+ """"""
1100
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1101
+ "
1102
+ def numerical_letter_grade(grades):
1103
+ """"""It is the last week of the semester and the teacher has to give the grades
1104
+ to students. The teacher has been making her own algorithm for grading.
1105
+ The only problem is, she has lost the code she used for grading.
1106
+ She has given you a list of GPAs for some students and you have to write
1107
+ a function that can output a list of letter grades using the following table:
1108
+ GPA | Letter grade
1109
+ 4.0 A+
1110
+ > 3.7 A
1111
+ > 3.3 A-
1112
+ > 3.0 B+
1113
+ > 2.7 B
1114
+ > 2.3 B-
1115
+ > 2.0 C+
1116
+ > 1.7 C
1117
+ > 1.3 C-
1118
+ > 1.0 D+
1119
+ > 0.7 D
1120
+ > 0.0 D-
1121
+ 0.0 E
1122
+
1123
+
1124
+ Example:
1125
+ grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
1126
+ """"""
1127
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1128
+ "
1129
+ def prime_length(string):
1130
+ """"""Write a function that takes a string and returns True if the string
1131
+ length is a prime number or False otherwise
1132
+ Examples
1133
+ prime_length('Hello') == True
1134
+ prime_length('abcdcba') == True
1135
+ prime_length('kittens') == True
1136
+ prime_length('orange') == False
1137
+ """"""
1138
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1139
+ "
1140
+ def starts_one_ends(n):
1141
+ """"""
1142
+ Given a positive integer n, return the count of the numbers of n-digit
1143
+ positive integers that start or end with 1.
1144
+ """"""
1145
+ ",0.0,0.0,0.0
1146
+ "
1147
+ def solve(N):
1148
+ """"""Given a positive integer N, return the total sum of its digits in binary.
1149
+
1150
+ Example
1151
+ For N = 1000, the sum of digits will be 1 the output should be ""1"".
1152
+ For N = 150, the sum of digits will be 6 the output should be ""110"".
1153
+ For N = 147, the sum of digits will be 12 the output should be ""1100"".
1154
+
1155
+ Variables:
1156
+ @N integer
1157
+ Constraints: 0 ≤ N ≤ 10000.
1158
+ Output:
1159
+ a string of binary number
1160
+ """"""
1161
+ ",0.0,0.0,0.0
1162
+ "
1163
+ def add(lst):
1164
+ """"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
1165
+
1166
+
1167
+ Examples:
1168
+ add([4, 2, 6, 7]) ==> 2
1169
+ """"""
1170
+ ",0.6000000000000001,0.9963880288957688,1.0
1171
+ "
1172
+ def anti_shuffle(s):
1173
+ """"""
1174
+ Write a function that takes a string and returns an ordered version of it.
1175
+ Ordered version of string, is a string where all words (separated by space)
1176
+ are replaced by a new word where all the characters arranged in
1177
+ ascending order based on ascii value.
1178
+ Note: You should keep the order of words and blank spaces in the sentence.
1179
+
1180
+ For example:
1181
+ anti_shuffle('Hi') returns 'Hi'
1182
+ anti_shuffle('hello') returns 'ehllo'
1183
+ anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
1184
+ """"""
1185
+ ",0.6000000000000001,0.9963880288957688,1.0
1186
+ "
1187
+ def get_row(lst, x):
1188
+ """"""
1189
+ You are given a 2 dimensional data, as a nested lists,
1190
+ which is similar to matrix, however, unlike matrices,
1191
+ each row may contain a different number of columns.
1192
+ Given lst, and integer x, find integers x in the list,
1193
+ and return list of tuples, [(x1, y1), (x2, y2) ...] such that
1194
+ each tuple is a coordinate - (row, columns), starting with 0.
1195
+ Sort coordinates initially by rows in ascending order.
1196
+ Also, sort coordinates of the row by columns in descending order.
1197
+
1198
+ Examples:
1199
+ get_row([
1200
+ [1,2,3,4,5,6],
1201
+ [1,2,3,4,1,6],
1202
+ [1,2,3,4,5,1]
1203
+ ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
1204
+ get_row([], 1) == []
1205
+ get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
1206
+ """"""
1207
+ ",0.050000000000000044,0.25,0.5
1208
+ "
1209
+ def sort_array(array):
1210
+ """"""
1211
+ Given an array of non-negative integers, return a copy of the given array after sorting,
1212
+ you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
1213
+ or sort it in descending order if the sum( first index value, last index value) is even.
1214
+
1215
+ Note:
1216
+ * don't change the given array.
1217
+
1218
+ Examples:
1219
+ * sort_array([]) => []
1220
+ * sort_array([5]) => [5]
1221
+ * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
1222
+ * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
1223
+ """"""
1224
+ ",0.050000000000000044,0.25,0.5
1225
+ "
1226
+ def encrypt(s):
1227
+ """"""Create a function encrypt that takes a string as an argument and
1228
+ returns a string encrypted with the alphabet being rotated.
1229
+ The alphabet should be rotated in a manner such that the letters
1230
+ shift down by two multiplied to two places.
1231
+ For example:
1232
+ encrypt('hi') returns 'lm'
1233
+ encrypt('asdfghjkl') returns 'ewhjklnop'
1234
+ encrypt('gf') returns 'kj'
1235
+ encrypt('et') returns 'ix'
1236
+ """"""
1237
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1238
+ "
1239
+ def next_smallest(lst):
1240
+ """"""
1241
+ You are given a list of integers.
1242
+ Write a function next_smallest() that returns the 2nd smallest element of the list.
1243
+ Return None if there is no such element.
1244
+
1245
+ next_smallest([1, 2, 3, 4, 5]) == 2
1246
+ next_smallest([5, 1, 4, 3, 2]) == 2
1247
+ next_smallest([]) == None
1248
+ next_smallest([1, 1]) == None
1249
+ """"""
1250
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1251
+ "
1252
+ def is_bored(S):
1253
+ """"""
1254
+ You'll be given a string of words, and your task is to count the number
1255
+ of boredoms. A boredom is a sentence that starts with the word ""I"".
1256
+ Sentences are delimited by '.', '?' or '!'.
1257
+
1258
+ For example:
1259
+ >>> is_bored(""Hello world"")
1260
+ 0
1261
+ >>> is_bored(""The sky is blue. The sun is shining. I love this weather"")
1262
+ 1
1263
+ """"""
1264
+ ",0.0,0.0,0.0
1265
+ "
1266
+ def any_int(x, y, z):
1267
+ '''
1268
+ Create a function that takes 3 numbers.
1269
+ Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
1270
+ Returns false in any other cases.
1271
+
1272
+ Examples
1273
+ any_int(5, 2, 7) ➞ True
1274
+
1275
+ any_int(3, 2, 2) ➞ False
1276
+
1277
+ any_int(3, -2, 1) ➞ True
1278
+
1279
+ any_int(3.6, -2.2, 2) ➞ False
1280
+
1281
+
1282
+
1283
+ '''
1284
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
1285
+ "
1286
+ def encode(message):
1287
+ """"""
1288
+ Write a function that takes a message, and encodes in such a
1289
+ way that it swaps case of all letters, replaces all vowels in
1290
+ the message with the letter that appears 2 places ahead of that
1291
+ vowel in the english alphabet.
1292
+ Assume only letters.
1293
+
1294
+ Examples:
1295
+ >>> encode('test')
1296
+ 'TGST'
1297
+ >>> encode('This is a message')
1298
+ 'tHKS KS C MGSSCGG'
1299
+ """"""
1300
+ ",0.0,0.0,0.0
1301
+ "
1302
+
1303
+ def skjkasdkd(lst):
1304
+ """"""You are given a list of integers.
1305
+ You need to find the largest prime value and return the sum of its digits.
1306
+
1307
+ Examples:
1308
+ For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
1309
+ For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
1310
+ For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
1311
+ For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
1312
+ For lst = [0,81,12,3,1,21] the output should be 3
1313
+ For lst = [0,8,1,2,1,7] the output should be 7
1314
+ """"""
1315
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1316
+ "
1317
+ def check_dict_case(dict):
1318
+ """"""
1319
+ Given a dictionary, return True if all keys are strings in lower
1320
+ case or all keys are strings in upper case, else return False.
1321
+ The function should return False is the given dictionary is empty.
1322
+ Examples:
1323
+ check_dict_case({""a"":""apple"", ""b"":""banana""}) should return True.
1324
+ check_dict_case({""a"":""apple"", ""A"":""banana"", ""B"":""banana""}) should return False.
1325
+ check_dict_case({""a"":""apple"", 8:""banana"", ""a"":""apple""}) should return False.
1326
+ check_dict_case({""Name"":""John"", ""Age"":""36"", ""City"":""Houston""}) should return False.
1327
+ check_dict_case({""STATE"":""NC"", ""ZIP"":""12345"" }) should return True.
1328
+ """"""
1329
+ ",0.050000000000000044,0.25,0.5
1330
+ "
1331
+ def count_up_to(n):
1332
+ """"""Implement a function that takes an non-negative integer and returns an array of the first n
1333
+ integers that are prime numbers and less than n.
1334
+ for example:
1335
+ count_up_to(5) => [2,3]
1336
+ count_up_to(11) => [2,3,5,7]
1337
+ count_up_to(0) => []
1338
+ count_up_to(20) => [2,3,5,7,11,13,17,19]
1339
+ count_up_to(1) => []
1340
+ count_up_to(18) => [2,3,5,7,11,13,17]
1341
+ """"""
1342
+ ",0.65,0.9986455108359134,1.0
1343
+ "
1344
+ def multiply(a, b):
1345
+ """"""Complete the function that takes two integers and returns
1346
+ the product of their unit digits.
1347
+ Assume the input is always valid.
1348
+ Examples:
1349
+ multiply(148, 412) should return 16.
1350
+ multiply(19, 28) should return 72.
1351
+ multiply(2020, 1851) should return 0.
1352
+ multiply(14,-15) should return 20.
1353
+ """"""
1354
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1355
+ "
1356
+ def count_upper(s):
1357
+ """"""
1358
+ Given a string s, count the number of uppercase vowels in even indices.
1359
+
1360
+ For example:
1361
+ count_upper('aBCdEf') returns 1
1362
+ count_upper('abcdefg') returns 0
1363
+ count_upper('dBBE') returns 0
1364
+ """"""
1365
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1366
+ "
1367
+ def closest_integer(value):
1368
+ '''
1369
+ Create a function that takes a value (string) representing a number
1370
+ and returns the closest integer to it. If the number is equidistant
1371
+ from two integers, round it away from zero.
1372
+
1373
+ Examples
1374
+ >>> closest_integer(""10"")
1375
+ 10
1376
+ >>> closest_integer(""15.3"")
1377
+ 15
1378
+
1379
+ Note:
1380
+ Rounding away from zero means that if the given number is equidistant
1381
+ from two integers, the one you should return is the one that is the
1382
+ farthest from zero. For example closest_integer(""14.5"") should
1383
+ return 15 and closest_integer(""-14.5"") should return -15.
1384
+ '''
1385
+ ",0.0,0.0,0.0
1386
+ "
1387
+ def make_a_pile(n):
1388
+ """"""
1389
+ Given a positive integer n, you have to make a pile of n levels of stones.
1390
+ The first level has n stones.
1391
+ The number of stones in the next level is:
1392
+ - the next odd number if n is odd.
1393
+ - the next even number if n is even.
1394
+ Return the number of stones in each level in a list, where element at index
1395
+ i represents the number of stones in the level (i+1).
1396
+
1397
+ Examples:
1398
+ >>> make_a_pile(3)
1399
+ [3, 5, 7]
1400
+ """"""
1401
+ ",0.050000000000000044,0.25,0.5
1402
+ "
1403
+ def words_string(s):
1404
+ """"""
1405
+ You will be given a string of words separated by commas or spaces. Your task is
1406
+ to split the string into words and return an array of the words.
1407
+
1408
+ For example:
1409
+ words_string(""Hi, my name is John"") == [""Hi"", ""my"", ""name"", ""is"", ""John""]
1410
+ words_string(""One, two, three, four, five, six"") == [""One"", ""two"", ""three"", ""four"", ""five"", ""six""]
1411
+ """"""
1412
+ ",0.0,0.0,0.0
1413
+ "
1414
+ def choose_num(x, y):
1415
+ """"""This function takes two positive numbers x and y and returns the
1416
+ biggest even integer number that is in the range [x, y] inclusive. If
1417
+ there's no such number, then the function should return -1.
1418
+
1419
+ For example:
1420
+ choose_num(12, 15) = 14
1421
+ choose_num(13, 12) = -1
1422
+ """"""
1423
+ ",0.050000000000000044,0.25,0.5
1424
+ "
1425
+ def rounded_avg(n, m):
1426
+ """"""You are given two positive integers n and m, and your task is to compute the
1427
+ average of the integers from n through m (including n and m).
1428
+ Round the answer to the nearest integer and convert that to binary.
1429
+ If n is greater than m, return -1.
1430
+ Example:
1431
+ rounded_avg(1, 5) => ""0b11""
1432
+ rounded_avg(7, 5) => -1
1433
+ rounded_avg(10, 20) => ""0b1111""
1434
+ rounded_avg(20, 33) => ""0b11010""
1435
+ """"""
1436
+ ",0.0,0.0,0.0
1437
+ "
1438
+ def unique_digits(x):
1439
+ """"""Given a list of positive integers x. return a sorted list of all
1440
+ elements that hasn't any even digit.
1441
+
1442
+ Note: Returned list should be sorted in increasing order.
1443
+
1444
+ For example:
1445
+ >>> unique_digits([15, 33, 1422, 1])
1446
+ [1, 15, 33]
1447
+ >>> unique_digits([152, 323, 1422, 10])
1448
+ []
1449
+ """"""
1450
+ ",0.25,0.8063080495356036,0.9837461300309598
1451
+ "
1452
+ def by_length(arr):
1453
+ """"""
1454
+ Given an array of integers, sort the integers that are between 1 and 9 inclusive,
1455
+ reverse the resulting array, and then replace each digit by its corresponding name from
1456
+ ""One"", ""Two"", ""Three"", ""Four"", ""Five"", ""Six"", ""Seven"", ""Eight"", ""Nine"".
1457
+
1458
+ For example:
1459
+ arr = [2, 1, 1, 4, 5, 8, 2, 3]
1460
+ -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
1461
+ -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
1462
+ return [""Eight"", ""Five"", ""Four"", ""Three"", ""Two"", ""Two"", ""One"", ""One""]
1463
+
1464
+ If the array is empty, return an empty array:
1465
+ arr = []
1466
+ return []
1467
+
1468
+ If the array has any strange number ignore it:
1469
+ arr = [1, -1 , 55]
1470
+ -> sort arr -> [-1, 1, 55]
1471
+ -> reverse arr -> [55, 1, -1]
1472
+ return = ['One']
1473
+ """"""
1474
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1475
+ "
1476
+ def f(n):
1477
+ """""" Implement the function f that takes n as a parameter,
1478
+ 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
1479
+ or the sum of numbers from 1 to i otherwise.
1480
+ i starts from 1.
1481
+ the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
1482
+ Example:
1483
+ f(5) == [1, 2, 6, 24, 15]
1484
+ """"""
1485
+ ",0.0,0.0,0.0
1486
+ "
1487
+ def even_odd_palindrome(n):
1488
+ """"""
1489
+ Given a positive integer n, return a tuple that has the number of even and odd
1490
+ integer palindromes that fall within the range(1, n), inclusive.
1491
+
1492
+ Example 1:
1493
+
1494
+ Input: 3
1495
+ Output: (1, 2)
1496
+ Explanation:
1497
+ Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
1498
+
1499
+ Example 2:
1500
+
1501
+ Input: 12
1502
+ Output: (4, 6)
1503
+ Explanation:
1504
+ Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
1505
+
1506
+ Note:
1507
+ 1. 1 <= n <= 10^3
1508
+ 2. returned tuple has the number of even and odd integer palindromes respectively.
1509
+ """"""
1510
+ ",0.85,1.0,1.0
1511
+ "
1512
+ def count_nums(arr):
1513
+ """"""
1514
+ Write a function count_nums which takes an array of integers and returns
1515
+ the number of elements which has a sum of digits > 0.
1516
+ If a number is negative, then its first signed digit will be negative:
1517
+ e.g. -123 has signed digits -1, 2, and 3.
1518
+ >>> count_nums([]) == 0
1519
+ >>> count_nums([-1, 11, -11]) == 1
1520
+ >>> count_nums([1, 1, 2]) == 3
1521
+ """"""
1522
+ ",0.0,0.0,0.0
1523
+ "
1524
+ def move_one_ball(arr):
1525
+ """"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
1526
+ numbers in the array will be randomly ordered. Your task is to determine if
1527
+ it is possible to get an array sorted in non-decreasing order by performing
1528
+ the following operation on the given array:
1529
+ You are allowed to perform right shift operation any number of times.
1530
+
1531
+ One right shift operation means shifting all elements of the array by one
1532
+ position in the right direction. The last element of the array will be moved to
1533
+ the starting position in the array i.e. 0th index.
1534
+
1535
+ If it is possible to obtain the sorted array by performing the above operation
1536
+ then return True else return False.
1537
+ If the given array is empty then return True.
1538
+
1539
+ Note: The given list is guaranteed to have unique elements.
1540
+
1541
+ For Example:
1542
+
1543
+ move_one_ball([3, 4, 5, 1, 2])==>True
1544
+ Explanation: By performin 2 right shift operations, non-decreasing order can
1545
+ be achieved for the given array.
1546
+ move_one_ball([3, 5, 4, 1, 2])==>False
1547
+ Explanation:It is not possible to get non-decreasing order for the given
1548
+ array by performing any number of right shift operations.
1549
+
1550
+ """"""
1551
+ ",0.050000000000000044,0.25,0.5
1552
+ "
1553
+ def exchange(lst1, lst2):
1554
+ """"""In this problem, you will implement a function that takes two lists of numbers,
1555
+ and determines whether it is possible to perform an exchange of elements
1556
+ between them to make lst1 a list of only even numbers.
1557
+ There is no limit on the number of exchanged elements between lst1 and lst2.
1558
+ If it is possible to exchange elements between the lst1 and lst2 to make
1559
+ all the elements of lst1 to be even, return ""YES"".
1560
+ Otherwise, return ""NO"".
1561
+ For example:
1562
+ exchange([1, 2, 3, 4], [1, 2, 3, 4]) => ""YES""
1563
+ exchange([1, 2, 3, 4], [1, 5, 3, 4]) => ""NO""
1564
+ It is assumed that the input lists will be non-empty.
1565
+ """"""
1566
+ ",0.0,0.0,0.0
1567
+ "
1568
+ def histogram(test):
1569
+ """"""Given a string representing a space separated lowercase letters, return a dictionary
1570
+ of the letter with the most repetition and containing the corresponding count.
1571
+ If several letters have the same occurrence, return all of them.
1572
+
1573
+ Example:
1574
+ histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
1575
+ histogram('a b b a') == {'a': 2, 'b': 2}
1576
+ histogram('a b c a b') == {'a': 2, 'b': 2}
1577
+ histogram('b b b b a') == {'b': 4}
1578
+ histogram('') == {}
1579
+
1580
+ """"""
1581
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1582
+ "
1583
+ def reverse_delete(s,c):
1584
+ """"""Task
1585
+ 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
1586
+ then check if the result string is palindrome.
1587
+ A string is called palindrome if it reads the same backward as forward.
1588
+ You should return a tuple containing the result string and True/False for the check.
1589
+ Example
1590
+ For s = ""abcde"", c = ""ae"", the result should be ('bcd',False)
1591
+ For s = ""abcdef"", c = ""b"" the result should be ('acdef',False)
1592
+ For s = ""abcdedcba"", c = ""ab"", the result should be ('cdedc',True)
1593
+ """"""
1594
+ ",0.5499999999999998,0.9918730650154799,1.0
1595
+ "
1596
+ def odd_count(lst):
1597
+ """"""Given a list of strings, where each string consists of only digits, return a list.
1598
+ Each element i of the output should be ""the number of odd elements in the
1599
+ string i of the input."" where all the i's should be replaced by the number
1600
+ of odd digits in the i'th string of the input.
1601
+
1602
+ >>> odd_count(['1234567'])
1603
+ [""the number of odd elements 4n the str4ng 4 of the 4nput.""]
1604
+ >>> odd_count(['3',""11111111""])
1605
+ [""the number of odd elements 1n the str1ng 1 of the 1nput."",
1606
+ ""the number of odd elements 8n the str8ng 8 of the 8nput.""]
1607
+ """"""
1608
+ ",0.0,0.0,0.0
1609
+ "
1610
+ def minSubArraySum(nums):
1611
+ """"""
1612
+ Given an array of integers nums, find the minimum sum of any non-empty sub-array
1613
+ of nums.
1614
+ Example
1615
+ minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
1616
+ minSubArraySum([-1, -2, -3]) == -6
1617
+ """"""
1618
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1619
+ "
1620
+ def max_fill(grid, capacity):
1621
+ import math
1622
+ """"""
1623
+ You are given a rectangular grid of wells. Each row represents a single well,
1624
+ and each 1 in a row represents a single unit of water.
1625
+ Each well has a corresponding bucket that can be used to extract water from it,
1626
+ and all buckets have the same capacity.
1627
+ Your task is to use the buckets to empty the wells.
1628
+ Output the number of times you need to lower the buckets.
1629
+
1630
+ Example 1:
1631
+ Input:
1632
+ grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
1633
+ bucket_capacity : 1
1634
+ Output: 6
1635
+
1636
+ Example 2:
1637
+ Input:
1638
+ grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
1639
+ bucket_capacity : 2
1640
+ Output: 5
1641
+
1642
+ Example 3:
1643
+ Input:
1644
+ grid : [[0,0,0], [0,0,0]]
1645
+ bucket_capacity : 5
1646
+ Output: 0
1647
+
1648
+ Constraints:
1649
+ * all wells have the same length
1650
+ * 1 <= grid.length <= 10^2
1651
+ * 1 <= grid[:,1].length <= 10^2
1652
+ * grid[i][j] -> 0 | 1
1653
+ * 1 <= capacity <= 10
1654
+ """"""
1655
+ ",0.0,0.0,0.0
1656
+ "
1657
+ def sort_array(arr):
1658
+ """"""
1659
+ In this Kata, you have to sort an array of non-negative integers according to
1660
+ number of ones in their binary representation in ascending order.
1661
+ For similar number of ones, sort based on decimal value.
1662
+
1663
+ It must be implemented like this:
1664
+ >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
1665
+ >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
1666
+ >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
1667
+ """"""
1668
+ ",1.0,1.0,1.0
1669
+ "
1670
+ def select_words(s, n):
1671
+ """"""Given a string s and a natural number n, you have been tasked to implement
1672
+ a function that returns a list of all words from string s that contain exactly
1673
+ n consonants, in order these words appear in the string s.
1674
+ If the string s is empty then the function should return an empty list.
1675
+ Note: you may assume the input string contains only letters and spaces.
1676
+ Examples:
1677
+ select_words(""Mary had a little lamb"", 4) ==> [""little""]
1678
+ select_words(""Mary had a little lamb"", 3) ==> [""Mary"", ""lamb""]
1679
+ select_words(""simple white space"", 2) ==> []
1680
+ select_words(""Hello world"", 4) ==> [""world""]
1681
+ select_words(""Uncle sam"", 3) ==> [""Uncle""]
1682
+ """"""
1683
+ ",0.050000000000000044,0.25,0.5
1684
+ "
1685
+ def get_closest_vowel(word):
1686
+ """"""You are given a word. Your task is to find the closest vowel that stands between
1687
+ two consonants from the right side of the word (case sensitive).
1688
+
1689
+ Vowels in the beginning and ending doesn't count. Return empty string if you didn't
1690
+ find any vowel met the above condition.
1691
+
1692
+ You may assume that the given string contains English letter only.
1693
+
1694
+ Example:
1695
+ get_closest_vowel(""yogurt"") ==> ""u""
1696
+ get_closest_vowel(""FULL"") ==> ""U""
1697
+ get_closest_vowel(""quick"") ==> """"
1698
+ get_closest_vowel(""ab"") ==> """"
1699
+ """"""
1700
+ ",0.050000000000000044,0.25,0.5
1701
+ "
1702
+ def match_parens(lst):
1703
+ '''
1704
+ You are given a list of two strings, both strings consist of open
1705
+ parentheses '(' or close parentheses ')' only.
1706
+ Your job is to check if it is possible to concatenate the two strings in
1707
+ some order, that the resulting string will be good.
1708
+ A string S is considered to be good if and only if all parentheses in S
1709
+ are balanced. For example: the string '(())()' is good, while the string
1710
+ '())' is not.
1711
+ Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
1712
+
1713
+ Examples:
1714
+ match_parens(['()(', ')']) == 'Yes'
1715
+ match_parens([')', ')']) == 'No'
1716
+ '''
1717
+ ",0.0,0.0,0.0
1718
+ "
1719
+ def maximum(arr, k):
1720
+ """"""
1721
+ Given an array arr of integers and a positive integer k, return a sorted list
1722
+ of length k with the maximum k numbers in arr.
1723
+
1724
+ Example 1:
1725
+
1726
+ Input: arr = [-3, -4, 5], k = 3
1727
+ Output: [-4, -3, 5]
1728
+
1729
+ Example 2:
1730
+
1731
+ Input: arr = [4, -4, 4], k = 2
1732
+ Output: [4, 4]
1733
+
1734
+ Example 3:
1735
+
1736
+ Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
1737
+ Output: [2]
1738
+
1739
+ Note:
1740
+ 1. The length of the array will be in the range of [1, 1000].
1741
+ 2. The elements in the array will be in the range of [-1000, 1000].
1742
+ 3. 0 <= k <= len(arr)
1743
+ """"""
1744
+ ",0.0,0.0,0.0
1745
+ "
1746
+ def solution(lst):
1747
+ """"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
1748
+
1749
+
1750
+ Examples
1751
+ solution([5, 8, 7, 1]) ==> 12
1752
+ solution([3, 3, 3, 3, 3]) ==> 9
1753
+ solution([30, 13, 24, 321]) ==>0
1754
+ """"""
1755
+ ",0.050000000000000044,0.25,0.5
1756
+ "
1757
+ def add_elements(arr, k):
1758
+ """"""
1759
+ Given a non-empty array of integers arr and an integer k, return
1760
+ the sum of the elements with at most two digits from the first k elements of arr.
1761
+
1762
+ Example:
1763
+
1764
+ Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
1765
+ Output: 24 # sum of 21 + 3
1766
+
1767
+ Constraints:
1768
+ 1. 1 <= len(arr) <= 100
1769
+ 2. 1 <= k <= len(arr)
1770
+ """"""
1771
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1772
+ "
1773
+ def get_odd_collatz(n):
1774
+ """"""
1775
+ Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
1776
+
1777
+ The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
1778
+ as follows: start with any positive integer n. Then each term is obtained from the
1779
+ previous term as follows: if the previous term is even, the next term is one half of
1780
+ the previous term. If the previous term is odd, the next term is 3 times the previous
1781
+ term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
1782
+
1783
+ Note:
1784
+ 1. Collatz(1) is [1].
1785
+ 2. returned list sorted in increasing order.
1786
+
1787
+ For example:
1788
+ get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
1789
+ """"""
1790
+ ",0.4,0.9489164086687306,0.9996427720885925
1791
+ "
1792
+ def valid_date(date):
1793
+ """"""You have to write a function which validates a given date string and
1794
+ returns True if the date is valid otherwise False.
1795
+ The date is valid if all of the following rules are satisfied:
1796
+ 1. The date string is not empty.
1797
+ 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
1798
+ 3. The months should not be less than 1 or higher than 12.
1799
+ 4. The date should be in the format: mm-dd-yyyy
1800
+
1801
+ for example:
1802
+ valid_date('03-11-2000') => True
1803
+
1804
+ valid_date('15-01-2012') => False
1805
+
1806
+ valid_date('04-0-2040') => False
1807
+
1808
+ valid_date('06-04-2020') => True
1809
+
1810
+ valid_date('06/04/2020') => False
1811
+ """"""
1812
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1813
+ "
1814
+ def split_words(txt):
1815
+ '''
1816
+ Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
1817
+ should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
1818
+ alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
1819
+ Examples
1820
+ split_words(""Hello world!"") ➞ [""Hello"", ""world!""]
1821
+ split_words(""Hello,world!"") ➞ [""Hello"", ""world!""]
1822
+ split_words(""abcdef"") == 3
1823
+ '''
1824
+ ",0.0,0.0,0.0
1825
+ "
1826
+ def is_sorted(lst):
1827
+ '''
1828
+ Given a list of numbers, return whether or not they are sorted
1829
+ in ascending order. If list has more than 1 duplicate of the same
1830
+ number, return False. Assume no negative numbers and only integers.
1831
+
1832
+ Examples
1833
+ is_sorted([5]) ➞ True
1834
+ is_sorted([1, 2, 3, 4, 5]) ➞ True
1835
+ is_sorted([1, 3, 2, 4, 5]) ➞ False
1836
+ is_sorted([1, 2, 3, 4, 5, 6]) ➞ True
1837
+ is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
1838
+ is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
1839
+ is_sorted([1, 2, 2, 3, 3, 4]) ➞ True
1840
+ is_sorted([1, 2, 2, 2, 3, 4]) ➞ False
1841
+ '''
1842
+ ",0.0,0.0,0.0
1843
+ "
1844
+ def intersection(interval1, interval2):
1845
+ """"""You are given two intervals,
1846
+ where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
1847
+ The given intervals are closed which means that the interval (start, end)
1848
+ includes both start and end.
1849
+ For each given interval, it is assumed that its start is less or equal its end.
1850
+ Your task is to determine whether the length of intersection of these two
1851
+ intervals is a prime number.
1852
+ Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
1853
+ which its length is 1, which not a prime number.
1854
+ If the length of the intersection is a prime number, return ""YES"",
1855
+ otherwise, return ""NO"".
1856
+ If the two intervals don't intersect, return ""NO"".
1857
+
1858
+
1859
+ [input/output] samples:
1860
+ intersection((1, 2), (2, 3)) ==> ""NO""
1861
+ intersection((-1, 1), (0, 4)) ==> ""NO""
1862
+ intersection((-3, -1), (-5, 5)) ==> ""YES""
1863
+ """"""
1864
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
1865
+ "
1866
+ def prod_signs(arr):
1867
+ """"""
1868
+ You are given an array arr of integers and you need to return
1869
+ sum of magnitudes of integers multiplied by product of all signs
1870
+ of each number in the array, represented by 1, -1 or 0.
1871
+ Note: return None for empty arr.
1872
+
1873
+ Example:
1874
+ >>> prod_signs([1, 2, 2, -4]) == -9
1875
+ >>> prod_signs([0, 1]) == 0
1876
+ >>> prod_signs([]) == None
1877
+ """"""
1878
+ ",0.050000000000000044,0.25,0.5
1879
+ "
1880
+ def minPath(grid, k):
1881
+ """"""
1882
+ Given a grid with N rows and N columns (N >= 2) and a positive integer k,
1883
+ each cell of the grid contains a value. Every integer in the range [1, N * N]
1884
+ inclusive appears exactly once on the cells of the grid.
1885
+
1886
+ You have to find the minimum path of length k in the grid. You can start
1887
+ from any cell, and in each step you can move to any of the neighbor cells,
1888
+ in other words, you can go to cells which share an edge with you current
1889
+ cell.
1890
+ Please note that a path of length k means visiting exactly k cells (not
1891
+ necessarily distinct).
1892
+ You CANNOT go off the grid.
1893
+ A path A (of length k) is considered less than a path B (of length k) if
1894
+ after making the ordered lists of the values on the cells that A and B go
1895
+ through (let's call them lst_A and lst_B), lst_A is lexicographically less
1896
+ than lst_B, in other words, there exist an integer index i (1 <= i <= k)
1897
+ such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
1898
+ lst_A[j] = lst_B[j].
1899
+ It is guaranteed that the answer is unique.
1900
+ Return an ordered list of the values on the cells that the minimum path go through.
1901
+
1902
+ Examples:
1903
+
1904
+ Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
1905
+ Output: [1, 2, 1]
1906
+
1907
+ Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
1908
+ Output: [1]
1909
+ """"""
1910
+ ",0.0,0.0,0.0
1911
+ "
1912
+ def tri(n):
1913
+ """"""Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
1914
+ the last couple centuries. However, what people don't know is Tribonacci sequence.
1915
+ Tribonacci sequence is defined by the recurrence:
1916
+ tri(1) = 3
1917
+ tri(n) = 1 + n / 2, if n is even.
1918
+ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
1919
+ For example:
1920
+ tri(2) = 1 + (2 / 2) = 2
1921
+ tri(4) = 3
1922
+ tri(3) = tri(2) + tri(1) + tri(4)
1923
+ = 2 + 3 + 3 = 8
1924
+ You are given a non-negative integer number n, you have to a return a list of the
1925
+ first n + 1 numbers of the Tribonacci sequence.
1926
+ Examples:
1927
+ tri(3) = [1, 3, 2, 8]
1928
+ """"""
1929
+ ",0.0,0.0,0.0
1930
+ "
1931
+ def digits(n):
1932
+ """"""Given a positive integer n, return the product of the odd digits.
1933
+ Return 0 if all digits are even.
1934
+ For example:
1935
+ digits(1) == 1
1936
+ digits(4) == 0
1937
+ digits(235) == 15
1938
+ """"""
1939
+ ",0.0,0.0,0.0
1940
+ "
1941
+ def is_nested(string):
1942
+ '''
1943
+ Create a function that takes a string as input which contains only square brackets.
1944
+ The function should return True if and only if there is a valid subsequence of brackets
1945
+ where at least one bracket in the subsequence is nested.
1946
+
1947
+ is_nested('[[]]') ➞ True
1948
+ is_nested('[]]]]]]][[[[[]') ➞ False
1949
+ is_nested('[][]') ➞ False
1950
+ is_nested('[]') ➞ False
1951
+ is_nested('[[][]]') ➞ True
1952
+ is_nested('[[]][[') ➞ True
1953
+ '''
1954
+ ",0.0,0.0,0.0
1955
+ "
1956
+
1957
+ def sum_squares(lst):
1958
+ """"""You are given a list of numbers.
1959
+ You need to return the sum of squared numbers in the given list,
1960
+ round each element in the list to the upper int(Ceiling) first.
1961
+ Examples:
1962
+ For lst = [1,2,3] the output should be 14
1963
+ For lst = [1,4,9] the output should be 98
1964
+ For lst = [1,3,5,7] the output should be 84
1965
+ For lst = [1.4,4.2,0] the output should be 29
1966
+ For lst = [-2.4,1,1] the output should be 6
1967
+
1968
+
1969
+ """"""
1970
+ ",0.0,0.0,0.0
1971
+ "
1972
+ def check_if_last_char_is_a_letter(txt):
1973
+ '''
1974
+ Create a function that returns True if the last character
1975
+ of a given string is an alphabetical character and is not
1976
+ a part of a word, and False otherwise.
1977
+ Note: ""word"" is a group of characters separated by space.
1978
+
1979
+ Examples:
1980
+ check_if_last_char_is_a_letter(""apple pie"") ➞ False
1981
+ check_if_last_char_is_a_letter(""apple pi e"") ➞ True
1982
+ check_if_last_char_is_a_letter(""apple pi e "") ➞ False
1983
+ check_if_last_char_is_a_letter("""") ➞ False
1984
+ '''
1985
+ ",0.0,0.0,0.0
1986
+ "
1987
+ def can_arrange(arr):
1988
+ """"""Create a function which returns the largest index of an element which
1989
+ is not greater than or equal to the element immediately preceding it. If
1990
+ no such element exists then return -1. The given array will not contain
1991
+ duplicate values.
1992
+
1993
+ Examples:
1994
+ can_arrange([1,2,4,3,5]) = 3
1995
+ can_arrange([1,2,3]) = -1
1996
+ """"""
1997
+ ",0.0,0.0,0.0
1998
+ "
1999
+ def largest_smallest_integers(lst):
2000
+ '''
2001
+ Create a function that returns a tuple (a, b), where 'a' is
2002
+ the largest of negative integers, and 'b' is the smallest
2003
+ of positive integers in a list.
2004
+ If there is no negative or positive integers, return them as None.
2005
+
2006
+ Examples:
2007
+ largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
2008
+ largest_smallest_integers([]) == (None, None)
2009
+ largest_smallest_integers([0]) == (None, None)
2010
+ '''
2011
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
2012
+ "
2013
+ def compare_one(a, b):
2014
+ """"""
2015
+ Create a function that takes integers, floats, or strings representing
2016
+ real numbers, and returns the larger variable in its given variable type.
2017
+ Return None if the values are equal.
2018
+ Note: If a real number is represented as a string, the floating point might be . or ,
2019
+
2020
+ compare_one(1, 2.5) ➞ 2.5
2021
+ compare_one(1, ""2,3"") ➞ ""2,3""
2022
+ compare_one(""5,1"", ""6"") ➞ ""6""
2023
+ compare_one(""1"", 1) ➞ None
2024
+ """"""
2025
+ ",0.0,0.0,0.0
2026
+ "
2027
+ def is_equal_to_sum_even(n):
2028
+ """"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
2029
+ Example
2030
+ is_equal_to_sum_even(4) == False
2031
+ is_equal_to_sum_even(6) == False
2032
+ is_equal_to_sum_even(8) == True
2033
+ """"""
2034
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2035
+ "
2036
+ def special_factorial(n):
2037
+ """"""The Brazilian factorial is defined as:
2038
+ brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
2039
+ where n > 0
2040
+
2041
+ For example:
2042
+ >>> special_factorial(4)
2043
+ 288
2044
+
2045
+ The function will receive an integer as input and should return the special
2046
+ factorial of this integer.
2047
+ """"""
2048
+ ",0.0,0.0,0.0
2049
+ "
2050
+ def fix_spaces(text):
2051
+ """"""
2052
+ Given a string text, replace all spaces in it with underscores,
2053
+ and if a string has more than 2 consecutive spaces,
2054
+ then replace all consecutive spaces with -
2055
+
2056
+ fix_spaces(""Example"") == ""Example""
2057
+ fix_spaces(""Example 1"") == ""Example_1""
2058
+ fix_spaces("" Example 2"") == ""_Example_2""
2059
+ fix_spaces("" Example 3"") == ""_Example-3""
2060
+ """"""
2061
+ ",0.0,0.0,0.0
2062
+ "
2063
+ def file_name_check(file_name):
2064
+ """"""Create a function which takes a string representing a file's name, and returns
2065
+ 'Yes' if the the file's name is valid, and returns 'No' otherwise.
2066
+ A file's name is considered to be valid if and only if all the following conditions
2067
+ are met:
2068
+ - There should not be more than three digits ('0'-'9') in the file's name.
2069
+ - The file's name contains exactly one dot '.'
2070
+ - The substring before the dot should not be empty, and it starts with a letter from
2071
+ the latin alphapet ('a'-'z' and 'A'-'Z').
2072
+ - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
2073
+ Examples:
2074
+ file_name_check(""example.txt"") # => 'Yes'
2075
+ file_name_check(""1example.dll"") # => 'No' (the name should start with a latin alphapet letter)
2076
+ """"""
2077
+ ",0.0,0.0,0.0
2078
+ "
2079
+
2080
+
2081
+ def sum_squares(lst):
2082
+ """"""""
2083
+ 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
2084
+ 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
2085
+ 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.
2086
+
2087
+ Examples:
2088
+ For lst = [1,2,3] the output should be 6
2089
+ For lst = [] the output should be 0
2090
+ For lst = [-1,-5,2,-1,-5] the output should be -126
2091
+ """"""
2092
+ ",0.0,0.0,0.0
2093
+ "
2094
+ def words_in_sentence(sentence):
2095
+ """"""
2096
+ You are given a string representing a sentence,
2097
+ the sentence contains some words separated by a space,
2098
+ and you have to return a string that contains the words from the original sentence,
2099
+ whose lengths are prime numbers,
2100
+ the order of the words in the new string should be the same as the original one.
2101
+
2102
+ Example 1:
2103
+ Input: sentence = ""This is a test""
2104
+ Output: ""is""
2105
+
2106
+ Example 2:
2107
+ Input: sentence = ""lets go for swimming""
2108
+ Output: ""go for""
2109
+
2110
+ Constraints:
2111
+ * 1 <= len(sentence) <= 100
2112
+ * sentence contains only letters
2113
+ """"""
2114
+ ",0.5499999999999998,0.9918730650154799,1.0
2115
+ "
2116
+ def simplify(x, n):
2117
+ """"""Your task is to implement a function that will simplify the expression
2118
+ x * n. The function returns True if x * n evaluates to a whole number and False
2119
+ otherwise. Both x and n, are string representation of a fraction, and have the following format,
2120
+ <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
2121
+
2122
+ You can assume that x, and n are valid fractions, and do not have zero as denominator.
2123
+
2124
+ simplify(""1/5"", ""5/1"") = True
2125
+ simplify(""1/6"", ""2/1"") = False
2126
+ simplify(""7/10"", ""10/2"") = False
2127
+ """"""
2128
+ ",0.0,0.0,0.0
2129
+ "
2130
+ def order_by_points(nums):
2131
+ """"""
2132
+ Write a function which sorts the given list of integers
2133
+ in ascending order according to the sum of their digits.
2134
+ Note: if there are several items with similar sum of their digits,
2135
+ order them based on their index in original list.
2136
+
2137
+ For example:
2138
+ >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
2139
+ >>> order_by_points([]) == []
2140
+ """"""
2141
+ ",0.0,0.0,0.0
2142
+ "
2143
+ def specialFilter(nums):
2144
+ """"""Write a function that takes an array of numbers as input and returns
2145
+ the number of elements in the array that are greater than 10 and both
2146
+ first and last digits of a number are odd (1, 3, 5, 7, 9).
2147
+ For example:
2148
+ specialFilter([15, -73, 14, -15]) => 1
2149
+ specialFilter([33, -2, -3, 45, 21, 109]) => 2
2150
+ """"""
2151
+ ",0.25,0.8063080495356036,0.9837461300309598
2152
+ "
2153
+ def get_max_triples(n):
2154
+ """"""
2155
+ You are given a positive integer n. You have to create an integer array a of length n.
2156
+ For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
2157
+ Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
2158
+ and a[i] + a[j] + a[k] is a multiple of 3.
2159
+
2160
+ Example :
2161
+ Input: n = 5
2162
+ Output: 1
2163
+ Explanation:
2164
+ a = [1, 3, 7, 13, 21]
2165
+ The only valid triple is (1, 7, 13).
2166
+ """"""
2167
+ ",0.0,0.0,0.0
2168
+ "
2169
+ def bf(planet1, planet2):
2170
+ '''
2171
+ There are eight planets in our solar system: the closerst to the Sun
2172
+ is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
2173
+ Uranus, Neptune.
2174
+ Write a function that takes two planet names as strings planet1 and planet2.
2175
+ The function should return a tuple containing all planets whose orbits are
2176
+ located between the orbit of planet1 and the orbit of planet2, sorted by
2177
+ the proximity to the sun.
2178
+ The function should return an empty tuple if planet1 or planet2
2179
+ are not correct planet names.
2180
+ Examples
2181
+ bf(""Jupiter"", ""Neptune"") ==> (""Saturn"", ""Uranus"")
2182
+ bf(""Earth"", ""Mercury"") ==> (""Venus"")
2183
+ bf(""Mercury"", ""Uranus"") ==> (""Venus"", ""Earth"", ""Mars"", ""Jupiter"", ""Saturn"")
2184
+ '''
2185
+ ",0.95,1.0,1.0
2186
+ "
2187
+ def sorted_list_sum(lst):
2188
+ """"""Write a function that accepts a list of strings as a parameter,
2189
+ deletes the strings that have odd lengths from it,
2190
+ and returns the resulted list with a sorted order,
2191
+ The list is always a list of strings and never an array of numbers,
2192
+ and it may contain duplicates.
2193
+ The order of the list should be ascending by length of each word, and you
2194
+ should return the list sorted by that rule.
2195
+ If two words have the same length, sort the list alphabetically.
2196
+ The function should return a list of strings in sorted order.
2197
+ You may assume that all words will have the same length.
2198
+ For example:
2199
+ assert list_sort([""aa"", ""a"", ""aaa""]) => [""aa""]
2200
+ assert list_sort([""ab"", ""a"", ""aaa"", ""cd""]) => [""ab"", ""cd""]
2201
+ """"""
2202
+ ",0.050000000000000044,0.25,0.5
2203
+ "
2204
+ def x_or_y(n, x, y):
2205
+ """"""A simple program which should return the value of x if n is
2206
+ a prime number and should return the value of y otherwise.
2207
+
2208
+ Examples:
2209
+ for x_or_y(7, 34, 12) == 34
2210
+ for x_or_y(15, 8, 5) == 5
2211
+
2212
+ """"""
2213
+ ",0.050000000000000044,0.25,0.5
2214
+ "
2215
+ def double_the_difference(lst):
2216
+ '''
2217
+ Given a list of numbers, return the sum of squares of the numbers
2218
+ in the list that are odd. Ignore numbers that are negative or not integers.
2219
+
2220
+ double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
2221
+ double_the_difference([-1, -2, 0]) == 0
2222
+ double_the_difference([9, -2]) == 81
2223
+ double_the_difference([0]) == 0
2224
+
2225
+ If the input list is empty, return 0.
2226
+ '''
2227
+ ",0.7,0.9996130030959752,1.0
2228
+ "
2229
+ def compare(game,guess):
2230
+ """"""I think we all remember that feeling when the result of some long-awaited
2231
+ event is finally known. The feelings and thoughts you have at that moment are
2232
+ definitely worth noting down and comparing.
2233
+ Your task is to determine if a person correctly guessed the results of a number of matches.
2234
+ You are given two arrays of scores and guesses of equal length, where each index shows a match.
2235
+ Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
2236
+ the value is 0, and if not, the value is the absolute difference between the guess and the score.
2237
+
2238
+
2239
+ example:
2240
+
2241
+ compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
2242
+ compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
2243
+ """"""
2244
+ ",0.85,1.0,1.0
2245
+ "
2246
+ def Strongest_Extension(class_name, extensions):
2247
+ """"""You will be given the name of a class (a string) and a list of extensions.
2248
+ The extensions are to be used to load additional classes to the class. The
2249
+ strength of the extension is as follows: Let CAP be the number of the uppercase
2250
+ letters in the extension's name, and let SM be the number of lowercase letters
2251
+ in the extension's name, the strength is given by the fraction CAP - SM.
2252
+ You should find the strongest extension and return a string in this
2253
+ format: ClassName.StrongestExtensionName.
2254
+ If there are two or more extensions with the same strength, you should
2255
+ choose the one that comes first in the list.
2256
+ For example, if you are given ""Slices"" as the class and a list of the
2257
+ extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
2258
+ return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
2259
+ (its strength is -1).
2260
+ Example:
2261
+ for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
2262
+ """"""
2263
+ ",0.0,0.0,0.0
2264
+ "
2265
+ def cycpattern_check(a , b):
2266
+ """"""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
2267
+ cycpattern_check(""abcd"",""abd"") => False
2268
+ cycpattern_check(""hello"",""ell"") => True
2269
+ cycpattern_check(""whassup"",""psus"") => False
2270
+ cycpattern_check(""abab"",""baa"") => True
2271
+ cycpattern_check(""efef"",""eeff"") => False
2272
+ cycpattern_check(""himenss"",""simen"") => True
2273
+
2274
+ """"""
2275
+ ",0.0,0.0,0.0
2276
+ "
2277
+ def even_odd_count(num):
2278
+ """"""Given an integer. return a tuple that has the number of even and odd digits respectively.
2279
+
2280
+ Example:
2281
+ even_odd_count(-12) ==> (1, 1)
2282
+ even_odd_count(123) ==> (1, 2)
2283
+ """"""
2284
+ ",0.5499999999999998,0.9918730650154799,1.0
2285
+ "
2286
+ def int_to_mini_roman(number):
2287
+ """"""
2288
+ Given a positive integer, obtain its roman numeral equivalent as a string,
2289
+ and return it in lowercase.
2290
+ Restrictions: 1 <= num <= 1000
2291
+
2292
+ Examples:
2293
+ >>> int_to_mini_roman(19) == 'xix'
2294
+ >>> int_to_mini_roman(152) == 'clii'
2295
+ >>> int_to_mini_roman(426) == 'cdxxvi'
2296
+ """"""
2297
+ ",0.5499999999999998,0.9918730650154799,1.0
2298
+ "
2299
+ def right_angle_triangle(a, b, c):
2300
+ '''
2301
+ Given the lengths of the three sides of a triangle. Return True if the three
2302
+ sides form a right-angled triangle, False otherwise.
2303
+ A right-angled triangle is a triangle in which one angle is right angle or
2304
+ 90 degree.
2305
+ Example:
2306
+ right_angle_triangle(3, 4, 5) == True
2307
+ right_angle_triangle(1, 2, 3) == False
2308
+ '''
2309
+ ",0.4,0.9489164086687306,0.9996427720885925
2310
+ "
2311
+ def find_max(words):
2312
+ """"""Write a function that accepts a list of strings.
2313
+ The list contains different words. Return the word with maximum number
2314
+ of unique characters. If multiple strings have maximum number of unique
2315
+ characters, return the one which comes first in lexicographical order.
2316
+
2317
+ find_max([""name"", ""of"", ""string""]) == ""string""
2318
+ find_max([""name"", ""enam"", ""game""]) == ""enam""
2319
+ find_max([""aaaaaaa"", ""bb"" ,""cc""]) == """"aaaaaaa""
2320
+ """"""
2321
+ ",1.0,1.0,1.0
2322
+ "
2323
+ def eat(number, need, remaining):
2324
+ """"""
2325
+ You're a hungry rabbit, and you already have eaten a certain number of carrots,
2326
+ but now you need to eat more carrots to complete the day's meals.
2327
+ you should return an array of [ total number of eaten carrots after your meals,
2328
+ the number of carrots left after your meals ]
2329
+ if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
2330
+
2331
+ Example:
2332
+ * eat(5, 6, 10) -> [11, 4]
2333
+ * eat(4, 8, 9) -> [12, 1]
2334
+ * eat(1, 10, 10) -> [11, 0]
2335
+ * eat(2, 11, 5) -> [7, 0]
2336
+
2337
+ Variables:
2338
+ @number : integer
2339
+ the number of carrots that you have eaten.
2340
+ @need : integer
2341
+ the number of carrots that you need to eat.
2342
+ @remaining : integer
2343
+ the number of remaining carrots thet exist in stock
2344
+
2345
+ Constrain:
2346
+ * 0 <= number <= 1000
2347
+ * 0 <= need <= 1000
2348
+ * 0 <= remaining <= 1000
2349
+
2350
+ Have fun :)
2351
+ """"""
2352
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
2353
+ "
2354
+ def do_algebra(operator, operand):
2355
+ """"""
2356
+ Given two lists operator, and operand. The first list has basic algebra operations, and
2357
+ the second list is a list of integers. Use the two given lists to build the algebric
2358
+ expression and return the evaluation of this expression.
2359
+
2360
+ The basic algebra operations:
2361
+ Addition ( + )
2362
+ Subtraction ( - )
2363
+ Multiplication ( * )
2364
+ Floor division ( // )
2365
+ Exponentiation ( ** )
2366
+
2367
+ Example:
2368
+ operator['+', '*', '-']
2369
+ array = [2, 3, 4, 5]
2370
+ result = 2 + 3 * 4 - 5
2371
+ => result = 9
2372
+
2373
+ Note:
2374
+ The length of operator list is equal to the length of operand list minus one.
2375
+ Operand is a list of of non-negative integers.
2376
+ Operator list has at least one operator, and operand list has at least two operands.
2377
+
2378
+ """"""
2379
+ ",0.0,0.0,0.0
2380
+ "
2381
+ def solve(s):
2382
+ """"""You are given a string s.
2383
+ if s[i] is a letter, reverse its case from lower to upper or vise versa,
2384
+ otherwise keep it as it is.
2385
+ If the string contains no letters, reverse the string.
2386
+ The function should return the resulted string.
2387
+ Examples
2388
+ solve(""1234"") = ""4321""
2389
+ solve(""ab"") = ""AB""
2390
+ solve(""#a@C"") = ""#A@c""
2391
+ """"""
2392
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2393
+ "
2394
+ def string_to_md5(text):
2395
+ """"""
2396
+ Given a string 'text', return its md5 hash equivalent string.
2397
+ If 'text' is an empty string, return None.
2398
+
2399
+ >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
2400
+ """"""
2401
+ ",0.65,0.9986455108359134,1.0
2402
+ "
2403
+ def generate_integers(a, b):
2404
+ """"""
2405
+ Given two positive integers a and b, return the even digits between a
2406
+ and b, in ascending order.
2407
+
2408
+ For example:
2409
+ generate_integers(2, 8) => [2, 4, 6, 8]
2410
+ generate_integers(8, 2) => [2, 4, 6, 8]
2411
+ generate_integers(10, 14) => []
2412
+ """"""
2413
+ ",0.0,0.0,0.0
data/coding/humaneval/csv/2.csv ADDED
@@ -0,0 +1,2413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt,pass@1,pass@5,pass@10
2
+ "from typing import List
3
+
4
+
5
+ def has_close_elements(numbers: List[float], threshold: float) -> bool:
6
+ """""" Check if in given list of numbers, are any two numbers closer to each other than
7
+ given threshold.
8
+ >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
9
+ False
10
+ >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
11
+ True
12
+ """"""
13
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
14
+ "from typing import List
15
+
16
+
17
+ def separate_paren_groups(paren_string: str) -> List[str]:
18
+ """""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
19
+ separate those group into separate strings and return the list of those.
20
+ Separate groups are balanced (each open brace is properly closed) and not nested within each other
21
+ Ignore any spaces in the input string.
22
+ >>> separate_paren_groups('( ) (( )) (( )( ))')
23
+ ['()', '(())', '(()())']
24
+ """"""
25
+ ",0.0,0.0,0.0
26
+ "
27
+
28
+ def truncate_number(number: float) -> float:
29
+ """""" Given a positive floating point number, it can be decomposed into
30
+ and integer part (largest integer smaller than given number) and decimals
31
+ (leftover part always smaller than 1).
32
+
33
+ Return the decimal part of the number.
34
+ >>> truncate_number(3.5)
35
+ 0.5
36
+ """"""
37
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
38
+ "from typing import List
39
+
40
+
41
+ def below_zero(operations: List[int]) -> bool:
42
+ """""" You're given a list of deposit and withdrawal operations on a bank account that starts with
43
+ zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
44
+ at that point function should return True. Otherwise it should return False.
45
+ >>> below_zero([1, 2, 3])
46
+ False
47
+ >>> below_zero([1, 2, -4, 5])
48
+ True
49
+ """"""
50
+ ",1.0,1.0,1.0
51
+ "from typing import List
52
+
53
+
54
+ def mean_absolute_deviation(numbers: List[float]) -> float:
55
+ """""" For a given list of input numbers, calculate Mean Absolute Deviation
56
+ around the mean of this dataset.
57
+ Mean Absolute Deviation is the average absolute difference between each
58
+ element and a centerpoint (mean in this case):
59
+ MAD = average | x - x_mean |
60
+ >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
61
+ 1.0
62
+ """"""
63
+ ",0.95,1.0,1.0
64
+ "from typing import List
65
+
66
+
67
+ def intersperse(numbers: List[int], delimeter: int) -> List[int]:
68
+ """""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
69
+ >>> intersperse([], 4)
70
+ []
71
+ >>> intersperse([1, 2, 3], 4)
72
+ [1, 4, 2, 4, 3]
73
+ """"""
74
+ ",0.0,0.0,0.0
75
+ "from typing import List
76
+
77
+
78
+ def parse_nested_parens(paren_string: str) -> List[int]:
79
+ """""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
80
+ For each of the group, output the deepest level of nesting of parentheses.
81
+ E.g. (()()) has maximum two levels of nesting while ((())) has three.
82
+
83
+ >>> parse_nested_parens('(()()) ((())) () ((())()())')
84
+ [2, 3, 1, 3]
85
+ """"""
86
+ ",0.25,0.8063080495356036,0.9837461300309598
87
+ "from typing import List
88
+
89
+
90
+ def filter_by_substring(strings: List[str], substring: str) -> List[str]:
91
+ """""" Filter an input list of strings only for ones that contain given substring
92
+ >>> filter_by_substring([], 'a')
93
+ []
94
+ >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
95
+ ['abc', 'bacd', 'array']
96
+ """"""
97
+ ",1.0,1.0,1.0
98
+ "from typing import List, Tuple
99
+
100
+
101
+ def sum_product(numbers: List[int]) -> Tuple[int, int]:
102
+ """""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
103
+ Empty sum should be equal to 0 and empty product should be equal to 1.
104
+ >>> sum_product([])
105
+ (0, 1)
106
+ >>> sum_product([1, 2, 3, 4])
107
+ (10, 24)
108
+ """"""
109
+ ",1.0,1.0,1.0
110
+ "from typing import List, Tuple
111
+
112
+
113
+ def rolling_max(numbers: List[int]) -> List[int]:
114
+ """""" From a given list of integers, generate a list of rolling maximum element found until given moment
115
+ in the sequence.
116
+ >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
117
+ [1, 2, 3, 3, 3, 4, 4]
118
+ """"""
119
+ ",0.25,0.8063080495356036,0.9837461300309598
120
+ "
121
+
122
+ def is_palindrome(string: str) -> bool:
123
+ """""" Test if given string is a palindrome """"""
124
+ return string == string[::-1]
125
+
126
+
127
+ def make_palindrome(string: str) -> str:
128
+ """""" Find the shortest palindrome that begins with a supplied string.
129
+ Algorithm idea is simple:
130
+ - Find the longest postfix of supplied string that is a palindrome.
131
+ - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
132
+ >>> make_palindrome('')
133
+ ''
134
+ >>> make_palindrome('cat')
135
+ 'catac'
136
+ >>> make_palindrome('cata')
137
+ 'catac'
138
+ """"""
139
+ ",0.0,0.0,0.0
140
+ "from typing import List
141
+
142
+
143
+ def string_xor(a: str, b: str) -> str:
144
+ """""" Input are two strings a and b consisting only of 1s and 0s.
145
+ Perform binary XOR on these inputs and return result also as a string.
146
+ >>> string_xor('010', '110')
147
+ '100'
148
+ """"""
149
+ ",0.7,0.9996130030959752,1.0
150
+ "from typing import List, Optional
151
+
152
+
153
+ def longest(strings: List[str]) -> Optional[str]:
154
+ """""" Out of list of strings, return the longest one. Return the first one in case of multiple
155
+ strings of the same length. Return None in case the input list is empty.
156
+ >>> longest([])
157
+
158
+ >>> longest(['a', 'b', 'c'])
159
+ 'a'
160
+ >>> longest(['a', 'bb', 'ccc'])
161
+ 'ccc'
162
+ """"""
163
+ ",1.0,1.0,1.0
164
+ "
165
+
166
+ def greatest_common_divisor(a: int, b: int) -> int:
167
+ """""" Return a greatest common divisor of two integers a and b
168
+ >>> greatest_common_divisor(3, 5)
169
+ 1
170
+ >>> greatest_common_divisor(25, 15)
171
+ 5
172
+ """"""
173
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
174
+ "from typing import List
175
+
176
+
177
+ def all_prefixes(string: str) -> List[str]:
178
+ """""" Return list of all prefixes from shortest to longest of the input string
179
+ >>> all_prefixes('abc')
180
+ ['a', 'ab', 'abc']
181
+ """"""
182
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
183
+ "
184
+
185
+ def string_sequence(n: int) -> str:
186
+ """""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
187
+ >>> string_sequence(0)
188
+ '0'
189
+ >>> string_sequence(5)
190
+ '0 1 2 3 4 5'
191
+ """"""
192
+ ",0.75,0.9999355005159959,1.0
193
+ "
194
+
195
+ def count_distinct_characters(string: str) -> int:
196
+ """""" Given a string, find out how many distinct characters (regardless of case) does it consist of
197
+ >>> count_distinct_characters('xyzXYZ')
198
+ 3
199
+ >>> count_distinct_characters('Jerry')
200
+ 4
201
+ """"""
202
+ ",0.6000000000000001,0.9963880288957688,1.0
203
+ "from typing import List
204
+
205
+
206
+ def parse_music(music_string: str) -> List[int]:
207
+ """""" Input to this function is a string representing musical notes in a special ASCII format.
208
+ Your task is to parse this string and return list of integers corresponding to how many beats does each
209
+ not last.
210
+
211
+ Here is a legend:
212
+ 'o' - whole note, lasts four beats
213
+ 'o|' - half note, lasts two beats
214
+ '.|' - quater note, lasts one beat
215
+
216
+ >>> parse_music('o o| .| o| o| .| .| .| .| o o')
217
+ [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
218
+ """"""
219
+ ",0.75,0.9999355005159959,1.0
220
+ "
221
+
222
+ def how_many_times(string: str, substring: str) -> int:
223
+ """""" Find how many times a given substring can be found in the original string. Count overlaping cases.
224
+ >>> how_many_times('', 'a')
225
+ 0
226
+ >>> how_many_times('aaa', 'a')
227
+ 3
228
+ >>> how_many_times('aaaa', 'aa')
229
+ 3
230
+ """"""
231
+ ",0.75,0.9999355005159959,1.0
232
+ "from typing import List
233
+
234
+
235
+ def sort_numbers(numbers: str) -> str:
236
+ """""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
237
+ Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
238
+ Return the string with numbers sorted from smallest to largest
239
+ >>> sort_numbers('three one five')
240
+ 'one three five'
241
+ """"""
242
+ ",0.0,0.0,0.0
243
+ "from typing import List, Tuple
244
+
245
+
246
+ def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
247
+ """""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
248
+ other and return them in order (smaller number, larger number).
249
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
250
+ (2.0, 2.2)
251
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
252
+ (2.0, 2.0)
253
+ """"""
254
+ ",0.6000000000000001,0.9963880288957688,1.0
255
+ "from typing import List
256
+
257
+
258
+ def rescale_to_unit(numbers: List[float]) -> List[float]:
259
+ """""" Given list of numbers (of at least two elements), apply a linear transform to that list,
260
+ such that the smallest number will become 0 and the largest will become 1
261
+ >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
262
+ [0.0, 0.25, 0.5, 0.75, 1.0]
263
+ """"""
264
+ ",0.8999999999999999,1.0,1.0
265
+ "from typing import List, Any
266
+
267
+
268
+ def filter_integers(values: List[Any]) -> List[int]:
269
+ """""" Filter given list of any python values only for integers
270
+ >>> filter_integers(['a', 3.14, 5])
271
+ [5]
272
+ >>> filter_integers([1, 2, 3, 'abc', {}, []])
273
+ [1, 2, 3]
274
+ """"""
275
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
276
+ "
277
+
278
+ def strlen(string: str) -> int:
279
+ """""" Return length of given string
280
+ >>> strlen('')
281
+ 0
282
+ >>> strlen('abc')
283
+ 3
284
+ """"""
285
+ ",0.75,0.9999355005159959,1.0
286
+ "
287
+
288
+ def largest_divisor(n: int) -> int:
289
+ """""" For a given number n, find the largest number that divides n evenly, smaller than n
290
+ >>> largest_divisor(15)
291
+ 5
292
+ """"""
293
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
294
+ "from typing import List
295
+
296
+
297
+ def factorize(n: int) -> List[int]:
298
+ """""" Return list of prime factors of given integer in the order from smallest to largest.
299
+ Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
300
+ Input number should be equal to the product of all factors
301
+ >>> factorize(8)
302
+ [2, 2, 2]
303
+ >>> factorize(25)
304
+ [5, 5]
305
+ >>> factorize(70)
306
+ [2, 5, 7]
307
+ """"""
308
+ ",1.0,1.0,1.0
309
+ "from typing import List
310
+
311
+
312
+ def remove_duplicates(numbers: List[int]) -> List[int]:
313
+ """""" From a list of integers, remove all elements that occur more than once.
314
+ Keep order of elements left the same as in the input.
315
+ >>> remove_duplicates([1, 2, 3, 2, 4])
316
+ [1, 3, 4]
317
+ """"""
318
+ ",0.0,0.0,0.0
319
+ "
320
+
321
+ def flip_case(string: str) -> str:
322
+ """""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
323
+ >>> flip_case('Hello')
324
+ 'hELLO'
325
+ """"""
326
+ ",1.0,1.0,1.0
327
+ "from typing import List
328
+
329
+
330
+ def concatenate(strings: List[str]) -> str:
331
+ """""" Concatenate list of strings into a single string
332
+ >>> concatenate([])
333
+ ''
334
+ >>> concatenate(['a', 'b', 'c'])
335
+ 'abc'
336
+ """"""
337
+ ",0.65,0.9986455108359134,1.0
338
+ "from typing import List
339
+
340
+
341
+ def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
342
+ """""" Filter an input list of strings only for ones that start with a given prefix.
343
+ >>> filter_by_prefix([], 'a')
344
+ []
345
+ >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
346
+ ['abc', 'array']
347
+ """"""
348
+ ",0.8999999999999999,1.0,1.0
349
+ "
350
+
351
+ def get_positive(l: list):
352
+ """"""Return only positive numbers in the list.
353
+ >>> get_positive([-1, 2, -4, 5, 6])
354
+ [2, 5, 6]
355
+ >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
356
+ [5, 3, 2, 3, 9, 123, 1]
357
+ """"""
358
+ ",0.65,0.9986455108359134,1.0
359
+ "
360
+
361
+ def is_prime(n):
362
+ """"""Return true if a given number is prime, and false otherwise.
363
+ >>> is_prime(6)
364
+ False
365
+ >>> is_prime(101)
366
+ True
367
+ >>> is_prime(11)
368
+ True
369
+ >>> is_prime(13441)
370
+ True
371
+ >>> is_prime(61)
372
+ True
373
+ >>> is_prime(4)
374
+ False
375
+ >>> is_prime(1)
376
+ False
377
+ """"""
378
+ ",0.65,0.9986455108359134,1.0
379
+ "import math
380
+
381
+
382
+ def poly(xs: list, x: float):
383
+ """"""
384
+ Evaluates polynomial with coefficients xs at point x.
385
+ return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
386
+ """"""
387
+ return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])
388
+
389
+
390
+ def find_zero(xs: list):
391
+ """""" xs are coefficients of a polynomial.
392
+ find_zero find x such that poly(x) = 0.
393
+ find_zero returns only only zero point, even if there are many.
394
+ Moreover, find_zero only takes list xs having even number of coefficients
395
+ and largest non zero coefficient as it guarantees
396
+ a solution.
397
+ >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
398
+ -0.5
399
+ >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
400
+ 1.0
401
+ """"""
402
+ ",0.0,0.0,0.0
403
+ "
404
+
405
+ def sort_third(l: list):
406
+ """"""This function takes a list l and returns a list l' such that
407
+ 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
408
+ to the values of the corresponding indicies of l, but sorted.
409
+ >>> sort_third([1, 2, 3])
410
+ [1, 2, 3]
411
+ >>> sort_third([5, 6, 3, 4, 8, 9, 2])
412
+ [2, 6, 3, 4, 8, 9, 5]
413
+ """"""
414
+ ",0.0,0.0,0.0
415
+ "
416
+
417
+ def unique(l: list):
418
+ """"""Return sorted unique elements in a list
419
+ >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
420
+ [0, 2, 3, 5, 9, 123]
421
+ """"""
422
+ ",0.6000000000000001,0.9963880288957688,1.0
423
+ "
424
+
425
+ def max_element(l: list):
426
+ """"""Return maximum element in the list.
427
+ >>> max_element([1, 2, 3])
428
+ 3
429
+ >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
430
+ 123
431
+ """"""
432
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
433
+ "
434
+
435
+ def fizz_buzz(n: int):
436
+ """"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
437
+ >>> fizz_buzz(50)
438
+ 0
439
+ >>> fizz_buzz(78)
440
+ 2
441
+ >>> fizz_buzz(79)
442
+ 3
443
+ """"""
444
+ ",0.25,0.8063080495356036,0.9837461300309598
445
+ "
446
+
447
+ def sort_even(l: list):
448
+ """"""This function takes a list l and returns a list l' such that
449
+ l' is identical to l in the odd indicies, while its values at the even indicies are equal
450
+ to the values of the even indicies of l, but sorted.
451
+ >>> sort_even([1, 2, 3])
452
+ [1, 2, 3]
453
+ >>> sort_even([5, 6, 3, 4])
454
+ [3, 6, 5, 4]
455
+ """"""
456
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
457
+ "
458
+
459
+ def encode_cyclic(s: str):
460
+ """"""
461
+ returns encoded string by cycling groups of three characters.
462
+ """"""
463
+ # split string to groups. Each of length 3.
464
+ groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
465
+ # cycle elements in each group. Unless group has fewer elements than 3.
466
+ groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
467
+ return """".join(groups)
468
+
469
+
470
+ def decode_cyclic(s: str):
471
+ """"""
472
+ takes as input string encoded with encode_cyclic function. Returns decoded string.
473
+ """"""
474
+ ",0.0,0.0,0.0
475
+ "
476
+
477
+ def prime_fib(n: int):
478
+ """"""
479
+ prime_fib returns n-th number that is a Fibonacci number and it's also prime.
480
+ >>> prime_fib(1)
481
+ 2
482
+ >>> prime_fib(2)
483
+ 3
484
+ >>> prime_fib(3)
485
+ 5
486
+ >>> prime_fib(4)
487
+ 13
488
+ >>> prime_fib(5)
489
+ 89
490
+ """"""
491
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
492
+ "
493
+
494
+ def triples_sum_to_zero(l: list):
495
+ """"""
496
+ triples_sum_to_zero takes a list of integers as an input.
497
+ it returns True if there are three distinct elements in the list that
498
+ sum to zero, and False otherwise.
499
+
500
+ >>> triples_sum_to_zero([1, 3, 5, 0])
501
+ False
502
+ >>> triples_sum_to_zero([1, 3, -2, 1])
503
+ True
504
+ >>> triples_sum_to_zero([1, 2, 3, 7])
505
+ False
506
+ >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
507
+ True
508
+ >>> triples_sum_to_zero([1])
509
+ False
510
+ """"""
511
+ ",0.7,0.9996130030959752,1.0
512
+ "
513
+
514
+ def car_race_collision(n: int):
515
+ """"""
516
+ Imagine a road that's a perfectly straight infinitely long line.
517
+ n cars are driving left to right; simultaneously, a different set of n cars
518
+ are driving right to left. The two sets of cars start out being very far from
519
+ each other. All cars move in the same speed. Two cars are said to collide
520
+ when a car that's moving left to right hits a car that's moving right to left.
521
+ However, the cars are infinitely sturdy and strong; as a result, they continue moving
522
+ in their trajectory as if they did not collide.
523
+
524
+ This function outputs the number of such collisions.
525
+ """"""
526
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
527
+ "
528
+
529
+ def incr_list(l: list):
530
+ """"""Return list with elements incremented by 1.
531
+ >>> incr_list([1, 2, 3])
532
+ [2, 3, 4]
533
+ >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
534
+ [6, 4, 6, 3, 4, 4, 10, 1, 124]
535
+ """"""
536
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
537
+ "
538
+
539
+ def pairs_sum_to_zero(l):
540
+ """"""
541
+ pairs_sum_to_zero takes a list of integers as an input.
542
+ it returns True if there are two distinct elements in the list that
543
+ sum to zero, and False otherwise.
544
+ >>> pairs_sum_to_zero([1, 3, 5, 0])
545
+ False
546
+ >>> pairs_sum_to_zero([1, 3, -2, 1])
547
+ False
548
+ >>> pairs_sum_to_zero([1, 2, 3, 7])
549
+ False
550
+ >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
551
+ True
552
+ >>> pairs_sum_to_zero([1])
553
+ False
554
+ """"""
555
+ ",0.95,1.0,1.0
556
+ "
557
+
558
+ def change_base(x: int, base: int):
559
+ """"""Change numerical base of input number x to base.
560
+ return string representation after the conversion.
561
+ base numbers are less than 10.
562
+ >>> change_base(8, 3)
563
+ '22'
564
+ >>> change_base(8, 2)
565
+ '1000'
566
+ >>> change_base(7, 2)
567
+ '111'
568
+ """"""
569
+ ",0.25,0.8063080495356036,0.9837461300309598
570
+ "
571
+
572
+ def triangle_area(a, h):
573
+ """"""Given length of a side and high return area for a triangle.
574
+ >>> triangle_area(5, 3)
575
+ 7.5
576
+ """"""
577
+ ",1.0,1.0,1.0
578
+ "
579
+
580
+ def fib4(n: int):
581
+ """"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
582
+ fib4(0) -> 0
583
+ fib4(1) -> 0
584
+ fib4(2) -> 2
585
+ fib4(3) -> 0
586
+ fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
587
+ Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
588
+ >>> fib4(5)
589
+ 4
590
+ >>> fib4(6)
591
+ 8
592
+ >>> fib4(7)
593
+ 14
594
+ """"""
595
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
596
+ "
597
+
598
+ def median(l: list):
599
+ """"""Return median of elements in the list l.
600
+ >>> median([3, 1, 2, 4, 5])
601
+ 3
602
+ >>> median([-10, 4, 6, 1000, 10, 20])
603
+ 15.0
604
+ """"""
605
+ ",0.95,1.0,1.0
606
+ "
607
+
608
+ def is_palindrome(text: str):
609
+ """"""
610
+ Checks if given string is a palindrome
611
+ >>> is_palindrome('')
612
+ True
613
+ >>> is_palindrome('aba')
614
+ True
615
+ >>> is_palindrome('aaaaa')
616
+ True
617
+ >>> is_palindrome('zbcd')
618
+ False
619
+ """"""
620
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
621
+ "
622
+
623
+ def modp(n: int, p: int):
624
+ """"""Return 2^n modulo p (be aware of numerics).
625
+ >>> modp(3, 5)
626
+ 3
627
+ >>> modp(1101, 101)
628
+ 2
629
+ >>> modp(0, 101)
630
+ 1
631
+ >>> modp(3, 11)
632
+ 8
633
+ >>> modp(100, 101)
634
+ 1
635
+ """"""
636
+ ",0.0,0.0,0.0
637
+ "
638
+
639
+ def encode_shift(s: str):
640
+ """"""
641
+ returns encoded string by shifting every character by 5 in the alphabet.
642
+ """"""
643
+ return """".join([chr(((ord(ch) + 5 - ord(""a"")) % 26) + ord(""a"")) for ch in s])
644
+
645
+
646
+ def decode_shift(s: str):
647
+ """"""
648
+ takes as input string encoded with encode_shift function. Returns decoded string.
649
+ """"""
650
+ ",1.0,1.0,1.0
651
+ "
652
+
653
+ def remove_vowels(text):
654
+ """"""
655
+ remove_vowels is a function that takes string and returns string without vowels.
656
+ >>> remove_vowels('')
657
+ ''
658
+ >>> remove_vowels(""abcdef\nghijklm"")
659
+ 'bcdf\nghjklm'
660
+ >>> remove_vowels('abcdef')
661
+ 'bcdf'
662
+ >>> remove_vowels('aaaaa')
663
+ ''
664
+ >>> remove_vowels('aaBAA')
665
+ 'B'
666
+ >>> remove_vowels('zbcd')
667
+ 'zbcd'
668
+ """"""
669
+ ",0.85,1.0,1.0
670
+ "
671
+
672
+ def below_threshold(l: list, t: int):
673
+ """"""Return True if all numbers in the list l are below threshold t.
674
+ >>> below_threshold([1, 2, 4, 10], 100)
675
+ True
676
+ >>> below_threshold([1, 20, 4, 10], 5)
677
+ False
678
+ """"""
679
+ ",0.65,0.9986455108359134,1.0
680
+ "
681
+
682
+ def add(x: int, y: int):
683
+ """"""Add two numbers x and y
684
+ >>> add(2, 3)
685
+ 5
686
+ >>> add(5, 7)
687
+ 12
688
+ """"""
689
+ ",0.8999999999999999,1.0,1.0
690
+ "
691
+
692
+ def same_chars(s0: str, s1: str):
693
+ """"""
694
+ Check if two words have the same characters.
695
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
696
+ True
697
+ >>> same_chars('abcd', 'dddddddabc')
698
+ True
699
+ >>> same_chars('dddddddabc', 'abcd')
700
+ True
701
+ >>> same_chars('eabcd', 'dddddddabc')
702
+ False
703
+ >>> same_chars('abcd', 'dddddddabce')
704
+ False
705
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
706
+ False
707
+ """"""
708
+ ",0.65,0.9986455108359134,1.0
709
+ "
710
+
711
+ def fib(n: int):
712
+ """"""Return n-th Fibonacci number.
713
+ >>> fib(10)
714
+ 55
715
+ >>> fib(1)
716
+ 1
717
+ >>> fib(8)
718
+ 21
719
+ """"""
720
+ ",0.65,0.9986455108359134,1.0
721
+ "
722
+
723
+ def correct_bracketing(brackets: str):
724
+ """""" brackets is a string of ""<"" and "">"".
725
+ return True if every opening bracket has a corresponding closing bracket.
726
+
727
+ >>> correct_bracketing(""<"")
728
+ False
729
+ >>> correct_bracketing(""<>"")
730
+ True
731
+ >>> correct_bracketing(""<<><>>"")
732
+ True
733
+ >>> correct_bracketing(""><<>"")
734
+ False
735
+ """"""
736
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
737
+ "
738
+
739
+ def monotonic(l: list):
740
+ """"""Return True is list elements are monotonically increasing or decreasing.
741
+ >>> monotonic([1, 2, 4, 20])
742
+ True
743
+ >>> monotonic([1, 20, 4, 10])
744
+ False
745
+ >>> monotonic([4, 1, 0, -10])
746
+ True
747
+ """"""
748
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
749
+ "
750
+
751
+ def common(l1: list, l2: list):
752
+ """"""Return sorted unique common elements for two lists.
753
+ >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
754
+ [1, 5, 653]
755
+ >>> common([5, 3, 2, 8], [3, 2])
756
+ [2, 3]
757
+
758
+ """"""
759
+ ",0.8999999999999999,1.0,1.0
760
+ "
761
+
762
+ def largest_prime_factor(n: int):
763
+ """"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
764
+ >>> largest_prime_factor(13195)
765
+ 29
766
+ >>> largest_prime_factor(2048)
767
+ 2
768
+ """"""
769
+ ",0.4,0.9489164086687306,0.9996427720885925
770
+ "
771
+
772
+ def sum_to_n(n: int):
773
+ """"""sum_to_n is a function that sums numbers from 1 to n.
774
+ >>> sum_to_n(30)
775
+ 465
776
+ >>> sum_to_n(100)
777
+ 5050
778
+ >>> sum_to_n(5)
779
+ 15
780
+ >>> sum_to_n(10)
781
+ 55
782
+ >>> sum_to_n(1)
783
+ 1
784
+ """"""
785
+ ",0.25,0.8063080495356036,0.9837461300309598
786
+ "
787
+
788
+ def correct_bracketing(brackets: str):
789
+ """""" brackets is a string of ""("" and "")"".
790
+ return True if every opening bracket has a corresponding closing bracket.
791
+
792
+ >>> correct_bracketing(""("")
793
+ False
794
+ >>> correct_bracketing(""()"")
795
+ True
796
+ >>> correct_bracketing(""(()())"")
797
+ True
798
+ >>> correct_bracketing("")(()"")
799
+ False
800
+ """"""
801
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
802
+ "
803
+
804
+ def derivative(xs: list):
805
+ """""" xs represent coefficients of a polynomial.
806
+ xs[0] + xs[1] * x + xs[2] * x^2 + ....
807
+ Return derivative of this polynomial in the same form.
808
+ >>> derivative([3, 1, 2, 4, 5])
809
+ [1, 4, 12, 20]
810
+ >>> derivative([1, 2, 3])
811
+ [2, 6]
812
+ """"""
813
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
814
+ "
815
+
816
+ def fibfib(n: int):
817
+ """"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
818
+ fibfib(0) == 0
819
+ fibfib(1) == 0
820
+ fibfib(2) == 1
821
+ fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
822
+ Please write a function to efficiently compute the n-th element of the fibfib number sequence.
823
+ >>> fibfib(1)
824
+ 0
825
+ >>> fibfib(5)
826
+ 4
827
+ >>> fibfib(8)
828
+ 24
829
+ """"""
830
+ ",0.25,0.8063080495356036,0.9837461300309598
831
+ "
832
+ FIX = """"""
833
+ Add more test cases.
834
+ """"""
835
+
836
+ def vowels_count(s):
837
+ """"""Write a function vowels_count which takes a string representing
838
+ a word as input and returns the number of vowels in the string.
839
+ Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
840
+ vowel, but only when it is at the end of the given word.
841
+
842
+ Example:
843
+ >>> vowels_count(""abcde"")
844
+ 2
845
+ >>> vowels_count(""ACEDY"")
846
+ 3
847
+ """"""
848
+ ",0.7999999999999999,1.0,1.0
849
+ "
850
+ def circular_shift(x, shift):
851
+ """"""Circular shift the digits of the integer x, shift the digits right by shift
852
+ and return the result as a string.
853
+ If shift > number of digits, return digits reversed.
854
+ >>> circular_shift(12, 1)
855
+ ""21""
856
+ >>> circular_shift(12, 2)
857
+ ""12""
858
+ """"""
859
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
860
+ "
861
+ def digitSum(s):
862
+ """"""Task
863
+ Write a function that takes a string as input and returns the sum of the upper characters only'
864
+ ASCII codes.
865
+
866
+ Examples:
867
+ digitSum("""") => 0
868
+ digitSum(""abAB"") => 131
869
+ digitSum(""abcCd"") => 67
870
+ digitSum(""helloE"") => 69
871
+ digitSum(""woArBld"") => 131
872
+ digitSum(""aAaaaXa"") => 153
873
+ """"""
874
+ ",0.75,0.9999355005159959,1.0
875
+ "
876
+ def fruit_distribution(s,n):
877
+ """"""
878
+ In this task, you will be given a string that represents a number of apples and oranges
879
+ that are distributed in a basket of fruit this basket contains
880
+ apples, oranges, and mango fruits. Given the string that represents the total number of
881
+ the oranges and apples and an integer that represent the total number of the fruits
882
+ in the basket return the number of the mango fruits in the basket.
883
+ for examble:
884
+ fruit_distribution(""5 apples and 6 oranges"", 19) ->19 - 5 - 6 = 8
885
+ fruit_distribution(""0 apples and 1 oranges"",3) -> 3 - 0 - 1 = 2
886
+ fruit_distribution(""2 apples and 3 oranges"", 100) -> 100 - 2 - 3 = 95
887
+ fruit_distribution(""100 apples and 1 oranges"",120) -> 120 - 100 - 1 = 19
888
+ """"""
889
+ ",0.0,0.0,0.0
890
+ "
891
+ def pluck(arr):
892
+ """"""
893
+ ""Given an array representing a branch of a tree that has non-negative integer nodes
894
+ your task is to pluck one of the nodes and return it.
895
+ The plucked node should be the node with the smallest even value.
896
+ If multiple nodes with the same smallest even value are found return the node that has smallest index.
897
+
898
+ The plucked node should be returned in a list, [ smalest_value, its index ],
899
+ If there are no even values or the given array is empty, return [].
900
+
901
+ Example 1:
902
+ Input: [4,2,3]
903
+ Output: [2, 1]
904
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
905
+
906
+ Example 2:
907
+ Input: [1,2,3]
908
+ Output: [2, 1]
909
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
910
+
911
+ Example 3:
912
+ Input: []
913
+ Output: []
914
+
915
+ Example 4:
916
+ Input: [5, 0, 3, 0, 4, 2]
917
+ Output: [0, 1]
918
+ Explanation: 0 is the smallest value, but there are two zeros,
919
+ so we will choose the first zero, which has the smallest index.
920
+
921
+ Constraints:
922
+ * 1 <= nodes.length <= 10000
923
+ * 0 <= node.value
924
+ """"""
925
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
926
+ "
927
+ def search(lst):
928
+ '''
929
+ You are given a non-empty list of positive integers. Return the greatest integer that is greater than
930
+ zero, and has a frequency greater than or equal to the value of the integer itself.
931
+ The frequency of an integer is the number of times it appears in the list.
932
+ If no such a value exist, return -1.
933
+ Examples:
934
+ search([4, 1, 2, 2, 3, 1]) == 2
935
+ search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
936
+ search([5, 5, 4, 4, 4]) == -1
937
+ '''
938
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
939
+ "
940
+ def strange_sort_list(lst):
941
+ '''
942
+ Given list of integers, return list in strange order.
943
+ Strange sorting, is when you start with the minimum value,
944
+ then maximum of the remaining integers, then minimum and so on.
945
+
946
+ Examples:
947
+ strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
948
+ strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
949
+ strange_sort_list([]) == []
950
+ '''
951
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
952
+ "
953
+ def triangle_area(a, b, c):
954
+ '''
955
+ Given the lengths of the three sides of a triangle. Return the area of
956
+ the triangle rounded to 2 decimal points if the three sides form a valid triangle.
957
+ Otherwise return -1
958
+ Three sides make a valid triangle when the sum of any two sides is greater
959
+ than the third side.
960
+ Example:
961
+ triangle_area(3, 4, 5) == 6.00
962
+ triangle_area(1, 2, 10) == -1
963
+ '''
964
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
965
+ "
966
+ def will_it_fly(q,w):
967
+ '''
968
+ Write a function that returns True if the object q will fly, and False otherwise.
969
+ 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.
970
+
971
+ Example:
972
+ will_it_fly([1, 2], 5) ➞ False
973
+ # 1+2 is less than the maximum possible weight, but it's unbalanced.
974
+
975
+ will_it_fly([3, 2, 3], 1) ➞ False
976
+ # it's balanced, but 3+2+3 is more than the maximum possible weight.
977
+
978
+ will_it_fly([3, 2, 3], 9) ➞ True
979
+ # 3+2+3 is less than the maximum possible weight, and it's balanced.
980
+
981
+ will_it_fly([3], 5) ➞ True
982
+ # 3 is less than the maximum possible weight, and it's balanced.
983
+ '''
984
+ ",0.5499999999999998,0.9918730650154799,1.0
985
+ "
986
+ def smallest_change(arr):
987
+ """"""
988
+ Given an array arr of integers, find the minimum number of elements that
989
+ need to be changed to make the array palindromic. A palindromic array is an array that
990
+ is read the same backwards and forwards. In one change, you can change one element to any other element.
991
+
992
+ For example:
993
+ smallest_change([1,2,3,5,4,7,9,6]) == 4
994
+ smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
995
+ smallest_change([1, 2, 3, 2, 1]) == 0
996
+ """"""
997
+ ",0.0,0.0,0.0
998
+ "
999
+ def total_match(lst1, lst2):
1000
+ '''
1001
+ Write a function that accepts two lists of strings and returns the list that has
1002
+ total number of chars in the all strings of the list less than the other list.
1003
+
1004
+ if the two lists have the same number of chars, return the first list.
1005
+
1006
+ Examples
1007
+ total_match([], []) ➞ []
1008
+ total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
1009
+ total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
1010
+ total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
1011
+ total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
1012
+ '''
1013
+ ",0.0,0.0,0.0
1014
+ "
1015
+ def is_multiply_prime(a):
1016
+ """"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
1017
+ and false otherwise.
1018
+ Knowing that (a) is less then 100.
1019
+ Example:
1020
+ is_multiply_prime(30) == True
1021
+ 30 = 2 * 3 * 5
1022
+ """"""
1023
+ ",0.0,0.0,0.0
1024
+ "
1025
+ def is_simple_power(x, n):
1026
+ """"""Your task is to write a function that returns true if a number x is a simple
1027
+ power of n and false in other cases.
1028
+ x is a simple power of n if n**int=x
1029
+ For example:
1030
+ is_simple_power(1, 4) => true
1031
+ is_simple_power(2, 2) => true
1032
+ is_simple_power(8, 2) => true
1033
+ is_simple_power(3, 2) => false
1034
+ is_simple_power(3, 1) => false
1035
+ is_simple_power(5, 3) => false
1036
+ """"""
1037
+ ",0.050000000000000044,0.25,0.5
1038
+ "
1039
+ def iscube(a):
1040
+ '''
1041
+ Write a function that takes an integer a and returns True
1042
+ if this ingeger is a cube of some integer number.
1043
+ Note: you may assume the input is always valid.
1044
+ Examples:
1045
+ iscube(1) ==> True
1046
+ iscube(2) ==> False
1047
+ iscube(-1) ==> True
1048
+ iscube(64) ==> True
1049
+ iscube(0) ==> True
1050
+ iscube(180) ==> False
1051
+ '''
1052
+ ",0.0,0.0,0.0
1053
+ "
1054
+ def hex_key(num):
1055
+ """"""You have been tasked to write a function that receives
1056
+ a hexadecimal number as a string and counts the number of hexadecimal
1057
+ digits that are primes (prime number, or a prime, is a natural number
1058
+ greater than 1 that is not a product of two smaller natural numbers).
1059
+ Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
1060
+ Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
1061
+ So you have to determine a number of the following digits: 2, 3, 5, 7,
1062
+ B (=decimal 11), D (=decimal 13).
1063
+ Note: you may assume the input is always correct or empty string,
1064
+ and symbols A,B,C,D,E,F are always uppercase.
1065
+ Examples:
1066
+ For num = ""AB"" the output should be 1.
1067
+ For num = ""1077E"" the output should be 2.
1068
+ For num = ""ABED1A33"" the output should be 4.
1069
+ For num = ""123456789ABCDEF0"" the output should be 6.
1070
+ For num = ""2020"" the output should be 2.
1071
+ """"""
1072
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
1073
+ "
1074
+ def decimal_to_binary(decimal):
1075
+ """"""You will be given a number in decimal form and your task is to convert it to
1076
+ binary format. The function should return a string, with each character representing a binary
1077
+ number. Each character in the string will be '0' or '1'.
1078
+
1079
+ There will be an extra couple of characters 'db' at the beginning and at the end of the string.
1080
+ The extra characters are there to help with the format.
1081
+
1082
+ Examples:
1083
+ decimal_to_binary(15) # returns ""db1111db""
1084
+ decimal_to_binary(32) # returns ""db100000db""
1085
+ """"""
1086
+ ",0.7,0.9996130030959752,1.0
1087
+ "
1088
+ def is_happy(s):
1089
+ """"""You are given a string s.
1090
+ Your task is to check if the string is happy or not.
1091
+ A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
1092
+ For example:
1093
+ is_happy(a) => False
1094
+ is_happy(aa) => False
1095
+ is_happy(abcd) => True
1096
+ is_happy(aabb) => False
1097
+ is_happy(adb) => True
1098
+ is_happy(xyy) => False
1099
+ """"""
1100
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1101
+ "
1102
+ def numerical_letter_grade(grades):
1103
+ """"""It is the last week of the semester and the teacher has to give the grades
1104
+ to students. The teacher has been making her own algorithm for grading.
1105
+ The only problem is, she has lost the code she used for grading.
1106
+ She has given you a list of GPAs for some students and you have to write
1107
+ a function that can output a list of letter grades using the following table:
1108
+ GPA | Letter grade
1109
+ 4.0 A+
1110
+ > 3.7 A
1111
+ > 3.3 A-
1112
+ > 3.0 B+
1113
+ > 2.7 B
1114
+ > 2.3 B-
1115
+ > 2.0 C+
1116
+ > 1.7 C
1117
+ > 1.3 C-
1118
+ > 1.0 D+
1119
+ > 0.7 D
1120
+ > 0.0 D-
1121
+ 0.0 E
1122
+
1123
+
1124
+ Example:
1125
+ grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
1126
+ """"""
1127
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
1128
+ "
1129
+ def prime_length(string):
1130
+ """"""Write a function that takes a string and returns True if the string
1131
+ length is a prime number or False otherwise
1132
+ Examples
1133
+ prime_length('Hello') == True
1134
+ prime_length('abcdcba') == True
1135
+ prime_length('kittens') == True
1136
+ prime_length('orange') == False
1137
+ """"""
1138
+ ",0.050000000000000044,0.25,0.5
1139
+ "
1140
+ def starts_one_ends(n):
1141
+ """"""
1142
+ Given a positive integer n, return the count of the numbers of n-digit
1143
+ positive integers that start or end with 1.
1144
+ """"""
1145
+ ",0.0,0.0,0.0
1146
+ "
1147
+ def solve(N):
1148
+ """"""Given a positive integer N, return the total sum of its digits in binary.
1149
+
1150
+ Example
1151
+ For N = 1000, the sum of digits will be 1 the output should be ""1"".
1152
+ For N = 150, the sum of digits will be 6 the output should be ""110"".
1153
+ For N = 147, the sum of digits will be 12 the output should be ""1100"".
1154
+
1155
+ Variables:
1156
+ @N integer
1157
+ Constraints: 0 ≤ N ≤ 10000.
1158
+ Output:
1159
+ a string of binary number
1160
+ """"""
1161
+ ",0.0,0.0,0.0
1162
+ "
1163
+ def add(lst):
1164
+ """"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
1165
+
1166
+
1167
+ Examples:
1168
+ add([4, 2, 6, 7]) ==> 2
1169
+ """"""
1170
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1171
+ "
1172
+ def anti_shuffle(s):
1173
+ """"""
1174
+ Write a function that takes a string and returns an ordered version of it.
1175
+ Ordered version of string, is a string where all words (separated by space)
1176
+ are replaced by a new word where all the characters arranged in
1177
+ ascending order based on ascii value.
1178
+ Note: You should keep the order of words and blank spaces in the sentence.
1179
+
1180
+ For example:
1181
+ anti_shuffle('Hi') returns 'Hi'
1182
+ anti_shuffle('hello') returns 'ehllo'
1183
+ anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
1184
+ """"""
1185
+ ",0.25,0.8063080495356036,0.9837461300309598
1186
+ "
1187
+ def get_row(lst, x):
1188
+ """"""
1189
+ You are given a 2 dimensional data, as a nested lists,
1190
+ which is similar to matrix, however, unlike matrices,
1191
+ each row may contain a different number of columns.
1192
+ Given lst, and integer x, find integers x in the list,
1193
+ and return list of tuples, [(x1, y1), (x2, y2) ...] such that
1194
+ each tuple is a coordinate - (row, columns), starting with 0.
1195
+ Sort coordinates initially by rows in ascending order.
1196
+ Also, sort coordinates of the row by columns in descending order.
1197
+
1198
+ Examples:
1199
+ get_row([
1200
+ [1,2,3,4,5,6],
1201
+ [1,2,3,4,1,6],
1202
+ [1,2,3,4,5,1]
1203
+ ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
1204
+ get_row([], 1) == []
1205
+ get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
1206
+ """"""
1207
+ ",0.0,0.0,0.0
1208
+ "
1209
+ def sort_array(array):
1210
+ """"""
1211
+ Given an array of non-negative integers, return a copy of the given array after sorting,
1212
+ you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
1213
+ or sort it in descending order if the sum( first index value, last index value) is even.
1214
+
1215
+ Note:
1216
+ * don't change the given array.
1217
+
1218
+ Examples:
1219
+ * sort_array([]) => []
1220
+ * sort_array([5]) => [5]
1221
+ * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
1222
+ * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
1223
+ """"""
1224
+ ",0.25,0.8063080495356036,0.9837461300309598
1225
+ "
1226
+ def encrypt(s):
1227
+ """"""Create a function encrypt that takes a string as an argument and
1228
+ returns a string encrypted with the alphabet being rotated.
1229
+ The alphabet should be rotated in a manner such that the letters
1230
+ shift down by two multiplied to two places.
1231
+ For example:
1232
+ encrypt('hi') returns 'lm'
1233
+ encrypt('asdfghjkl') returns 'ewhjklnop'
1234
+ encrypt('gf') returns 'kj'
1235
+ encrypt('et') returns 'ix'
1236
+ """"""
1237
+ ",0.050000000000000044,0.25,0.5
1238
+ "
1239
+ def next_smallest(lst):
1240
+ """"""
1241
+ You are given a list of integers.
1242
+ Write a function next_smallest() that returns the 2nd smallest element of the list.
1243
+ Return None if there is no such element.
1244
+
1245
+ next_smallest([1, 2, 3, 4, 5]) == 2
1246
+ next_smallest([5, 1, 4, 3, 2]) == 2
1247
+ next_smallest([]) == None
1248
+ next_smallest([1, 1]) == None
1249
+ """"""
1250
+ ",0.25,0.8063080495356036,0.9837461300309598
1251
+ "
1252
+ def is_bored(S):
1253
+ """"""
1254
+ You'll be given a string of words, and your task is to count the number
1255
+ of boredoms. A boredom is a sentence that starts with the word ""I"".
1256
+ Sentences are delimited by '.', '?' or '!'.
1257
+
1258
+ For example:
1259
+ >>> is_bored(""Hello world"")
1260
+ 0
1261
+ >>> is_bored(""The sky is blue. The sun is shining. I love this weather"")
1262
+ 1
1263
+ """"""
1264
+ ",0.0,0.0,0.0
1265
+ "
1266
+ def any_int(x, y, z):
1267
+ '''
1268
+ Create a function that takes 3 numbers.
1269
+ Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
1270
+ Returns false in any other cases.
1271
+
1272
+ Examples
1273
+ any_int(5, 2, 7) ➞ True
1274
+
1275
+ any_int(3, 2, 2) ➞ False
1276
+
1277
+ any_int(3, -2, 1) ➞ True
1278
+
1279
+ any_int(3.6, -2.2, 2) ➞ False
1280
+
1281
+
1282
+
1283
+ '''
1284
+ ",0.6000000000000001,0.9963880288957688,1.0
1285
+ "
1286
+ def encode(message):
1287
+ """"""
1288
+ Write a function that takes a message, and encodes in such a
1289
+ way that it swaps case of all letters, replaces all vowels in
1290
+ the message with the letter that appears 2 places ahead of that
1291
+ vowel in the english alphabet.
1292
+ Assume only letters.
1293
+
1294
+ Examples:
1295
+ >>> encode('test')
1296
+ 'TGST'
1297
+ >>> encode('This is a message')
1298
+ 'tHKS KS C MGSSCGG'
1299
+ """"""
1300
+ ",0.0,0.0,0.0
1301
+ "
1302
+
1303
+ def skjkasdkd(lst):
1304
+ """"""You are given a list of integers.
1305
+ You need to find the largest prime value and return the sum of its digits.
1306
+
1307
+ Examples:
1308
+ For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
1309
+ For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
1310
+ For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
1311
+ For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
1312
+ For lst = [0,81,12,3,1,21] the output should be 3
1313
+ For lst = [0,8,1,2,1,7] the output should be 7
1314
+ """"""
1315
+ ",0.25,0.8063080495356036,0.9837461300309598
1316
+ "
1317
+ def check_dict_case(dict):
1318
+ """"""
1319
+ Given a dictionary, return True if all keys are strings in lower
1320
+ case or all keys are strings in upper case, else return False.
1321
+ The function should return False is the given dictionary is empty.
1322
+ Examples:
1323
+ check_dict_case({""a"":""apple"", ""b"":""banana""}) should return True.
1324
+ check_dict_case({""a"":""apple"", ""A"":""banana"", ""B"":""banana""}) should return False.
1325
+ check_dict_case({""a"":""apple"", 8:""banana"", ""a"":""apple""}) should return False.
1326
+ check_dict_case({""Name"":""John"", ""Age"":""36"", ""City"":""Houston""}) should return False.
1327
+ check_dict_case({""STATE"":""NC"", ""ZIP"":""12345"" }) should return True.
1328
+ """"""
1329
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1330
+ "
1331
+ def count_up_to(n):
1332
+ """"""Implement a function that takes an non-negative integer and returns an array of the first n
1333
+ integers that are prime numbers and less than n.
1334
+ for example:
1335
+ count_up_to(5) => [2,3]
1336
+ count_up_to(11) => [2,3,5,7]
1337
+ count_up_to(0) => []
1338
+ count_up_to(20) => [2,3,5,7,11,13,17,19]
1339
+ count_up_to(1) => []
1340
+ count_up_to(18) => [2,3,5,7,11,13,17]
1341
+ """"""
1342
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
1343
+ "
1344
+ def multiply(a, b):
1345
+ """"""Complete the function that takes two integers and returns
1346
+ the product of their unit digits.
1347
+ Assume the input is always valid.
1348
+ Examples:
1349
+ multiply(148, 412) should return 16.
1350
+ multiply(19, 28) should return 72.
1351
+ multiply(2020, 1851) should return 0.
1352
+ multiply(14,-15) should return 20.
1353
+ """"""
1354
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1355
+ "
1356
+ def count_upper(s):
1357
+ """"""
1358
+ Given a string s, count the number of uppercase vowels in even indices.
1359
+
1360
+ For example:
1361
+ count_upper('aBCdEf') returns 1
1362
+ count_upper('abcdefg') returns 0
1363
+ count_upper('dBBE') returns 0
1364
+ """"""
1365
+ ",0.25,0.8063080495356036,0.9837461300309598
1366
+ "
1367
+ def closest_integer(value):
1368
+ '''
1369
+ Create a function that takes a value (string) representing a number
1370
+ and returns the closest integer to it. If the number is equidistant
1371
+ from two integers, round it away from zero.
1372
+
1373
+ Examples
1374
+ >>> closest_integer(""10"")
1375
+ 10
1376
+ >>> closest_integer(""15.3"")
1377
+ 15
1378
+
1379
+ Note:
1380
+ Rounding away from zero means that if the given number is equidistant
1381
+ from two integers, the one you should return is the one that is the
1382
+ farthest from zero. For example closest_integer(""14.5"") should
1383
+ return 15 and closest_integer(""-14.5"") should return -15.
1384
+ '''
1385
+ ",0.0,0.0,0.0
1386
+ "
1387
+ def make_a_pile(n):
1388
+ """"""
1389
+ Given a positive integer n, you have to make a pile of n levels of stones.
1390
+ The first level has n stones.
1391
+ The number of stones in the next level is:
1392
+ - the next odd number if n is odd.
1393
+ - the next even number if n is even.
1394
+ Return the number of stones in each level in a list, where element at index
1395
+ i represents the number of stones in the level (i+1).
1396
+
1397
+ Examples:
1398
+ >>> make_a_pile(3)
1399
+ [3, 5, 7]
1400
+ """"""
1401
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1402
+ "
1403
+ def words_string(s):
1404
+ """"""
1405
+ You will be given a string of words separated by commas or spaces. Your task is
1406
+ to split the string into words and return an array of the words.
1407
+
1408
+ For example:
1409
+ words_string(""Hi, my name is John"") == [""Hi"", ""my"", ""name"", ""is"", ""John""]
1410
+ words_string(""One, two, three, four, five, six"") == [""One"", ""two"", ""three"", ""four"", ""five"", ""six""]
1411
+ """"""
1412
+ ",0.0,0.0,0.0
1413
+ "
1414
+ def choose_num(x, y):
1415
+ """"""This function takes two positive numbers x and y and returns the
1416
+ biggest even integer number that is in the range [x, y] inclusive. If
1417
+ there's no such number, then the function should return -1.
1418
+
1419
+ For example:
1420
+ choose_num(12, 15) = 14
1421
+ choose_num(13, 12) = -1
1422
+ """"""
1423
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1424
+ "
1425
+ def rounded_avg(n, m):
1426
+ """"""You are given two positive integers n and m, and your task is to compute the
1427
+ average of the integers from n through m (including n and m).
1428
+ Round the answer to the nearest integer and convert that to binary.
1429
+ If n is greater than m, return -1.
1430
+ Example:
1431
+ rounded_avg(1, 5) => ""0b11""
1432
+ rounded_avg(7, 5) => -1
1433
+ rounded_avg(10, 20) => ""0b1111""
1434
+ rounded_avg(20, 33) => ""0b11010""
1435
+ """"""
1436
+ ",0.0,0.0,0.0
1437
+ "
1438
+ def unique_digits(x):
1439
+ """"""Given a list of positive integers x. return a sorted list of all
1440
+ elements that hasn't any even digit.
1441
+
1442
+ Note: Returned list should be sorted in increasing order.
1443
+
1444
+ For example:
1445
+ >>> unique_digits([15, 33, 1422, 1])
1446
+ [1, 15, 33]
1447
+ >>> unique_digits([152, 323, 1422, 10])
1448
+ []
1449
+ """"""
1450
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1451
+ "
1452
+ def by_length(arr):
1453
+ """"""
1454
+ Given an array of integers, sort the integers that are between 1 and 9 inclusive,
1455
+ reverse the resulting array, and then replace each digit by its corresponding name from
1456
+ ""One"", ""Two"", ""Three"", ""Four"", ""Five"", ""Six"", ""Seven"", ""Eight"", ""Nine"".
1457
+
1458
+ For example:
1459
+ arr = [2, 1, 1, 4, 5, 8, 2, 3]
1460
+ -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
1461
+ -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
1462
+ return [""Eight"", ""Five"", ""Four"", ""Three"", ""Two"", ""Two"", ""One"", ""One""]
1463
+
1464
+ If the array is empty, return an empty array:
1465
+ arr = []
1466
+ return []
1467
+
1468
+ If the array has any strange number ignore it:
1469
+ arr = [1, -1 , 55]
1470
+ -> sort arr -> [-1, 1, 55]
1471
+ -> reverse arr -> [55, 1, -1]
1472
+ return = ['One']
1473
+ """"""
1474
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1475
+ "
1476
+ def f(n):
1477
+ """""" Implement the function f that takes n as a parameter,
1478
+ 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
1479
+ or the sum of numbers from 1 to i otherwise.
1480
+ i starts from 1.
1481
+ the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
1482
+ Example:
1483
+ f(5) == [1, 2, 6, 24, 15]
1484
+ """"""
1485
+ ",0.0,0.0,0.0
1486
+ "
1487
+ def even_odd_palindrome(n):
1488
+ """"""
1489
+ Given a positive integer n, return a tuple that has the number of even and odd
1490
+ integer palindromes that fall within the range(1, n), inclusive.
1491
+
1492
+ Example 1:
1493
+
1494
+ Input: 3
1495
+ Output: (1, 2)
1496
+ Explanation:
1497
+ Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
1498
+
1499
+ Example 2:
1500
+
1501
+ Input: 12
1502
+ Output: (4, 6)
1503
+ Explanation:
1504
+ Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
1505
+
1506
+ Note:
1507
+ 1. 1 <= n <= 10^3
1508
+ 2. returned tuple has the number of even and odd integer palindromes respectively.
1509
+ """"""
1510
+ ",1.0,1.0,1.0
1511
+ "
1512
+ def count_nums(arr):
1513
+ """"""
1514
+ Write a function count_nums which takes an array of integers and returns
1515
+ the number of elements which has a sum of digits > 0.
1516
+ If a number is negative, then its first signed digit will be negative:
1517
+ e.g. -123 has signed digits -1, 2, and 3.
1518
+ >>> count_nums([]) == 0
1519
+ >>> count_nums([-1, 11, -11]) == 1
1520
+ >>> count_nums([1, 1, 2]) == 3
1521
+ """"""
1522
+ ",0.050000000000000044,0.25,0.5
1523
+ "
1524
+ def move_one_ball(arr):
1525
+ """"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
1526
+ numbers in the array will be randomly ordered. Your task is to determine if
1527
+ it is possible to get an array sorted in non-decreasing order by performing
1528
+ the following operation on the given array:
1529
+ You are allowed to perform right shift operation any number of times.
1530
+
1531
+ One right shift operation means shifting all elements of the array by one
1532
+ position in the right direction. The last element of the array will be moved to
1533
+ the starting position in the array i.e. 0th index.
1534
+
1535
+ If it is possible to obtain the sorted array by performing the above operation
1536
+ then return True else return False.
1537
+ If the given array is empty then return True.
1538
+
1539
+ Note: The given list is guaranteed to have unique elements.
1540
+
1541
+ For Example:
1542
+
1543
+ move_one_ball([3, 4, 5, 1, 2])==>True
1544
+ Explanation: By performin 2 right shift operations, non-decreasing order can
1545
+ be achieved for the given array.
1546
+ move_one_ball([3, 5, 4, 1, 2])==>False
1547
+ Explanation:It is not possible to get non-decreasing order for the given
1548
+ array by performing any number of right shift operations.
1549
+
1550
+ """"""
1551
+ ",0.0,0.0,0.0
1552
+ "
1553
+ def exchange(lst1, lst2):
1554
+ """"""In this problem, you will implement a function that takes two lists of numbers,
1555
+ and determines whether it is possible to perform an exchange of elements
1556
+ between them to make lst1 a list of only even numbers.
1557
+ There is no limit on the number of exchanged elements between lst1 and lst2.
1558
+ If it is possible to exchange elements between the lst1 and lst2 to make
1559
+ all the elements of lst1 to be even, return ""YES"".
1560
+ Otherwise, return ""NO"".
1561
+ For example:
1562
+ exchange([1, 2, 3, 4], [1, 2, 3, 4]) => ""YES""
1563
+ exchange([1, 2, 3, 4], [1, 5, 3, 4]) => ""NO""
1564
+ It is assumed that the input lists will be non-empty.
1565
+ """"""
1566
+ ",0.0,0.0,0.0
1567
+ "
1568
+ def histogram(test):
1569
+ """"""Given a string representing a space separated lowercase letters, return a dictionary
1570
+ of the letter with the most repetition and containing the corresponding count.
1571
+ If several letters have the same occurrence, return all of them.
1572
+
1573
+ Example:
1574
+ histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
1575
+ histogram('a b b a') == {'a': 2, 'b': 2}
1576
+ histogram('a b c a b') == {'a': 2, 'b': 2}
1577
+ histogram('b b b b a') == {'b': 4}
1578
+ histogram('') == {}
1579
+
1580
+ """"""
1581
+ ",0.050000000000000044,0.25,0.5
1582
+ "
1583
+ def reverse_delete(s,c):
1584
+ """"""Task
1585
+ 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
1586
+ then check if the result string is palindrome.
1587
+ A string is called palindrome if it reads the same backward as forward.
1588
+ You should return a tuple containing the result string and True/False for the check.
1589
+ Example
1590
+ For s = ""abcde"", c = ""ae"", the result should be ('bcd',False)
1591
+ For s = ""abcdef"", c = ""b"" the result should be ('acdef',False)
1592
+ For s = ""abcdedcba"", c = ""ab"", the result should be ('cdedc',True)
1593
+ """"""
1594
+ ",0.65,0.9986455108359134,1.0
1595
+ "
1596
+ def odd_count(lst):
1597
+ """"""Given a list of strings, where each string consists of only digits, return a list.
1598
+ Each element i of the output should be ""the number of odd elements in the
1599
+ string i of the input."" where all the i's should be replaced by the number
1600
+ of odd digits in the i'th string of the input.
1601
+
1602
+ >>> odd_count(['1234567'])
1603
+ [""the number of odd elements 4n the str4ng 4 of the 4nput.""]
1604
+ >>> odd_count(['3',""11111111""])
1605
+ [""the number of odd elements 1n the str1ng 1 of the 1nput."",
1606
+ ""the number of odd elements 8n the str8ng 8 of the 8nput.""]
1607
+ """"""
1608
+ ",0.050000000000000044,0.25,0.5
1609
+ "
1610
+ def minSubArraySum(nums):
1611
+ """"""
1612
+ Given an array of integers nums, find the minimum sum of any non-empty sub-array
1613
+ of nums.
1614
+ Example
1615
+ minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
1616
+ minSubArraySum([-1, -2, -3]) == -6
1617
+ """"""
1618
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1619
+ "
1620
+ def max_fill(grid, capacity):
1621
+ import math
1622
+ """"""
1623
+ You are given a rectangular grid of wells. Each row represents a single well,
1624
+ and each 1 in a row represents a single unit of water.
1625
+ Each well has a corresponding bucket that can be used to extract water from it,
1626
+ and all buckets have the same capacity.
1627
+ Your task is to use the buckets to empty the wells.
1628
+ Output the number of times you need to lower the buckets.
1629
+
1630
+ Example 1:
1631
+ Input:
1632
+ grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
1633
+ bucket_capacity : 1
1634
+ Output: 6
1635
+
1636
+ Example 2:
1637
+ Input:
1638
+ grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
1639
+ bucket_capacity : 2
1640
+ Output: 5
1641
+
1642
+ Example 3:
1643
+ Input:
1644
+ grid : [[0,0,0], [0,0,0]]
1645
+ bucket_capacity : 5
1646
+ Output: 0
1647
+
1648
+ Constraints:
1649
+ * all wells have the same length
1650
+ * 1 <= grid.length <= 10^2
1651
+ * 1 <= grid[:,1].length <= 10^2
1652
+ * grid[i][j] -> 0 | 1
1653
+ * 1 <= capacity <= 10
1654
+ """"""
1655
+ ",0.0,0.0,0.0
1656
+ "
1657
+ def sort_array(arr):
1658
+ """"""
1659
+ In this Kata, you have to sort an array of non-negative integers according to
1660
+ number of ones in their binary representation in ascending order.
1661
+ For similar number of ones, sort based on decimal value.
1662
+
1663
+ It must be implemented like this:
1664
+ >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
1665
+ >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
1666
+ >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
1667
+ """"""
1668
+ ",0.85,1.0,1.0
1669
+ "
1670
+ def select_words(s, n):
1671
+ """"""Given a string s and a natural number n, you have been tasked to implement
1672
+ a function that returns a list of all words from string s that contain exactly
1673
+ n consonants, in order these words appear in the string s.
1674
+ If the string s is empty then the function should return an empty list.
1675
+ Note: you may assume the input string contains only letters and spaces.
1676
+ Examples:
1677
+ select_words(""Mary had a little lamb"", 4) ==> [""little""]
1678
+ select_words(""Mary had a little lamb"", 3) ==> [""Mary"", ""lamb""]
1679
+ select_words(""simple white space"", 2) ==> []
1680
+ select_words(""Hello world"", 4) ==> [""world""]
1681
+ select_words(""Uncle sam"", 3) ==> [""Uncle""]
1682
+ """"""
1683
+ ",0.050000000000000044,0.25,0.5
1684
+ "
1685
+ def get_closest_vowel(word):
1686
+ """"""You are given a word. Your task is to find the closest vowel that stands between
1687
+ two consonants from the right side of the word (case sensitive).
1688
+
1689
+ Vowels in the beginning and ending doesn't count. Return empty string if you didn't
1690
+ find any vowel met the above condition.
1691
+
1692
+ You may assume that the given string contains English letter only.
1693
+
1694
+ Example:
1695
+ get_closest_vowel(""yogurt"") ==> ""u""
1696
+ get_closest_vowel(""FULL"") ==> ""U""
1697
+ get_closest_vowel(""quick"") ==> """"
1698
+ get_closest_vowel(""ab"") ==> """"
1699
+ """"""
1700
+ ",0.050000000000000044,0.25,0.5
1701
+ "
1702
+ def match_parens(lst):
1703
+ '''
1704
+ You are given a list of two strings, both strings consist of open
1705
+ parentheses '(' or close parentheses ')' only.
1706
+ Your job is to check if it is possible to concatenate the two strings in
1707
+ some order, that the resulting string will be good.
1708
+ A string S is considered to be good if and only if all parentheses in S
1709
+ are balanced. For example: the string '(())()' is good, while the string
1710
+ '())' is not.
1711
+ Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
1712
+
1713
+ Examples:
1714
+ match_parens(['()(', ')']) == 'Yes'
1715
+ match_parens([')', ')']) == 'No'
1716
+ '''
1717
+ ",0.0,0.0,0.0
1718
+ "
1719
+ def maximum(arr, k):
1720
+ """"""
1721
+ Given an array arr of integers and a positive integer k, return a sorted list
1722
+ of length k with the maximum k numbers in arr.
1723
+
1724
+ Example 1:
1725
+
1726
+ Input: arr = [-3, -4, 5], k = 3
1727
+ Output: [-4, -3, 5]
1728
+
1729
+ Example 2:
1730
+
1731
+ Input: arr = [4, -4, 4], k = 2
1732
+ Output: [4, 4]
1733
+
1734
+ Example 3:
1735
+
1736
+ Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
1737
+ Output: [2]
1738
+
1739
+ Note:
1740
+ 1. The length of the array will be in the range of [1, 1000].
1741
+ 2. The elements in the array will be in the range of [-1000, 1000].
1742
+ 3. 0 <= k <= len(arr)
1743
+ """"""
1744
+ ",0.0,0.0,0.0
1745
+ "
1746
+ def solution(lst):
1747
+ """"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
1748
+
1749
+
1750
+ Examples
1751
+ solution([5, 8, 7, 1]) ==> 12
1752
+ solution([3, 3, 3, 3, 3]) ==> 9
1753
+ solution([30, 13, 24, 321]) ==>0
1754
+ """"""
1755
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1756
+ "
1757
+ def add_elements(arr, k):
1758
+ """"""
1759
+ Given a non-empty array of integers arr and an integer k, return
1760
+ the sum of the elements with at most two digits from the first k elements of arr.
1761
+
1762
+ Example:
1763
+
1764
+ Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
1765
+ Output: 24 # sum of 21 + 3
1766
+
1767
+ Constraints:
1768
+ 1. 1 <= len(arr) <= 100
1769
+ 2. 1 <= k <= len(arr)
1770
+ """"""
1771
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1772
+ "
1773
+ def get_odd_collatz(n):
1774
+ """"""
1775
+ Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
1776
+
1777
+ The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
1778
+ as follows: start with any positive integer n. Then each term is obtained from the
1779
+ previous term as follows: if the previous term is even, the next term is one half of
1780
+ the previous term. If the previous term is odd, the next term is 3 times the previous
1781
+ term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
1782
+
1783
+ Note:
1784
+ 1. Collatz(1) is [1].
1785
+ 2. returned list sorted in increasing order.
1786
+
1787
+ For example:
1788
+ get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
1789
+ """"""
1790
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1791
+ "
1792
+ def valid_date(date):
1793
+ """"""You have to write a function which validates a given date string and
1794
+ returns True if the date is valid otherwise False.
1795
+ The date is valid if all of the following rules are satisfied:
1796
+ 1. The date string is not empty.
1797
+ 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
1798
+ 3. The months should not be less than 1 or higher than 12.
1799
+ 4. The date should be in the format: mm-dd-yyyy
1800
+
1801
+ for example:
1802
+ valid_date('03-11-2000') => True
1803
+
1804
+ valid_date('15-01-2012') => False
1805
+
1806
+ valid_date('04-0-2040') => False
1807
+
1808
+ valid_date('06-04-2020') => True
1809
+
1810
+ valid_date('06/04/2020') => False
1811
+ """"""
1812
+ ",0.0,0.0,0.0
1813
+ "
1814
+ def split_words(txt):
1815
+ '''
1816
+ Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
1817
+ should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
1818
+ alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
1819
+ Examples
1820
+ split_words(""Hello world!"") ➞ [""Hello"", ""world!""]
1821
+ split_words(""Hello,world!"") ➞ [""Hello"", ""world!""]
1822
+ split_words(""abcdef"") == 3
1823
+ '''
1824
+ ",0.0,0.0,0.0
1825
+ "
1826
+ def is_sorted(lst):
1827
+ '''
1828
+ Given a list of numbers, return whether or not they are sorted
1829
+ in ascending order. If list has more than 1 duplicate of the same
1830
+ number, return False. Assume no negative numbers and only integers.
1831
+
1832
+ Examples
1833
+ is_sorted([5]) ➞ True
1834
+ is_sorted([1, 2, 3, 4, 5]) ➞ True
1835
+ is_sorted([1, 3, 2, 4, 5]) ➞ False
1836
+ is_sorted([1, 2, 3, 4, 5, 6]) ➞ True
1837
+ is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
1838
+ is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
1839
+ is_sorted([1, 2, 2, 3, 3, 4]) ➞ True
1840
+ is_sorted([1, 2, 2, 2, 3, 4]) ➞ False
1841
+ '''
1842
+ ",0.0,0.0,0.0
1843
+ "
1844
+ def intersection(interval1, interval2):
1845
+ """"""You are given two intervals,
1846
+ where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
1847
+ The given intervals are closed which means that the interval (start, end)
1848
+ includes both start and end.
1849
+ For each given interval, it is assumed that its start is less or equal its end.
1850
+ Your task is to determine whether the length of intersection of these two
1851
+ intervals is a prime number.
1852
+ Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
1853
+ which its length is 1, which not a prime number.
1854
+ If the length of the intersection is a prime number, return ""YES"",
1855
+ otherwise, return ""NO"".
1856
+ If the two intervals don't intersect, return ""NO"".
1857
+
1858
+
1859
+ [input/output] samples:
1860
+ intersection((1, 2), (2, 3)) ==> ""NO""
1861
+ intersection((-1, 1), (0, 4)) ==> ""NO""
1862
+ intersection((-3, -1), (-5, 5)) ==> ""YES""
1863
+ """"""
1864
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1865
+ "
1866
+ def prod_signs(arr):
1867
+ """"""
1868
+ You are given an array arr of integers and you need to return
1869
+ sum of magnitudes of integers multiplied by product of all signs
1870
+ of each number in the array, represented by 1, -1 or 0.
1871
+ Note: return None for empty arr.
1872
+
1873
+ Example:
1874
+ >>> prod_signs([1, 2, 2, -4]) == -9
1875
+ >>> prod_signs([0, 1]) == 0
1876
+ >>> prod_signs([]) == None
1877
+ """"""
1878
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1879
+ "
1880
+ def minPath(grid, k):
1881
+ """"""
1882
+ Given a grid with N rows and N columns (N >= 2) and a positive integer k,
1883
+ each cell of the grid contains a value. Every integer in the range [1, N * N]
1884
+ inclusive appears exactly once on the cells of the grid.
1885
+
1886
+ You have to find the minimum path of length k in the grid. You can start
1887
+ from any cell, and in each step you can move to any of the neighbor cells,
1888
+ in other words, you can go to cells which share an edge with you current
1889
+ cell.
1890
+ Please note that a path of length k means visiting exactly k cells (not
1891
+ necessarily distinct).
1892
+ You CANNOT go off the grid.
1893
+ A path A (of length k) is considered less than a path B (of length k) if
1894
+ after making the ordered lists of the values on the cells that A and B go
1895
+ through (let's call them lst_A and lst_B), lst_A is lexicographically less
1896
+ than lst_B, in other words, there exist an integer index i (1 <= i <= k)
1897
+ such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
1898
+ lst_A[j] = lst_B[j].
1899
+ It is guaranteed that the answer is unique.
1900
+ Return an ordered list of the values on the cells that the minimum path go through.
1901
+
1902
+ Examples:
1903
+
1904
+ Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
1905
+ Output: [1, 2, 1]
1906
+
1907
+ Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
1908
+ Output: [1]
1909
+ """"""
1910
+ ",0.0,0.0,0.0
1911
+ "
1912
+ def tri(n):
1913
+ """"""Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
1914
+ the last couple centuries. However, what people don't know is Tribonacci sequence.
1915
+ Tribonacci sequence is defined by the recurrence:
1916
+ tri(1) = 3
1917
+ tri(n) = 1 + n / 2, if n is even.
1918
+ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
1919
+ For example:
1920
+ tri(2) = 1 + (2 / 2) = 2
1921
+ tri(4) = 3
1922
+ tri(3) = tri(2) + tri(1) + tri(4)
1923
+ = 2 + 3 + 3 = 8
1924
+ You are given a non-negative integer number n, you have to a return a list of the
1925
+ first n + 1 numbers of the Tribonacci sequence.
1926
+ Examples:
1927
+ tri(3) = [1, 3, 2, 8]
1928
+ """"""
1929
+ ",0.0,0.0,0.0
1930
+ "
1931
+ def digits(n):
1932
+ """"""Given a positive integer n, return the product of the odd digits.
1933
+ Return 0 if all digits are even.
1934
+ For example:
1935
+ digits(1) == 1
1936
+ digits(4) == 0
1937
+ digits(235) == 15
1938
+ """"""
1939
+ ",0.0,0.0,0.0
1940
+ "
1941
+ def is_nested(string):
1942
+ '''
1943
+ Create a function that takes a string as input which contains only square brackets.
1944
+ The function should return True if and only if there is a valid subsequence of brackets
1945
+ where at least one bracket in the subsequence is nested.
1946
+
1947
+ is_nested('[[]]') ➞ True
1948
+ is_nested('[]]]]]]][[[[[]') ➞ False
1949
+ is_nested('[][]') ➞ False
1950
+ is_nested('[]') ➞ False
1951
+ is_nested('[[][]]') ➞ True
1952
+ is_nested('[[]][[') ➞ True
1953
+ '''
1954
+ ",0.0,0.0,0.0
1955
+ "
1956
+
1957
+ def sum_squares(lst):
1958
+ """"""You are given a list of numbers.
1959
+ You need to return the sum of squared numbers in the given list,
1960
+ round each element in the list to the upper int(Ceiling) first.
1961
+ Examples:
1962
+ For lst = [1,2,3] the output should be 14
1963
+ For lst = [1,4,9] the output should be 98
1964
+ For lst = [1,3,5,7] the output should be 84
1965
+ For lst = [1.4,4.2,0] the output should be 29
1966
+ For lst = [-2.4,1,1] the output should be 6
1967
+
1968
+
1969
+ """"""
1970
+ ",0.0,0.0,0.0
1971
+ "
1972
+ def check_if_last_char_is_a_letter(txt):
1973
+ '''
1974
+ Create a function that returns True if the last character
1975
+ of a given string is an alphabetical character and is not
1976
+ a part of a word, and False otherwise.
1977
+ Note: ""word"" is a group of characters separated by space.
1978
+
1979
+ Examples:
1980
+ check_if_last_char_is_a_letter(""apple pie"") ➞ False
1981
+ check_if_last_char_is_a_letter(""apple pi e"") ➞ True
1982
+ check_if_last_char_is_a_letter(""apple pi e "") ➞ False
1983
+ check_if_last_char_is_a_letter("""") ➞ False
1984
+ '''
1985
+ ",0.050000000000000044,0.25,0.5
1986
+ "
1987
+ def can_arrange(arr):
1988
+ """"""Create a function which returns the largest index of an element which
1989
+ is not greater than or equal to the element immediately preceding it. If
1990
+ no such element exists then return -1. The given array will not contain
1991
+ duplicate values.
1992
+
1993
+ Examples:
1994
+ can_arrange([1,2,4,3,5]) = 3
1995
+ can_arrange([1,2,3]) = -1
1996
+ """"""
1997
+ ",0.0,0.0,0.0
1998
+ "
1999
+ def largest_smallest_integers(lst):
2000
+ '''
2001
+ Create a function that returns a tuple (a, b), where 'a' is
2002
+ the largest of negative integers, and 'b' is the smallest
2003
+ of positive integers in a list.
2004
+ If there is no negative or positive integers, return them as None.
2005
+
2006
+ Examples:
2007
+ largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
2008
+ largest_smallest_integers([]) == (None, None)
2009
+ largest_smallest_integers([0]) == (None, None)
2010
+ '''
2011
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
2012
+ "
2013
+ def compare_one(a, b):
2014
+ """"""
2015
+ Create a function that takes integers, floats, or strings representing
2016
+ real numbers, and returns the larger variable in its given variable type.
2017
+ Return None if the values are equal.
2018
+ Note: If a real number is represented as a string, the floating point might be . or ,
2019
+
2020
+ compare_one(1, 2.5) ➞ 2.5
2021
+ compare_one(1, ""2,3"") ➞ ""2,3""
2022
+ compare_one(""5,1"", ""6"") ➞ ""6""
2023
+ compare_one(""1"", 1) ➞ None
2024
+ """"""
2025
+ ",0.0,0.0,0.0
2026
+ "
2027
+ def is_equal_to_sum_even(n):
2028
+ """"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
2029
+ Example
2030
+ is_equal_to_sum_even(4) == False
2031
+ is_equal_to_sum_even(6) == False
2032
+ is_equal_to_sum_even(8) == True
2033
+ """"""
2034
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
2035
+ "
2036
+ def special_factorial(n):
2037
+ """"""The Brazilian factorial is defined as:
2038
+ brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
2039
+ where n > 0
2040
+
2041
+ For example:
2042
+ >>> special_factorial(4)
2043
+ 288
2044
+
2045
+ The function will receive an integer as input and should return the special
2046
+ factorial of this integer.
2047
+ """"""
2048
+ ",0.0,0.0,0.0
2049
+ "
2050
+ def fix_spaces(text):
2051
+ """"""
2052
+ Given a string text, replace all spaces in it with underscores,
2053
+ and if a string has more than 2 consecutive spaces,
2054
+ then replace all consecutive spaces with -
2055
+
2056
+ fix_spaces(""Example"") == ""Example""
2057
+ fix_spaces(""Example 1"") == ""Example_1""
2058
+ fix_spaces("" Example 2"") == ""_Example_2""
2059
+ fix_spaces("" Example 3"") == ""_Example-3""
2060
+ """"""
2061
+ ",0.0,0.0,0.0
2062
+ "
2063
+ def file_name_check(file_name):
2064
+ """"""Create a function which takes a string representing a file's name, and returns
2065
+ 'Yes' if the the file's name is valid, and returns 'No' otherwise.
2066
+ A file's name is considered to be valid if and only if all the following conditions
2067
+ are met:
2068
+ - There should not be more than three digits ('0'-'9') in the file's name.
2069
+ - The file's name contains exactly one dot '.'
2070
+ - The substring before the dot should not be empty, and it starts with a letter from
2071
+ the latin alphapet ('a'-'z' and 'A'-'Z').
2072
+ - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
2073
+ Examples:
2074
+ file_name_check(""example.txt"") # => 'Yes'
2075
+ file_name_check(""1example.dll"") # => 'No' (the name should start with a latin alphapet letter)
2076
+ """"""
2077
+ ",0.0,0.0,0.0
2078
+ "
2079
+
2080
+
2081
+ def sum_squares(lst):
2082
+ """"""""
2083
+ 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
2084
+ 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
2085
+ 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.
2086
+
2087
+ Examples:
2088
+ For lst = [1,2,3] the output should be 6
2089
+ For lst = [] the output should be 0
2090
+ For lst = [-1,-5,2,-1,-5] the output should be -126
2091
+ """"""
2092
+ ",0.0,0.0,0.0
2093
+ "
2094
+ def words_in_sentence(sentence):
2095
+ """"""
2096
+ You are given a string representing a sentence,
2097
+ the sentence contains some words separated by a space,
2098
+ and you have to return a string that contains the words from the original sentence,
2099
+ whose lengths are prime numbers,
2100
+ the order of the words in the new string should be the same as the original one.
2101
+
2102
+ Example 1:
2103
+ Input: sentence = ""This is a test""
2104
+ Output: ""is""
2105
+
2106
+ Example 2:
2107
+ Input: sentence = ""lets go for swimming""
2108
+ Output: ""go for""
2109
+
2110
+ Constraints:
2111
+ * 1 <= len(sentence) <= 100
2112
+ * sentence contains only letters
2113
+ """"""
2114
+ ",0.7,0.9996130030959752,1.0
2115
+ "
2116
+ def simplify(x, n):
2117
+ """"""Your task is to implement a function that will simplify the expression
2118
+ x * n. The function returns True if x * n evaluates to a whole number and False
2119
+ otherwise. Both x and n, are string representation of a fraction, and have the following format,
2120
+ <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
2121
+
2122
+ You can assume that x, and n are valid fractions, and do not have zero as denominator.
2123
+
2124
+ simplify(""1/5"", ""5/1"") = True
2125
+ simplify(""1/6"", ""2/1"") = False
2126
+ simplify(""7/10"", ""10/2"") = False
2127
+ """"""
2128
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
2129
+ "
2130
+ def order_by_points(nums):
2131
+ """"""
2132
+ Write a function which sorts the given list of integers
2133
+ in ascending order according to the sum of their digits.
2134
+ Note: if there are several items with similar sum of their digits,
2135
+ order them based on their index in original list.
2136
+
2137
+ For example:
2138
+ >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
2139
+ >>> order_by_points([]) == []
2140
+ """"""
2141
+ ",0.0,0.0,0.0
2142
+ "
2143
+ def specialFilter(nums):
2144
+ """"""Write a function that takes an array of numbers as input and returns
2145
+ the number of elements in the array that are greater than 10 and both
2146
+ first and last digits of a number are odd (1, 3, 5, 7, 9).
2147
+ For example:
2148
+ specialFilter([15, -73, 14, -15]) => 1
2149
+ specialFilter([33, -2, -3, 45, 21, 109]) => 2
2150
+ """"""
2151
+ ",0.050000000000000044,0.25,0.5
2152
+ "
2153
+ def get_max_triples(n):
2154
+ """"""
2155
+ You are given a positive integer n. You have to create an integer array a of length n.
2156
+ For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
2157
+ Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
2158
+ and a[i] + a[j] + a[k] is a multiple of 3.
2159
+
2160
+ Example :
2161
+ Input: n = 5
2162
+ Output: 1
2163
+ Explanation:
2164
+ a = [1, 3, 7, 13, 21]
2165
+ The only valid triple is (1, 7, 13).
2166
+ """"""
2167
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2168
+ "
2169
+ def bf(planet1, planet2):
2170
+ '''
2171
+ There are eight planets in our solar system: the closerst to the Sun
2172
+ is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
2173
+ Uranus, Neptune.
2174
+ Write a function that takes two planet names as strings planet1 and planet2.
2175
+ The function should return a tuple containing all planets whose orbits are
2176
+ located between the orbit of planet1 and the orbit of planet2, sorted by
2177
+ the proximity to the sun.
2178
+ The function should return an empty tuple if planet1 or planet2
2179
+ are not correct planet names.
2180
+ Examples
2181
+ bf(""Jupiter"", ""Neptune"") ==> (""Saturn"", ""Uranus"")
2182
+ bf(""Earth"", ""Mercury"") ==> (""Venus"")
2183
+ bf(""Mercury"", ""Uranus"") ==> (""Venus"", ""Earth"", ""Mars"", ""Jupiter"", ""Saturn"")
2184
+ '''
2185
+ ",0.85,1.0,1.0
2186
+ "
2187
+ def sorted_list_sum(lst):
2188
+ """"""Write a function that accepts a list of strings as a parameter,
2189
+ deletes the strings that have odd lengths from it,
2190
+ and returns the resulted list with a sorted order,
2191
+ The list is always a list of strings and never an array of numbers,
2192
+ and it may contain duplicates.
2193
+ The order of the list should be ascending by length of each word, and you
2194
+ should return the list sorted by that rule.
2195
+ If two words have the same length, sort the list alphabetically.
2196
+ The function should return a list of strings in sorted order.
2197
+ You may assume that all words will have the same length.
2198
+ For example:
2199
+ assert list_sort([""aa"", ""a"", ""aaa""]) => [""aa""]
2200
+ assert list_sort([""ab"", ""a"", ""aaa"", ""cd""]) => [""ab"", ""cd""]
2201
+ """"""
2202
+ ",0.0,0.0,0.0
2203
+ "
2204
+ def x_or_y(n, x, y):
2205
+ """"""A simple program which should return the value of x if n is
2206
+ a prime number and should return the value of y otherwise.
2207
+
2208
+ Examples:
2209
+ for x_or_y(7, 34, 12) == 34
2210
+ for x_or_y(15, 8, 5) == 5
2211
+
2212
+ """"""
2213
+ ",0.0,0.0,0.0
2214
+ "
2215
+ def double_the_difference(lst):
2216
+ '''
2217
+ Given a list of numbers, return the sum of squares of the numbers
2218
+ in the list that are odd. Ignore numbers that are negative or not integers.
2219
+
2220
+ double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
2221
+ double_the_difference([-1, -2, 0]) == 0
2222
+ double_the_difference([9, -2]) == 81
2223
+ double_the_difference([0]) == 0
2224
+
2225
+ If the input list is empty, return 0.
2226
+ '''
2227
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2228
+ "
2229
+ def compare(game,guess):
2230
+ """"""I think we all remember that feeling when the result of some long-awaited
2231
+ event is finally known. The feelings and thoughts you have at that moment are
2232
+ definitely worth noting down and comparing.
2233
+ Your task is to determine if a person correctly guessed the results of a number of matches.
2234
+ You are given two arrays of scores and guesses of equal length, where each index shows a match.
2235
+ Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
2236
+ the value is 0, and if not, the value is the absolute difference between the guess and the score.
2237
+
2238
+
2239
+ example:
2240
+
2241
+ compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
2242
+ compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
2243
+ """"""
2244
+ ",0.8999999999999999,1.0,1.0
2245
+ "
2246
+ def Strongest_Extension(class_name, extensions):
2247
+ """"""You will be given the name of a class (a string) and a list of extensions.
2248
+ The extensions are to be used to load additional classes to the class. The
2249
+ strength of the extension is as follows: Let CAP be the number of the uppercase
2250
+ letters in the extension's name, and let SM be the number of lowercase letters
2251
+ in the extension's name, the strength is given by the fraction CAP - SM.
2252
+ You should find the strongest extension and return a string in this
2253
+ format: ClassName.StrongestExtensionName.
2254
+ If there are two or more extensions with the same strength, you should
2255
+ choose the one that comes first in the list.
2256
+ For example, if you are given ""Slices"" as the class and a list of the
2257
+ extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
2258
+ return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
2259
+ (its strength is -1).
2260
+ Example:
2261
+ for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
2262
+ """"""
2263
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
2264
+ "
2265
+ def cycpattern_check(a , b):
2266
+ """"""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
2267
+ cycpattern_check(""abcd"",""abd"") => False
2268
+ cycpattern_check(""hello"",""ell"") => True
2269
+ cycpattern_check(""whassup"",""psus"") => False
2270
+ cycpattern_check(""abab"",""baa"") => True
2271
+ cycpattern_check(""efef"",""eeff"") => False
2272
+ cycpattern_check(""himenss"",""simen"") => True
2273
+
2274
+ """"""
2275
+ ",0.050000000000000044,0.25,0.5
2276
+ "
2277
+ def even_odd_count(num):
2278
+ """"""Given an integer. return a tuple that has the number of even and odd digits respectively.
2279
+
2280
+ Example:
2281
+ even_odd_count(-12) ==> (1, 1)
2282
+ even_odd_count(123) ==> (1, 2)
2283
+ """"""
2284
+ ",0.6000000000000001,0.9963880288957688,1.0
2285
+ "
2286
+ def int_to_mini_roman(number):
2287
+ """"""
2288
+ Given a positive integer, obtain its roman numeral equivalent as a string,
2289
+ and return it in lowercase.
2290
+ Restrictions: 1 <= num <= 1000
2291
+
2292
+ Examples:
2293
+ >>> int_to_mini_roman(19) == 'xix'
2294
+ >>> int_to_mini_roman(152) == 'clii'
2295
+ >>> int_to_mini_roman(426) == 'cdxxvi'
2296
+ """"""
2297
+ ",0.6000000000000001,0.9963880288957688,1.0
2298
+ "
2299
+ def right_angle_triangle(a, b, c):
2300
+ '''
2301
+ Given the lengths of the three sides of a triangle. Return True if the three
2302
+ sides form a right-angled triangle, False otherwise.
2303
+ A right-angled triangle is a triangle in which one angle is right angle or
2304
+ 90 degree.
2305
+ Example:
2306
+ right_angle_triangle(3, 4, 5) == True
2307
+ right_angle_triangle(1, 2, 3) == False
2308
+ '''
2309
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
2310
+ "
2311
+ def find_max(words):
2312
+ """"""Write a function that accepts a list of strings.
2313
+ The list contains different words. Return the word with maximum number
2314
+ of unique characters. If multiple strings have maximum number of unique
2315
+ characters, return the one which comes first in lexicographical order.
2316
+
2317
+ find_max([""name"", ""of"", ""string""]) == ""string""
2318
+ find_max([""name"", ""enam"", ""game""]) == ""enam""
2319
+ find_max([""aaaaaaa"", ""bb"" ,""cc""]) == """"aaaaaaa""
2320
+ """"""
2321
+ ",0.85,1.0,1.0
2322
+ "
2323
+ def eat(number, need, remaining):
2324
+ """"""
2325
+ You're a hungry rabbit, and you already have eaten a certain number of carrots,
2326
+ but now you need to eat more carrots to complete the day's meals.
2327
+ you should return an array of [ total number of eaten carrots after your meals,
2328
+ the number of carrots left after your meals ]
2329
+ if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
2330
+
2331
+ Example:
2332
+ * eat(5, 6, 10) -> [11, 4]
2333
+ * eat(4, 8, 9) -> [12, 1]
2334
+ * eat(1, 10, 10) -> [11, 0]
2335
+ * eat(2, 11, 5) -> [7, 0]
2336
+
2337
+ Variables:
2338
+ @number : integer
2339
+ the number of carrots that you have eaten.
2340
+ @need : integer
2341
+ the number of carrots that you need to eat.
2342
+ @remaining : integer
2343
+ the number of remaining carrots thet exist in stock
2344
+
2345
+ Constrain:
2346
+ * 0 <= number <= 1000
2347
+ * 0 <= need <= 1000
2348
+ * 0 <= remaining <= 1000
2349
+
2350
+ Have fun :)
2351
+ """"""
2352
+ ",0.4,0.9489164086687306,0.9996427720885925
2353
+ "
2354
+ def do_algebra(operator, operand):
2355
+ """"""
2356
+ Given two lists operator, and operand. The first list has basic algebra operations, and
2357
+ the second list is a list of integers. Use the two given lists to build the algebric
2358
+ expression and return the evaluation of this expression.
2359
+
2360
+ The basic algebra operations:
2361
+ Addition ( + )
2362
+ Subtraction ( - )
2363
+ Multiplication ( * )
2364
+ Floor division ( // )
2365
+ Exponentiation ( ** )
2366
+
2367
+ Example:
2368
+ operator['+', '*', '-']
2369
+ array = [2, 3, 4, 5]
2370
+ result = 2 + 3 * 4 - 5
2371
+ => result = 9
2372
+
2373
+ Note:
2374
+ The length of operator list is equal to the length of operand list minus one.
2375
+ Operand is a list of of non-negative integers.
2376
+ Operator list has at least one operator, and operand list has at least two operands.
2377
+
2378
+ """"""
2379
+ ",0.0,0.0,0.0
2380
+ "
2381
+ def solve(s):
2382
+ """"""You are given a string s.
2383
+ if s[i] is a letter, reverse its case from lower to upper or vise versa,
2384
+ otherwise keep it as it is.
2385
+ If the string contains no letters, reverse the string.
2386
+ The function should return the resulted string.
2387
+ Examples
2388
+ solve(""1234"") = ""4321""
2389
+ solve(""ab"") = ""AB""
2390
+ solve(""#a@C"") = ""#A@c""
2391
+ """"""
2392
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2393
+ "
2394
+ def string_to_md5(text):
2395
+ """"""
2396
+ Given a string 'text', return its md5 hash equivalent string.
2397
+ If 'text' is an empty string, return None.
2398
+
2399
+ >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
2400
+ """"""
2401
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2402
+ "
2403
+ def generate_integers(a, b):
2404
+ """"""
2405
+ Given two positive integers a and b, return the even digits between a
2406
+ and b, in ascending order.
2407
+
2408
+ For example:
2409
+ generate_integers(2, 8) => [2, 4, 6, 8]
2410
+ generate_integers(8, 2) => [2, 4, 6, 8]
2411
+ generate_integers(10, 14) => []
2412
+ """"""
2413
+ ",0.0,0.0,0.0
data/coding/humaneval/csv/3.csv ADDED
@@ -0,0 +1,2413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt,pass@1,pass@5,pass@10
2
+ "from typing import List
3
+
4
+
5
+ def has_close_elements(numbers: List[float], threshold: float) -> bool:
6
+ """""" Check if in given list of numbers, are any two numbers closer to each other than
7
+ given threshold.
8
+ >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
9
+ False
10
+ >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
11
+ True
12
+ """"""
13
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
14
+ "from typing import List
15
+
16
+
17
+ def separate_paren_groups(paren_string: str) -> List[str]:
18
+ """""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
19
+ separate those group into separate strings and return the list of those.
20
+ Separate groups are balanced (each open brace is properly closed) and not nested within each other
21
+ Ignore any spaces in the input string.
22
+ >>> separate_paren_groups('( ) (( )) (( )( ))')
23
+ ['()', '(())', '(()())']
24
+ """"""
25
+ ",0.0,0.0,0.0
26
+ "
27
+
28
+ def truncate_number(number: float) -> float:
29
+ """""" Given a positive floating point number, it can be decomposed into
30
+ and integer part (largest integer smaller than given number) and decimals
31
+ (leftover part always smaller than 1).
32
+
33
+ Return the decimal part of the number.
34
+ >>> truncate_number(3.5)
35
+ 0.5
36
+ """"""
37
+ ",0.25,0.8063080495356036,0.9837461300309598
38
+ "from typing import List
39
+
40
+
41
+ def below_zero(operations: List[int]) -> bool:
42
+ """""" You're given a list of deposit and withdrawal operations on a bank account that starts with
43
+ zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
44
+ at that point function should return True. Otherwise it should return False.
45
+ >>> below_zero([1, 2, 3])
46
+ False
47
+ >>> below_zero([1, 2, -4, 5])
48
+ True
49
+ """"""
50
+ ",1.0,1.0,1.0
51
+ "from typing import List
52
+
53
+
54
+ def mean_absolute_deviation(numbers: List[float]) -> float:
55
+ """""" For a given list of input numbers, calculate Mean Absolute Deviation
56
+ around the mean of this dataset.
57
+ Mean Absolute Deviation is the average absolute difference between each
58
+ element and a centerpoint (mean in this case):
59
+ MAD = average | x - x_mean |
60
+ >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
61
+ 1.0
62
+ """"""
63
+ ",1.0,1.0,1.0
64
+ "from typing import List
65
+
66
+
67
+ def intersperse(numbers: List[int], delimeter: int) -> List[int]:
68
+ """""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
69
+ >>> intersperse([], 4)
70
+ []
71
+ >>> intersperse([1, 2, 3], 4)
72
+ [1, 4, 2, 4, 3]
73
+ """"""
74
+ ",0.0,0.0,0.0
75
+ "from typing import List
76
+
77
+
78
+ def parse_nested_parens(paren_string: str) -> List[int]:
79
+ """""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
80
+ For each of the group, output the deepest level of nesting of parentheses.
81
+ E.g. (()()) has maximum two levels of nesting while ((())) has three.
82
+
83
+ >>> parse_nested_parens('(()()) ((())) () ((())()())')
84
+ [2, 3, 1, 3]
85
+ """"""
86
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
87
+ "from typing import List
88
+
89
+
90
+ def filter_by_substring(strings: List[str], substring: str) -> List[str]:
91
+ """""" Filter an input list of strings only for ones that contain given substring
92
+ >>> filter_by_substring([], 'a')
93
+ []
94
+ >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
95
+ ['abc', 'bacd', 'array']
96
+ """"""
97
+ ",0.95,1.0,1.0
98
+ "from typing import List, Tuple
99
+
100
+
101
+ def sum_product(numbers: List[int]) -> Tuple[int, int]:
102
+ """""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
103
+ Empty sum should be equal to 0 and empty product should be equal to 1.
104
+ >>> sum_product([])
105
+ (0, 1)
106
+ >>> sum_product([1, 2, 3, 4])
107
+ (10, 24)
108
+ """"""
109
+ ",1.0,1.0,1.0
110
+ "from typing import List, Tuple
111
+
112
+
113
+ def rolling_max(numbers: List[int]) -> List[int]:
114
+ """""" From a given list of integers, generate a list of rolling maximum element found until given moment
115
+ in the sequence.
116
+ >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
117
+ [1, 2, 3, 3, 3, 4, 4]
118
+ """"""
119
+ ",0.25,0.8063080495356036,0.9837461300309598
120
+ "
121
+
122
+ def is_palindrome(string: str) -> bool:
123
+ """""" Test if given string is a palindrome """"""
124
+ return string == string[::-1]
125
+
126
+
127
+ def make_palindrome(string: str) -> str:
128
+ """""" Find the shortest palindrome that begins with a supplied string.
129
+ Algorithm idea is simple:
130
+ - Find the longest postfix of supplied string that is a palindrome.
131
+ - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
132
+ >>> make_palindrome('')
133
+ ''
134
+ >>> make_palindrome('cat')
135
+ 'catac'
136
+ >>> make_palindrome('cata')
137
+ 'catac'
138
+ """"""
139
+ ",0.0,0.0,0.0
140
+ "from typing import List
141
+
142
+
143
+ def string_xor(a: str, b: str) -> str:
144
+ """""" Input are two strings a and b consisting only of 1s and 0s.
145
+ Perform binary XOR on these inputs and return result also as a string.
146
+ >>> string_xor('010', '110')
147
+ '100'
148
+ """"""
149
+ ",0.7,0.9996130030959752,1.0
150
+ "from typing import List, Optional
151
+
152
+
153
+ def longest(strings: List[str]) -> Optional[str]:
154
+ """""" Out of list of strings, return the longest one. Return the first one in case of multiple
155
+ strings of the same length. Return None in case the input list is empty.
156
+ >>> longest([])
157
+
158
+ >>> longest(['a', 'b', 'c'])
159
+ 'a'
160
+ >>> longest(['a', 'bb', 'ccc'])
161
+ 'ccc'
162
+ """"""
163
+ ",1.0,1.0,1.0
164
+ "
165
+
166
+ def greatest_common_divisor(a: int, b: int) -> int:
167
+ """""" Return a greatest common divisor of two integers a and b
168
+ >>> greatest_common_divisor(3, 5)
169
+ 1
170
+ >>> greatest_common_divisor(25, 15)
171
+ 5
172
+ """"""
173
+ ",0.4,0.9489164086687306,0.9996427720885925
174
+ "from typing import List
175
+
176
+
177
+ def all_prefixes(string: str) -> List[str]:
178
+ """""" Return list of all prefixes from shortest to longest of the input string
179
+ >>> all_prefixes('abc')
180
+ ['a', 'ab', 'abc']
181
+ """"""
182
+ ",0.050000000000000044,0.25,0.5
183
+ "
184
+
185
+ def string_sequence(n: int) -> str:
186
+ """""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
187
+ >>> string_sequence(0)
188
+ '0'
189
+ >>> string_sequence(5)
190
+ '0 1 2 3 4 5'
191
+ """"""
192
+ ",0.8999999999999999,1.0,1.0
193
+ "
194
+
195
+ def count_distinct_characters(string: str) -> int:
196
+ """""" Given a string, find out how many distinct characters (regardless of case) does it consist of
197
+ >>> count_distinct_characters('xyzXYZ')
198
+ 3
199
+ >>> count_distinct_characters('Jerry')
200
+ 4
201
+ """"""
202
+ ",0.4,0.9489164086687306,0.9996427720885925
203
+ "from typing import List
204
+
205
+
206
+ def parse_music(music_string: str) -> List[int]:
207
+ """""" Input to this function is a string representing musical notes in a special ASCII format.
208
+ Your task is to parse this string and return list of integers corresponding to how many beats does each
209
+ not last.
210
+
211
+ Here is a legend:
212
+ 'o' - whole note, lasts four beats
213
+ 'o|' - half note, lasts two beats
214
+ '.|' - quater note, lasts one beat
215
+
216
+ >>> parse_music('o o| .| o| o| .| .| .| .| o o')
217
+ [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
218
+ """"""
219
+ ",0.85,1.0,1.0
220
+ "
221
+
222
+ def how_many_times(string: str, substring: str) -> int:
223
+ """""" Find how many times a given substring can be found in the original string. Count overlaping cases.
224
+ >>> how_many_times('', 'a')
225
+ 0
226
+ >>> how_many_times('aaa', 'a')
227
+ 3
228
+ >>> how_many_times('aaaa', 'aa')
229
+ 3
230
+ """"""
231
+ ",0.7,0.9996130030959752,1.0
232
+ "from typing import List
233
+
234
+
235
+ def sort_numbers(numbers: str) -> str:
236
+ """""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
237
+ Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
238
+ Return the string with numbers sorted from smallest to largest
239
+ >>> sort_numbers('three one five')
240
+ 'one three five'
241
+ """"""
242
+ ",0.0,0.0,0.0
243
+ "from typing import List, Tuple
244
+
245
+
246
+ def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
247
+ """""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
248
+ other and return them in order (smaller number, larger number).
249
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
250
+ (2.0, 2.2)
251
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
252
+ (2.0, 2.0)
253
+ """"""
254
+ ",0.6000000000000001,0.9963880288957688,1.0
255
+ "from typing import List
256
+
257
+
258
+ def rescale_to_unit(numbers: List[float]) -> List[float]:
259
+ """""" Given list of numbers (of at least two elements), apply a linear transform to that list,
260
+ such that the smallest number will become 0 and the largest will become 1
261
+ >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
262
+ [0.0, 0.25, 0.5, 0.75, 1.0]
263
+ """"""
264
+ ",0.8999999999999999,1.0,1.0
265
+ "from typing import List, Any
266
+
267
+
268
+ def filter_integers(values: List[Any]) -> List[int]:
269
+ """""" Filter given list of any python values only for integers
270
+ >>> filter_integers(['a', 3.14, 5])
271
+ [5]
272
+ >>> filter_integers([1, 2, 3, 'abc', {}, []])
273
+ [1, 2, 3]
274
+ """"""
275
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
276
+ "
277
+
278
+ def strlen(string: str) -> int:
279
+ """""" Return length of given string
280
+ >>> strlen('')
281
+ 0
282
+ >>> strlen('abc')
283
+ 3
284
+ """"""
285
+ ",0.75,0.9999355005159959,1.0
286
+ "
287
+
288
+ def largest_divisor(n: int) -> int:
289
+ """""" For a given number n, find the largest number that divides n evenly, smaller than n
290
+ >>> largest_divisor(15)
291
+ 5
292
+ """"""
293
+ ",0.0,0.0,0.0
294
+ "from typing import List
295
+
296
+
297
+ def factorize(n: int) -> List[int]:
298
+ """""" Return list of prime factors of given integer in the order from smallest to largest.
299
+ Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
300
+ Input number should be equal to the product of all factors
301
+ >>> factorize(8)
302
+ [2, 2, 2]
303
+ >>> factorize(25)
304
+ [5, 5]
305
+ >>> factorize(70)
306
+ [2, 5, 7]
307
+ """"""
308
+ ",1.0,1.0,1.0
309
+ "from typing import List
310
+
311
+
312
+ def remove_duplicates(numbers: List[int]) -> List[int]:
313
+ """""" From a list of integers, remove all elements that occur more than once.
314
+ Keep order of elements left the same as in the input.
315
+ >>> remove_duplicates([1, 2, 3, 2, 4])
316
+ [1, 3, 4]
317
+ """"""
318
+ ",0.050000000000000044,0.25,0.5
319
+ "
320
+
321
+ def flip_case(string: str) -> str:
322
+ """""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
323
+ >>> flip_case('Hello')
324
+ 'hELLO'
325
+ """"""
326
+ ",0.95,1.0,1.0
327
+ "from typing import List
328
+
329
+
330
+ def concatenate(strings: List[str]) -> str:
331
+ """""" Concatenate list of strings into a single string
332
+ >>> concatenate([])
333
+ ''
334
+ >>> concatenate(['a', 'b', 'c'])
335
+ 'abc'
336
+ """"""
337
+ ",0.85,1.0,1.0
338
+ "from typing import List
339
+
340
+
341
+ def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
342
+ """""" Filter an input list of strings only for ones that start with a given prefix.
343
+ >>> filter_by_prefix([], 'a')
344
+ []
345
+ >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
346
+ ['abc', 'array']
347
+ """"""
348
+ ",0.95,1.0,1.0
349
+ "
350
+
351
+ def get_positive(l: list):
352
+ """"""Return only positive numbers in the list.
353
+ >>> get_positive([-1, 2, -4, 5, 6])
354
+ [2, 5, 6]
355
+ >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
356
+ [5, 3, 2, 3, 9, 123, 1]
357
+ """"""
358
+ ",0.75,0.9999355005159959,1.0
359
+ "
360
+
361
+ def is_prime(n):
362
+ """"""Return true if a given number is prime, and false otherwise.
363
+ >>> is_prime(6)
364
+ False
365
+ >>> is_prime(101)
366
+ True
367
+ >>> is_prime(11)
368
+ True
369
+ >>> is_prime(13441)
370
+ True
371
+ >>> is_prime(61)
372
+ True
373
+ >>> is_prime(4)
374
+ False
375
+ >>> is_prime(1)
376
+ False
377
+ """"""
378
+ ",0.7,0.9996130030959752,1.0
379
+ "import math
380
+
381
+
382
+ def poly(xs: list, x: float):
383
+ """"""
384
+ Evaluates polynomial with coefficients xs at point x.
385
+ return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
386
+ """"""
387
+ return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])
388
+
389
+
390
+ def find_zero(xs: list):
391
+ """""" xs are coefficients of a polynomial.
392
+ find_zero find x such that poly(x) = 0.
393
+ find_zero returns only only zero point, even if there are many.
394
+ Moreover, find_zero only takes list xs having even number of coefficients
395
+ and largest non zero coefficient as it guarantees
396
+ a solution.
397
+ >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
398
+ -0.5
399
+ >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
400
+ 1.0
401
+ """"""
402
+ ",0.0,0.0,0.0
403
+ "
404
+
405
+ def sort_third(l: list):
406
+ """"""This function takes a list l and returns a list l' such that
407
+ 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
408
+ to the values of the corresponding indicies of l, but sorted.
409
+ >>> sort_third([1, 2, 3])
410
+ [1, 2, 3]
411
+ >>> sort_third([5, 6, 3, 4, 8, 9, 2])
412
+ [2, 6, 3, 4, 8, 9, 5]
413
+ """"""
414
+ ",0.050000000000000044,0.25,0.5
415
+ "
416
+
417
+ def unique(l: list):
418
+ """"""Return sorted unique elements in a list
419
+ >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
420
+ [0, 2, 3, 5, 9, 123]
421
+ """"""
422
+ ",0.65,0.9986455108359134,1.0
423
+ "
424
+
425
+ def max_element(l: list):
426
+ """"""Return maximum element in the list.
427
+ >>> max_element([1, 2, 3])
428
+ 3
429
+ >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
430
+ 123
431
+ """"""
432
+ ",0.65,0.9986455108359134,1.0
433
+ "
434
+
435
+ def fizz_buzz(n: int):
436
+ """"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
437
+ >>> fizz_buzz(50)
438
+ 0
439
+ >>> fizz_buzz(78)
440
+ 2
441
+ >>> fizz_buzz(79)
442
+ 3
443
+ """"""
444
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
445
+ "
446
+
447
+ def sort_even(l: list):
448
+ """"""This function takes a list l and returns a list l' such that
449
+ l' is identical to l in the odd indicies, while its values at the even indicies are equal
450
+ to the values of the even indicies of l, but sorted.
451
+ >>> sort_even([1, 2, 3])
452
+ [1, 2, 3]
453
+ >>> sort_even([5, 6, 3, 4])
454
+ [3, 6, 5, 4]
455
+ """"""
456
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
457
+ "
458
+
459
+ def encode_cyclic(s: str):
460
+ """"""
461
+ returns encoded string by cycling groups of three characters.
462
+ """"""
463
+ # split string to groups. Each of length 3.
464
+ groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
465
+ # cycle elements in each group. Unless group has fewer elements than 3.
466
+ groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
467
+ return """".join(groups)
468
+
469
+
470
+ def decode_cyclic(s: str):
471
+ """"""
472
+ takes as input string encoded with encode_cyclic function. Returns decoded string.
473
+ """"""
474
+ ",0.0,0.0,0.0
475
+ "
476
+
477
+ def prime_fib(n: int):
478
+ """"""
479
+ prime_fib returns n-th number that is a Fibonacci number and it's also prime.
480
+ >>> prime_fib(1)
481
+ 2
482
+ >>> prime_fib(2)
483
+ 3
484
+ >>> prime_fib(3)
485
+ 5
486
+ >>> prime_fib(4)
487
+ 13
488
+ >>> prime_fib(5)
489
+ 89
490
+ """"""
491
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
492
+ "
493
+
494
+ def triples_sum_to_zero(l: list):
495
+ """"""
496
+ triples_sum_to_zero takes a list of integers as an input.
497
+ it returns True if there are three distinct elements in the list that
498
+ sum to zero, and False otherwise.
499
+
500
+ >>> triples_sum_to_zero([1, 3, 5, 0])
501
+ False
502
+ >>> triples_sum_to_zero([1, 3, -2, 1])
503
+ True
504
+ >>> triples_sum_to_zero([1, 2, 3, 7])
505
+ False
506
+ >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
507
+ True
508
+ >>> triples_sum_to_zero([1])
509
+ False
510
+ """"""
511
+ ",0.65,0.9986455108359134,1.0
512
+ "
513
+
514
+ def car_race_collision(n: int):
515
+ """"""
516
+ Imagine a road that's a perfectly straight infinitely long line.
517
+ n cars are driving left to right; simultaneously, a different set of n cars
518
+ are driving right to left. The two sets of cars start out being very far from
519
+ each other. All cars move in the same speed. Two cars are said to collide
520
+ when a car that's moving left to right hits a car that's moving right to left.
521
+ However, the cars are infinitely sturdy and strong; as a result, they continue moving
522
+ in their trajectory as if they did not collide.
523
+
524
+ This function outputs the number of such collisions.
525
+ """"""
526
+ ",0.050000000000000044,0.25,0.5
527
+ "
528
+
529
+ def incr_list(l: list):
530
+ """"""Return list with elements incremented by 1.
531
+ >>> incr_list([1, 2, 3])
532
+ [2, 3, 4]
533
+ >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
534
+ [6, 4, 6, 3, 4, 4, 10, 1, 124]
535
+ """"""
536
+ ",0.7999999999999999,1.0,1.0
537
+ "
538
+
539
+ def pairs_sum_to_zero(l):
540
+ """"""
541
+ pairs_sum_to_zero takes a list of integers as an input.
542
+ it returns True if there are two distinct elements in the list that
543
+ sum to zero, and False otherwise.
544
+ >>> pairs_sum_to_zero([1, 3, 5, 0])
545
+ False
546
+ >>> pairs_sum_to_zero([1, 3, -2, 1])
547
+ False
548
+ >>> pairs_sum_to_zero([1, 2, 3, 7])
549
+ False
550
+ >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
551
+ True
552
+ >>> pairs_sum_to_zero([1])
553
+ False
554
+ """"""
555
+ ",1.0,1.0,1.0
556
+ "
557
+
558
+ def change_base(x: int, base: int):
559
+ """"""Change numerical base of input number x to base.
560
+ return string representation after the conversion.
561
+ base numbers are less than 10.
562
+ >>> change_base(8, 3)
563
+ '22'
564
+ >>> change_base(8, 2)
565
+ '1000'
566
+ >>> change_base(7, 2)
567
+ '111'
568
+ """"""
569
+ ",0.050000000000000044,0.25,0.5
570
+ "
571
+
572
+ def triangle_area(a, h):
573
+ """"""Given length of a side and high return area for a triangle.
574
+ >>> triangle_area(5, 3)
575
+ 7.5
576
+ """"""
577
+ ",0.85,1.0,1.0
578
+ "
579
+
580
+ def fib4(n: int):
581
+ """"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
582
+ fib4(0) -> 0
583
+ fib4(1) -> 0
584
+ fib4(2) -> 2
585
+ fib4(3) -> 0
586
+ fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
587
+ Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
588
+ >>> fib4(5)
589
+ 4
590
+ >>> fib4(6)
591
+ 8
592
+ >>> fib4(7)
593
+ 14
594
+ """"""
595
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
596
+ "
597
+
598
+ def median(l: list):
599
+ """"""Return median of elements in the list l.
600
+ >>> median([3, 1, 2, 4, 5])
601
+ 3
602
+ >>> median([-10, 4, 6, 1000, 10, 20])
603
+ 15.0
604
+ """"""
605
+ ",0.7,0.9996130030959752,1.0
606
+ "
607
+
608
+ def is_palindrome(text: str):
609
+ """"""
610
+ Checks if given string is a palindrome
611
+ >>> is_palindrome('')
612
+ True
613
+ >>> is_palindrome('aba')
614
+ True
615
+ >>> is_palindrome('aaaaa')
616
+ True
617
+ >>> is_palindrome('zbcd')
618
+ False
619
+ """"""
620
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
621
+ "
622
+
623
+ def modp(n: int, p: int):
624
+ """"""Return 2^n modulo p (be aware of numerics).
625
+ >>> modp(3, 5)
626
+ 3
627
+ >>> modp(1101, 101)
628
+ 2
629
+ >>> modp(0, 101)
630
+ 1
631
+ >>> modp(3, 11)
632
+ 8
633
+ >>> modp(100, 101)
634
+ 1
635
+ """"""
636
+ ",0.050000000000000044,0.25,0.5
637
+ "
638
+
639
+ def encode_shift(s: str):
640
+ """"""
641
+ returns encoded string by shifting every character by 5 in the alphabet.
642
+ """"""
643
+ return """".join([chr(((ord(ch) + 5 - ord(""a"")) % 26) + ord(""a"")) for ch in s])
644
+
645
+
646
+ def decode_shift(s: str):
647
+ """"""
648
+ takes as input string encoded with encode_shift function. Returns decoded string.
649
+ """"""
650
+ ",1.0,1.0,1.0
651
+ "
652
+
653
+ def remove_vowels(text):
654
+ """"""
655
+ remove_vowels is a function that takes string and returns string without vowels.
656
+ >>> remove_vowels('')
657
+ ''
658
+ >>> remove_vowels(""abcdef\nghijklm"")
659
+ 'bcdf\nghjklm'
660
+ >>> remove_vowels('abcdef')
661
+ 'bcdf'
662
+ >>> remove_vowels('aaaaa')
663
+ ''
664
+ >>> remove_vowels('aaBAA')
665
+ 'B'
666
+ >>> remove_vowels('zbcd')
667
+ 'zbcd'
668
+ """"""
669
+ ",0.85,1.0,1.0
670
+ "
671
+
672
+ def below_threshold(l: list, t: int):
673
+ """"""Return True if all numbers in the list l are below threshold t.
674
+ >>> below_threshold([1, 2, 4, 10], 100)
675
+ True
676
+ >>> below_threshold([1, 20, 4, 10], 5)
677
+ False
678
+ """"""
679
+ ",0.7999999999999999,1.0,1.0
680
+ "
681
+
682
+ def add(x: int, y: int):
683
+ """"""Add two numbers x and y
684
+ >>> add(2, 3)
685
+ 5
686
+ >>> add(5, 7)
687
+ 12
688
+ """"""
689
+ ",0.95,1.0,1.0
690
+ "
691
+
692
+ def same_chars(s0: str, s1: str):
693
+ """"""
694
+ Check if two words have the same characters.
695
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
696
+ True
697
+ >>> same_chars('abcd', 'dddddddabc')
698
+ True
699
+ >>> same_chars('dddddddabc', 'abcd')
700
+ True
701
+ >>> same_chars('eabcd', 'dddddddabc')
702
+ False
703
+ >>> same_chars('abcd', 'dddddddabce')
704
+ False
705
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
706
+ False
707
+ """"""
708
+ ",0.8999999999999999,1.0,1.0
709
+ "
710
+
711
+ def fib(n: int):
712
+ """"""Return n-th Fibonacci number.
713
+ >>> fib(10)
714
+ 55
715
+ >>> fib(1)
716
+ 1
717
+ >>> fib(8)
718
+ 21
719
+ """"""
720
+ ",0.8999999999999999,1.0,1.0
721
+ "
722
+
723
+ def correct_bracketing(brackets: str):
724
+ """""" brackets is a string of ""<"" and "">"".
725
+ return True if every opening bracket has a corresponding closing bracket.
726
+
727
+ >>> correct_bracketing(""<"")
728
+ False
729
+ >>> correct_bracketing(""<>"")
730
+ True
731
+ >>> correct_bracketing(""<<><>>"")
732
+ True
733
+ >>> correct_bracketing(""><<>"")
734
+ False
735
+ """"""
736
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
737
+ "
738
+
739
+ def monotonic(l: list):
740
+ """"""Return True is list elements are monotonically increasing or decreasing.
741
+ >>> monotonic([1, 2, 4, 20])
742
+ True
743
+ >>> monotonic([1, 20, 4, 10])
744
+ False
745
+ >>> monotonic([4, 1, 0, -10])
746
+ True
747
+ """"""
748
+ ",0.25,0.8063080495356036,0.9837461300309598
749
+ "
750
+
751
+ def common(l1: list, l2: list):
752
+ """"""Return sorted unique common elements for two lists.
753
+ >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
754
+ [1, 5, 653]
755
+ >>> common([5, 3, 2, 8], [3, 2])
756
+ [2, 3]
757
+
758
+ """"""
759
+ ",0.75,0.9999355005159959,1.0
760
+ "
761
+
762
+ def largest_prime_factor(n: int):
763
+ """"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
764
+ >>> largest_prime_factor(13195)
765
+ 29
766
+ >>> largest_prime_factor(2048)
767
+ 2
768
+ """"""
769
+ ",0.65,0.9986455108359134,1.0
770
+ "
771
+
772
+ def sum_to_n(n: int):
773
+ """"""sum_to_n is a function that sums numbers from 1 to n.
774
+ >>> sum_to_n(30)
775
+ 465
776
+ >>> sum_to_n(100)
777
+ 5050
778
+ >>> sum_to_n(5)
779
+ 15
780
+ >>> sum_to_n(10)
781
+ 55
782
+ >>> sum_to_n(1)
783
+ 1
784
+ """"""
785
+ ",0.4,0.9489164086687306,0.9996427720885925
786
+ "
787
+
788
+ def correct_bracketing(brackets: str):
789
+ """""" brackets is a string of ""("" and "")"".
790
+ return True if every opening bracket has a corresponding closing bracket.
791
+
792
+ >>> correct_bracketing(""("")
793
+ False
794
+ >>> correct_bracketing(""()"")
795
+ True
796
+ >>> correct_bracketing(""(()())"")
797
+ True
798
+ >>> correct_bracketing("")(()"")
799
+ False
800
+ """"""
801
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
802
+ "
803
+
804
+ def derivative(xs: list):
805
+ """""" xs represent coefficients of a polynomial.
806
+ xs[0] + xs[1] * x + xs[2] * x^2 + ....
807
+ Return derivative of this polynomial in the same form.
808
+ >>> derivative([3, 1, 2, 4, 5])
809
+ [1, 4, 12, 20]
810
+ >>> derivative([1, 2, 3])
811
+ [2, 6]
812
+ """"""
813
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
814
+ "
815
+
816
+ def fibfib(n: int):
817
+ """"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
818
+ fibfib(0) == 0
819
+ fibfib(1) == 0
820
+ fibfib(2) == 1
821
+ fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
822
+ Please write a function to efficiently compute the n-th element of the fibfib number sequence.
823
+ >>> fibfib(1)
824
+ 0
825
+ >>> fibfib(5)
826
+ 4
827
+ >>> fibfib(8)
828
+ 24
829
+ """"""
830
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
831
+ "
832
+ FIX = """"""
833
+ Add more test cases.
834
+ """"""
835
+
836
+ def vowels_count(s):
837
+ """"""Write a function vowels_count which takes a string representing
838
+ a word as input and returns the number of vowels in the string.
839
+ Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
840
+ vowel, but only when it is at the end of the given word.
841
+
842
+ Example:
843
+ >>> vowels_count(""abcde"")
844
+ 2
845
+ >>> vowels_count(""ACEDY"")
846
+ 3
847
+ """"""
848
+ ",0.65,0.9986455108359134,1.0
849
+ "
850
+ def circular_shift(x, shift):
851
+ """"""Circular shift the digits of the integer x, shift the digits right by shift
852
+ and return the result as a string.
853
+ If shift > number of digits, return digits reversed.
854
+ >>> circular_shift(12, 1)
855
+ ""21""
856
+ >>> circular_shift(12, 2)
857
+ ""12""
858
+ """"""
859
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
860
+ "
861
+ def digitSum(s):
862
+ """"""Task
863
+ Write a function that takes a string as input and returns the sum of the upper characters only'
864
+ ASCII codes.
865
+
866
+ Examples:
867
+ digitSum("""") => 0
868
+ digitSum(""abAB"") => 131
869
+ digitSum(""abcCd"") => 67
870
+ digitSum(""helloE"") => 69
871
+ digitSum(""woArBld"") => 131
872
+ digitSum(""aAaaaXa"") => 153
873
+ """"""
874
+ ",0.7999999999999999,1.0,1.0
875
+ "
876
+ def fruit_distribution(s,n):
877
+ """"""
878
+ In this task, you will be given a string that represents a number of apples and oranges
879
+ that are distributed in a basket of fruit this basket contains
880
+ apples, oranges, and mango fruits. Given the string that represents the total number of
881
+ the oranges and apples and an integer that represent the total number of the fruits
882
+ in the basket return the number of the mango fruits in the basket.
883
+ for examble:
884
+ fruit_distribution(""5 apples and 6 oranges"", 19) ->19 - 5 - 6 = 8
885
+ fruit_distribution(""0 apples and 1 oranges"",3) -> 3 - 0 - 1 = 2
886
+ fruit_distribution(""2 apples and 3 oranges"", 100) -> 100 - 2 - 3 = 95
887
+ fruit_distribution(""100 apples and 1 oranges"",120) -> 120 - 100 - 1 = 19
888
+ """"""
889
+ ",0.0,0.0,0.0
890
+ "
891
+ def pluck(arr):
892
+ """"""
893
+ ""Given an array representing a branch of a tree that has non-negative integer nodes
894
+ your task is to pluck one of the nodes and return it.
895
+ The plucked node should be the node with the smallest even value.
896
+ If multiple nodes with the same smallest even value are found return the node that has smallest index.
897
+
898
+ The plucked node should be returned in a list, [ smalest_value, its index ],
899
+ If there are no even values or the given array is empty, return [].
900
+
901
+ Example 1:
902
+ Input: [4,2,3]
903
+ Output: [2, 1]
904
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
905
+
906
+ Example 2:
907
+ Input: [1,2,3]
908
+ Output: [2, 1]
909
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
910
+
911
+ Example 3:
912
+ Input: []
913
+ Output: []
914
+
915
+ Example 4:
916
+ Input: [5, 0, 3, 0, 4, 2]
917
+ Output: [0, 1]
918
+ Explanation: 0 is the smallest value, but there are two zeros,
919
+ so we will choose the first zero, which has the smallest index.
920
+
921
+ Constraints:
922
+ * 1 <= nodes.length <= 10000
923
+ * 0 <= node.value
924
+ """"""
925
+ ",0.4,0.9489164086687306,0.9996427720885925
926
+ "
927
+ def search(lst):
928
+ '''
929
+ You are given a non-empty list of positive integers. Return the greatest integer that is greater than
930
+ zero, and has a frequency greater than or equal to the value of the integer itself.
931
+ The frequency of an integer is the number of times it appears in the list.
932
+ If no such a value exist, return -1.
933
+ Examples:
934
+ search([4, 1, 2, 2, 3, 1]) == 2
935
+ search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
936
+ search([5, 5, 4, 4, 4]) == -1
937
+ '''
938
+ ",0.0,0.0,0.0
939
+ "
940
+ def strange_sort_list(lst):
941
+ '''
942
+ Given list of integers, return list in strange order.
943
+ Strange sorting, is when you start with the minimum value,
944
+ then maximum of the remaining integers, then minimum and so on.
945
+
946
+ Examples:
947
+ strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
948
+ strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
949
+ strange_sort_list([]) == []
950
+ '''
951
+ ",0.0,0.0,0.0
952
+ "
953
+ def triangle_area(a, b, c):
954
+ '''
955
+ Given the lengths of the three sides of a triangle. Return the area of
956
+ the triangle rounded to 2 decimal points if the three sides form a valid triangle.
957
+ Otherwise return -1
958
+ Three sides make a valid triangle when the sum of any two sides is greater
959
+ than the third side.
960
+ Example:
961
+ triangle_area(3, 4, 5) == 6.00
962
+ triangle_area(1, 2, 10) == -1
963
+ '''
964
+ ",0.25,0.8063080495356036,0.9837461300309598
965
+ "
966
+ def will_it_fly(q,w):
967
+ '''
968
+ Write a function that returns True if the object q will fly, and False otherwise.
969
+ 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.
970
+
971
+ Example:
972
+ will_it_fly([1, 2], 5) ➞ False
973
+ # 1+2 is less than the maximum possible weight, but it's unbalanced.
974
+
975
+ will_it_fly([3, 2, 3], 1) ➞ False
976
+ # it's balanced, but 3+2+3 is more than the maximum possible weight.
977
+
978
+ will_it_fly([3, 2, 3], 9) ➞ True
979
+ # 3+2+3 is less than the maximum possible weight, and it's balanced.
980
+
981
+ will_it_fly([3], 5) ➞ True
982
+ # 3 is less than the maximum possible weight, and it's balanced.
983
+ '''
984
+ ",0.4,0.9489164086687306,0.9996427720885925
985
+ "
986
+ def smallest_change(arr):
987
+ """"""
988
+ Given an array arr of integers, find the minimum number of elements that
989
+ need to be changed to make the array palindromic. A palindromic array is an array that
990
+ is read the same backwards and forwards. In one change, you can change one element to any other element.
991
+
992
+ For example:
993
+ smallest_change([1,2,3,5,4,7,9,6]) == 4
994
+ smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
995
+ smallest_change([1, 2, 3, 2, 1]) == 0
996
+ """"""
997
+ ",0.0,0.0,0.0
998
+ "
999
+ def total_match(lst1, lst2):
1000
+ '''
1001
+ Write a function that accepts two lists of strings and returns the list that has
1002
+ total number of chars in the all strings of the list less than the other list.
1003
+
1004
+ if the two lists have the same number of chars, return the first list.
1005
+
1006
+ Examples
1007
+ total_match([], []) ➞ []
1008
+ total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
1009
+ total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
1010
+ total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
1011
+ total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
1012
+ '''
1013
+ ",0.0,0.0,0.0
1014
+ "
1015
+ def is_multiply_prime(a):
1016
+ """"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
1017
+ and false otherwise.
1018
+ Knowing that (a) is less then 100.
1019
+ Example:
1020
+ is_multiply_prime(30) == True
1021
+ 30 = 2 * 3 * 5
1022
+ """"""
1023
+ ",0.0,0.0,0.0
1024
+ "
1025
+ def is_simple_power(x, n):
1026
+ """"""Your task is to write a function that returns true if a number x is a simple
1027
+ power of n and false in other cases.
1028
+ x is a simple power of n if n**int=x
1029
+ For example:
1030
+ is_simple_power(1, 4) => true
1031
+ is_simple_power(2, 2) => true
1032
+ is_simple_power(8, 2) => true
1033
+ is_simple_power(3, 2) => false
1034
+ is_simple_power(3, 1) => false
1035
+ is_simple_power(5, 3) => false
1036
+ """"""
1037
+ ",0.0,0.0,0.0
1038
+ "
1039
+ def iscube(a):
1040
+ '''
1041
+ Write a function that takes an integer a and returns True
1042
+ if this ingeger is a cube of some integer number.
1043
+ Note: you may assume the input is always valid.
1044
+ Examples:
1045
+ iscube(1) ==> True
1046
+ iscube(2) ==> False
1047
+ iscube(-1) ==> True
1048
+ iscube(64) ==> True
1049
+ iscube(0) ==> True
1050
+ iscube(180) ==> False
1051
+ '''
1052
+ ",0.0,0.0,0.0
1053
+ "
1054
+ def hex_key(num):
1055
+ """"""You have been tasked to write a function that receives
1056
+ a hexadecimal number as a string and counts the number of hexadecimal
1057
+ digits that are primes (prime number, or a prime, is a natural number
1058
+ greater than 1 that is not a product of two smaller natural numbers).
1059
+ Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
1060
+ Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
1061
+ So you have to determine a number of the following digits: 2, 3, 5, 7,
1062
+ B (=decimal 11), D (=decimal 13).
1063
+ Note: you may assume the input is always correct or empty string,
1064
+ and symbols A,B,C,D,E,F are always uppercase.
1065
+ Examples:
1066
+ For num = ""AB"" the output should be 1.
1067
+ For num = ""1077E"" the output should be 2.
1068
+ For num = ""ABED1A33"" the output should be 4.
1069
+ For num = ""123456789ABCDEF0"" the output should be 6.
1070
+ For num = ""2020"" the output should be 2.
1071
+ """"""
1072
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1073
+ "
1074
+ def decimal_to_binary(decimal):
1075
+ """"""You will be given a number in decimal form and your task is to convert it to
1076
+ binary format. The function should return a string, with each character representing a binary
1077
+ number. Each character in the string will be '0' or '1'.
1078
+
1079
+ There will be an extra couple of characters 'db' at the beginning and at the end of the string.
1080
+ The extra characters are there to help with the format.
1081
+
1082
+ Examples:
1083
+ decimal_to_binary(15) # returns ""db1111db""
1084
+ decimal_to_binary(32) # returns ""db100000db""
1085
+ """"""
1086
+ ",0.7,0.9996130030959752,1.0
1087
+ "
1088
+ def is_happy(s):
1089
+ """"""You are given a string s.
1090
+ Your task is to check if the string is happy or not.
1091
+ A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
1092
+ For example:
1093
+ is_happy(a) => False
1094
+ is_happy(aa) => False
1095
+ is_happy(abcd) => True
1096
+ is_happy(aabb) => False
1097
+ is_happy(adb) => True
1098
+ is_happy(xyy) => False
1099
+ """"""
1100
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1101
+ "
1102
+ def numerical_letter_grade(grades):
1103
+ """"""It is the last week of the semester and the teacher has to give the grades
1104
+ to students. The teacher has been making her own algorithm for grading.
1105
+ The only problem is, she has lost the code she used for grading.
1106
+ She has given you a list of GPAs for some students and you have to write
1107
+ a function that can output a list of letter grades using the following table:
1108
+ GPA | Letter grade
1109
+ 4.0 A+
1110
+ > 3.7 A
1111
+ > 3.3 A-
1112
+ > 3.0 B+
1113
+ > 2.7 B
1114
+ > 2.3 B-
1115
+ > 2.0 C+
1116
+ > 1.7 C
1117
+ > 1.3 C-
1118
+ > 1.0 D+
1119
+ > 0.7 D
1120
+ > 0.0 D-
1121
+ 0.0 E
1122
+
1123
+
1124
+ Example:
1125
+ grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
1126
+ """"""
1127
+ ",0.25,0.8063080495356036,0.9837461300309598
1128
+ "
1129
+ def prime_length(string):
1130
+ """"""Write a function that takes a string and returns True if the string
1131
+ length is a prime number or False otherwise
1132
+ Examples
1133
+ prime_length('Hello') == True
1134
+ prime_length('abcdcba') == True
1135
+ prime_length('kittens') == True
1136
+ prime_length('orange') == False
1137
+ """"""
1138
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1139
+ "
1140
+ def starts_one_ends(n):
1141
+ """"""
1142
+ Given a positive integer n, return the count of the numbers of n-digit
1143
+ positive integers that start or end with 1.
1144
+ """"""
1145
+ ",0.0,0.0,0.0
1146
+ "
1147
+ def solve(N):
1148
+ """"""Given a positive integer N, return the total sum of its digits in binary.
1149
+
1150
+ Example
1151
+ For N = 1000, the sum of digits will be 1 the output should be ""1"".
1152
+ For N = 150, the sum of digits will be 6 the output should be ""110"".
1153
+ For N = 147, the sum of digits will be 12 the output should be ""1100"".
1154
+
1155
+ Variables:
1156
+ @N integer
1157
+ Constraints: 0 ≤ N ≤ 10000.
1158
+ Output:
1159
+ a string of binary number
1160
+ """"""
1161
+ ",0.0,0.0,0.0
1162
+ "
1163
+ def add(lst):
1164
+ """"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
1165
+
1166
+
1167
+ Examples:
1168
+ add([4, 2, 6, 7]) ==> 2
1169
+ """"""
1170
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1171
+ "
1172
+ def anti_shuffle(s):
1173
+ """"""
1174
+ Write a function that takes a string and returns an ordered version of it.
1175
+ Ordered version of string, is a string where all words (separated by space)
1176
+ are replaced by a new word where all the characters arranged in
1177
+ ascending order based on ascii value.
1178
+ Note: You should keep the order of words and blank spaces in the sentence.
1179
+
1180
+ For example:
1181
+ anti_shuffle('Hi') returns 'Hi'
1182
+ anti_shuffle('hello') returns 'ehllo'
1183
+ anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
1184
+ """"""
1185
+ ",0.5499999999999998,0.9918730650154799,1.0
1186
+ "
1187
+ def get_row(lst, x):
1188
+ """"""
1189
+ You are given a 2 dimensional data, as a nested lists,
1190
+ which is similar to matrix, however, unlike matrices,
1191
+ each row may contain a different number of columns.
1192
+ Given lst, and integer x, find integers x in the list,
1193
+ and return list of tuples, [(x1, y1), (x2, y2) ...] such that
1194
+ each tuple is a coordinate - (row, columns), starting with 0.
1195
+ Sort coordinates initially by rows in ascending order.
1196
+ Also, sort coordinates of the row by columns in descending order.
1197
+
1198
+ Examples:
1199
+ get_row([
1200
+ [1,2,3,4,5,6],
1201
+ [1,2,3,4,1,6],
1202
+ [1,2,3,4,5,1]
1203
+ ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
1204
+ get_row([], 1) == []
1205
+ get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
1206
+ """"""
1207
+ ",0.050000000000000044,0.25,0.5
1208
+ "
1209
+ def sort_array(array):
1210
+ """"""
1211
+ Given an array of non-negative integers, return a copy of the given array after sorting,
1212
+ you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
1213
+ or sort it in descending order if the sum( first index value, last index value) is even.
1214
+
1215
+ Note:
1216
+ * don't change the given array.
1217
+
1218
+ Examples:
1219
+ * sort_array([]) => []
1220
+ * sort_array([5]) => [5]
1221
+ * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
1222
+ * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
1223
+ """"""
1224
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1225
+ "
1226
+ def encrypt(s):
1227
+ """"""Create a function encrypt that takes a string as an argument and
1228
+ returns a string encrypted with the alphabet being rotated.
1229
+ The alphabet should be rotated in a manner such that the letters
1230
+ shift down by two multiplied to two places.
1231
+ For example:
1232
+ encrypt('hi') returns 'lm'
1233
+ encrypt('asdfghjkl') returns 'ewhjklnop'
1234
+ encrypt('gf') returns 'kj'
1235
+ encrypt('et') returns 'ix'
1236
+ """"""
1237
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1238
+ "
1239
+ def next_smallest(lst):
1240
+ """"""
1241
+ You are given a list of integers.
1242
+ Write a function next_smallest() that returns the 2nd smallest element of the list.
1243
+ Return None if there is no such element.
1244
+
1245
+ next_smallest([1, 2, 3, 4, 5]) == 2
1246
+ next_smallest([5, 1, 4, 3, 2]) == 2
1247
+ next_smallest([]) == None
1248
+ next_smallest([1, 1]) == None
1249
+ """"""
1250
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1251
+ "
1252
+ def is_bored(S):
1253
+ """"""
1254
+ You'll be given a string of words, and your task is to count the number
1255
+ of boredoms. A boredom is a sentence that starts with the word ""I"".
1256
+ Sentences are delimited by '.', '?' or '!'.
1257
+
1258
+ For example:
1259
+ >>> is_bored(""Hello world"")
1260
+ 0
1261
+ >>> is_bored(""The sky is blue. The sun is shining. I love this weather"")
1262
+ 1
1263
+ """"""
1264
+ ",0.0,0.0,0.0
1265
+ "
1266
+ def any_int(x, y, z):
1267
+ '''
1268
+ Create a function that takes 3 numbers.
1269
+ Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
1270
+ Returns false in any other cases.
1271
+
1272
+ Examples
1273
+ any_int(5, 2, 7) ➞ True
1274
+
1275
+ any_int(3, 2, 2) ➞ False
1276
+
1277
+ any_int(3, -2, 1) ➞ True
1278
+
1279
+ any_int(3.6, -2.2, 2) ➞ False
1280
+
1281
+
1282
+
1283
+ '''
1284
+ ",0.75,0.9999355005159959,1.0
1285
+ "
1286
+ def encode(message):
1287
+ """"""
1288
+ Write a function that takes a message, and encodes in such a
1289
+ way that it swaps case of all letters, replaces all vowels in
1290
+ the message with the letter that appears 2 places ahead of that
1291
+ vowel in the english alphabet.
1292
+ Assume only letters.
1293
+
1294
+ Examples:
1295
+ >>> encode('test')
1296
+ 'TGST'
1297
+ >>> encode('This is a message')
1298
+ 'tHKS KS C MGSSCGG'
1299
+ """"""
1300
+ ",0.0,0.0,0.0
1301
+ "
1302
+
1303
+ def skjkasdkd(lst):
1304
+ """"""You are given a list of integers.
1305
+ You need to find the largest prime value and return the sum of its digits.
1306
+
1307
+ Examples:
1308
+ For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
1309
+ For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
1310
+ For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
1311
+ For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
1312
+ For lst = [0,81,12,3,1,21] the output should be 3
1313
+ For lst = [0,8,1,2,1,7] the output should be 7
1314
+ """"""
1315
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1316
+ "
1317
+ def check_dict_case(dict):
1318
+ """"""
1319
+ Given a dictionary, return True if all keys are strings in lower
1320
+ case or all keys are strings in upper case, else return False.
1321
+ The function should return False is the given dictionary is empty.
1322
+ Examples:
1323
+ check_dict_case({""a"":""apple"", ""b"":""banana""}) should return True.
1324
+ check_dict_case({""a"":""apple"", ""A"":""banana"", ""B"":""banana""}) should return False.
1325
+ check_dict_case({""a"":""apple"", 8:""banana"", ""a"":""apple""}) should return False.
1326
+ check_dict_case({""Name"":""John"", ""Age"":""36"", ""City"":""Houston""}) should return False.
1327
+ check_dict_case({""STATE"":""NC"", ""ZIP"":""12345"" }) should return True.
1328
+ """"""
1329
+ ",0.050000000000000044,0.25,0.5
1330
+ "
1331
+ def count_up_to(n):
1332
+ """"""Implement a function that takes an non-negative integer and returns an array of the first n
1333
+ integers that are prime numbers and less than n.
1334
+ for example:
1335
+ count_up_to(5) => [2,3]
1336
+ count_up_to(11) => [2,3,5,7]
1337
+ count_up_to(0) => []
1338
+ count_up_to(20) => [2,3,5,7,11,13,17,19]
1339
+ count_up_to(1) => []
1340
+ count_up_to(18) => [2,3,5,7,11,13,17]
1341
+ """"""
1342
+ ",0.25,0.8063080495356036,0.9837461300309598
1343
+ "
1344
+ def multiply(a, b):
1345
+ """"""Complete the function that takes two integers and returns
1346
+ the product of their unit digits.
1347
+ Assume the input is always valid.
1348
+ Examples:
1349
+ multiply(148, 412) should return 16.
1350
+ multiply(19, 28) should return 72.
1351
+ multiply(2020, 1851) should return 0.
1352
+ multiply(14,-15) should return 20.
1353
+ """"""
1354
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1355
+ "
1356
+ def count_upper(s):
1357
+ """"""
1358
+ Given a string s, count the number of uppercase vowels in even indices.
1359
+
1360
+ For example:
1361
+ count_upper('aBCdEf') returns 1
1362
+ count_upper('abcdefg') returns 0
1363
+ count_upper('dBBE') returns 0
1364
+ """"""
1365
+ ",0.5499999999999998,0.9918730650154799,1.0
1366
+ "
1367
+ def closest_integer(value):
1368
+ '''
1369
+ Create a function that takes a value (string) representing a number
1370
+ and returns the closest integer to it. If the number is equidistant
1371
+ from two integers, round it away from zero.
1372
+
1373
+ Examples
1374
+ >>> closest_integer(""10"")
1375
+ 10
1376
+ >>> closest_integer(""15.3"")
1377
+ 15
1378
+
1379
+ Note:
1380
+ Rounding away from zero means that if the given number is equidistant
1381
+ from two integers, the one you should return is the one that is the
1382
+ farthest from zero. For example closest_integer(""14.5"") should
1383
+ return 15 and closest_integer(""-14.5"") should return -15.
1384
+ '''
1385
+ ",0.050000000000000044,0.25,0.5
1386
+ "
1387
+ def make_a_pile(n):
1388
+ """"""
1389
+ Given a positive integer n, you have to make a pile of n levels of stones.
1390
+ The first level has n stones.
1391
+ The number of stones in the next level is:
1392
+ - the next odd number if n is odd.
1393
+ - the next even number if n is even.
1394
+ Return the number of stones in each level in a list, where element at index
1395
+ i represents the number of stones in the level (i+1).
1396
+
1397
+ Examples:
1398
+ >>> make_a_pile(3)
1399
+ [3, 5, 7]
1400
+ """"""
1401
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1402
+ "
1403
+ def words_string(s):
1404
+ """"""
1405
+ You will be given a string of words separated by commas or spaces. Your task is
1406
+ to split the string into words and return an array of the words.
1407
+
1408
+ For example:
1409
+ words_string(""Hi, my name is John"") == [""Hi"", ""my"", ""name"", ""is"", ""John""]
1410
+ words_string(""One, two, three, four, five, six"") == [""One"", ""two"", ""three"", ""four"", ""five"", ""six""]
1411
+ """"""
1412
+ ",0.0,0.0,0.0
1413
+ "
1414
+ def choose_num(x, y):
1415
+ """"""This function takes two positive numbers x and y and returns the
1416
+ biggest even integer number that is in the range [x, y] inclusive. If
1417
+ there's no such number, then the function should return -1.
1418
+
1419
+ For example:
1420
+ choose_num(12, 15) = 14
1421
+ choose_num(13, 12) = -1
1422
+ """"""
1423
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1424
+ "
1425
+ def rounded_avg(n, m):
1426
+ """"""You are given two positive integers n and m, and your task is to compute the
1427
+ average of the integers from n through m (including n and m).
1428
+ Round the answer to the nearest integer and convert that to binary.
1429
+ If n is greater than m, return -1.
1430
+ Example:
1431
+ rounded_avg(1, 5) => ""0b11""
1432
+ rounded_avg(7, 5) => -1
1433
+ rounded_avg(10, 20) => ""0b1111""
1434
+ rounded_avg(20, 33) => ""0b11010""
1435
+ """"""
1436
+ ",0.0,0.0,0.0
1437
+ "
1438
+ def unique_digits(x):
1439
+ """"""Given a list of positive integers x. return a sorted list of all
1440
+ elements that hasn't any even digit.
1441
+
1442
+ Note: Returned list should be sorted in increasing order.
1443
+
1444
+ For example:
1445
+ >>> unique_digits([15, 33, 1422, 1])
1446
+ [1, 15, 33]
1447
+ >>> unique_digits([152, 323, 1422, 10])
1448
+ []
1449
+ """"""
1450
+ ",0.050000000000000044,0.25,0.5
1451
+ "
1452
+ def by_length(arr):
1453
+ """"""
1454
+ Given an array of integers, sort the integers that are between 1 and 9 inclusive,
1455
+ reverse the resulting array, and then replace each digit by its corresponding name from
1456
+ ""One"", ""Two"", ""Three"", ""Four"", ""Five"", ""Six"", ""Seven"", ""Eight"", ""Nine"".
1457
+
1458
+ For example:
1459
+ arr = [2, 1, 1, 4, 5, 8, 2, 3]
1460
+ -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
1461
+ -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
1462
+ return [""Eight"", ""Five"", ""Four"", ""Three"", ""Two"", ""Two"", ""One"", ""One""]
1463
+
1464
+ If the array is empty, return an empty array:
1465
+ arr = []
1466
+ return []
1467
+
1468
+ If the array has any strange number ignore it:
1469
+ arr = [1, -1 , 55]
1470
+ -> sort arr -> [-1, 1, 55]
1471
+ -> reverse arr -> [55, 1, -1]
1472
+ return = ['One']
1473
+ """"""
1474
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1475
+ "
1476
+ def f(n):
1477
+ """""" Implement the function f that takes n as a parameter,
1478
+ 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
1479
+ or the sum of numbers from 1 to i otherwise.
1480
+ i starts from 1.
1481
+ the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
1482
+ Example:
1483
+ f(5) == [1, 2, 6, 24, 15]
1484
+ """"""
1485
+ ",0.0,0.0,0.0
1486
+ "
1487
+ def even_odd_palindrome(n):
1488
+ """"""
1489
+ Given a positive integer n, return a tuple that has the number of even and odd
1490
+ integer palindromes that fall within the range(1, n), inclusive.
1491
+
1492
+ Example 1:
1493
+
1494
+ Input: 3
1495
+ Output: (1, 2)
1496
+ Explanation:
1497
+ Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
1498
+
1499
+ Example 2:
1500
+
1501
+ Input: 12
1502
+ Output: (4, 6)
1503
+ Explanation:
1504
+ Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
1505
+
1506
+ Note:
1507
+ 1. 1 <= n <= 10^3
1508
+ 2. returned tuple has the number of even and odd integer palindromes respectively.
1509
+ """"""
1510
+ ",1.0,1.0,1.0
1511
+ "
1512
+ def count_nums(arr):
1513
+ """"""
1514
+ Write a function count_nums which takes an array of integers and returns
1515
+ the number of elements which has a sum of digits > 0.
1516
+ If a number is negative, then its first signed digit will be negative:
1517
+ e.g. -123 has signed digits -1, 2, and 3.
1518
+ >>> count_nums([]) == 0
1519
+ >>> count_nums([-1, 11, -11]) == 1
1520
+ >>> count_nums([1, 1, 2]) == 3
1521
+ """"""
1522
+ ",0.0,0.0,0.0
1523
+ "
1524
+ def move_one_ball(arr):
1525
+ """"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
1526
+ numbers in the array will be randomly ordered. Your task is to determine if
1527
+ it is possible to get an array sorted in non-decreasing order by performing
1528
+ the following operation on the given array:
1529
+ You are allowed to perform right shift operation any number of times.
1530
+
1531
+ One right shift operation means shifting all elements of the array by one
1532
+ position in the right direction. The last element of the array will be moved to
1533
+ the starting position in the array i.e. 0th index.
1534
+
1535
+ If it is possible to obtain the sorted array by performing the above operation
1536
+ then return True else return False.
1537
+ If the given array is empty then return True.
1538
+
1539
+ Note: The given list is guaranteed to have unique elements.
1540
+
1541
+ For Example:
1542
+
1543
+ move_one_ball([3, 4, 5, 1, 2])==>True
1544
+ Explanation: By performin 2 right shift operations, non-decreasing order can
1545
+ be achieved for the given array.
1546
+ move_one_ball([3, 5, 4, 1, 2])==>False
1547
+ Explanation:It is not possible to get non-decreasing order for the given
1548
+ array by performing any number of right shift operations.
1549
+
1550
+ """"""
1551
+ ",0.0,0.0,0.0
1552
+ "
1553
+ def exchange(lst1, lst2):
1554
+ """"""In this problem, you will implement a function that takes two lists of numbers,
1555
+ and determines whether it is possible to perform an exchange of elements
1556
+ between them to make lst1 a list of only even numbers.
1557
+ There is no limit on the number of exchanged elements between lst1 and lst2.
1558
+ If it is possible to exchange elements between the lst1 and lst2 to make
1559
+ all the elements of lst1 to be even, return ""YES"".
1560
+ Otherwise, return ""NO"".
1561
+ For example:
1562
+ exchange([1, 2, 3, 4], [1, 2, 3, 4]) => ""YES""
1563
+ exchange([1, 2, 3, 4], [1, 5, 3, 4]) => ""NO""
1564
+ It is assumed that the input lists will be non-empty.
1565
+ """"""
1566
+ ",0.0,0.0,0.0
1567
+ "
1568
+ def histogram(test):
1569
+ """"""Given a string representing a space separated lowercase letters, return a dictionary
1570
+ of the letter with the most repetition and containing the corresponding count.
1571
+ If several letters have the same occurrence, return all of them.
1572
+
1573
+ Example:
1574
+ histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
1575
+ histogram('a b b a') == {'a': 2, 'b': 2}
1576
+ histogram('a b c a b') == {'a': 2, 'b': 2}
1577
+ histogram('b b b b a') == {'b': 4}
1578
+ histogram('') == {}
1579
+
1580
+ """"""
1581
+ ",0.050000000000000044,0.25,0.5
1582
+ "
1583
+ def reverse_delete(s,c):
1584
+ """"""Task
1585
+ 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
1586
+ then check if the result string is palindrome.
1587
+ A string is called palindrome if it reads the same backward as forward.
1588
+ You should return a tuple containing the result string and True/False for the check.
1589
+ Example
1590
+ For s = ""abcde"", c = ""ae"", the result should be ('bcd',False)
1591
+ For s = ""abcdef"", c = ""b"" the result should be ('acdef',False)
1592
+ For s = ""abcdedcba"", c = ""ab"", the result should be ('cdedc',True)
1593
+ """"""
1594
+ ",0.4,0.9489164086687306,0.9996427720885925
1595
+ "
1596
+ def odd_count(lst):
1597
+ """"""Given a list of strings, where each string consists of only digits, return a list.
1598
+ Each element i of the output should be ""the number of odd elements in the
1599
+ string i of the input."" where all the i's should be replaced by the number
1600
+ of odd digits in the i'th string of the input.
1601
+
1602
+ >>> odd_count(['1234567'])
1603
+ [""the number of odd elements 4n the str4ng 4 of the 4nput.""]
1604
+ >>> odd_count(['3',""11111111""])
1605
+ [""the number of odd elements 1n the str1ng 1 of the 1nput."",
1606
+ ""the number of odd elements 8n the str8ng 8 of the 8nput.""]
1607
+ """"""
1608
+ ",0.0,0.0,0.0
1609
+ "
1610
+ def minSubArraySum(nums):
1611
+ """"""
1612
+ Given an array of integers nums, find the minimum sum of any non-empty sub-array
1613
+ of nums.
1614
+ Example
1615
+ minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
1616
+ minSubArraySum([-1, -2, -3]) == -6
1617
+ """"""
1618
+ ",0.25,0.8063080495356036,0.9837461300309598
1619
+ "
1620
+ def max_fill(grid, capacity):
1621
+ import math
1622
+ """"""
1623
+ You are given a rectangular grid of wells. Each row represents a single well,
1624
+ and each 1 in a row represents a single unit of water.
1625
+ Each well has a corresponding bucket that can be used to extract water from it,
1626
+ and all buckets have the same capacity.
1627
+ Your task is to use the buckets to empty the wells.
1628
+ Output the number of times you need to lower the buckets.
1629
+
1630
+ Example 1:
1631
+ Input:
1632
+ grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
1633
+ bucket_capacity : 1
1634
+ Output: 6
1635
+
1636
+ Example 2:
1637
+ Input:
1638
+ grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
1639
+ bucket_capacity : 2
1640
+ Output: 5
1641
+
1642
+ Example 3:
1643
+ Input:
1644
+ grid : [[0,0,0], [0,0,0]]
1645
+ bucket_capacity : 5
1646
+ Output: 0
1647
+
1648
+ Constraints:
1649
+ * all wells have the same length
1650
+ * 1 <= grid.length <= 10^2
1651
+ * 1 <= grid[:,1].length <= 10^2
1652
+ * grid[i][j] -> 0 | 1
1653
+ * 1 <= capacity <= 10
1654
+ """"""
1655
+ ",0.0,0.0,0.0
1656
+ "
1657
+ def sort_array(arr):
1658
+ """"""
1659
+ In this Kata, you have to sort an array of non-negative integers according to
1660
+ number of ones in their binary representation in ascending order.
1661
+ For similar number of ones, sort based on decimal value.
1662
+
1663
+ It must be implemented like this:
1664
+ >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
1665
+ >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
1666
+ >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
1667
+ """"""
1668
+ ",0.95,1.0,1.0
1669
+ "
1670
+ def select_words(s, n):
1671
+ """"""Given a string s and a natural number n, you have been tasked to implement
1672
+ a function that returns a list of all words from string s that contain exactly
1673
+ n consonants, in order these words appear in the string s.
1674
+ If the string s is empty then the function should return an empty list.
1675
+ Note: you may assume the input string contains only letters and spaces.
1676
+ Examples:
1677
+ select_words(""Mary had a little lamb"", 4) ==> [""little""]
1678
+ select_words(""Mary had a little lamb"", 3) ==> [""Mary"", ""lamb""]
1679
+ select_words(""simple white space"", 2) ==> []
1680
+ select_words(""Hello world"", 4) ==> [""world""]
1681
+ select_words(""Uncle sam"", 3) ==> [""Uncle""]
1682
+ """"""
1683
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1684
+ "
1685
+ def get_closest_vowel(word):
1686
+ """"""You are given a word. Your task is to find the closest vowel that stands between
1687
+ two consonants from the right side of the word (case sensitive).
1688
+
1689
+ Vowels in the beginning and ending doesn't count. Return empty string if you didn't
1690
+ find any vowel met the above condition.
1691
+
1692
+ You may assume that the given string contains English letter only.
1693
+
1694
+ Example:
1695
+ get_closest_vowel(""yogurt"") ==> ""u""
1696
+ get_closest_vowel(""FULL"") ==> ""U""
1697
+ get_closest_vowel(""quick"") ==> """"
1698
+ get_closest_vowel(""ab"") ==> """"
1699
+ """"""
1700
+ ",0.050000000000000044,0.25,0.5
1701
+ "
1702
+ def match_parens(lst):
1703
+ '''
1704
+ You are given a list of two strings, both strings consist of open
1705
+ parentheses '(' or close parentheses ')' only.
1706
+ Your job is to check if it is possible to concatenate the two strings in
1707
+ some order, that the resulting string will be good.
1708
+ A string S is considered to be good if and only if all parentheses in S
1709
+ are balanced. For example: the string '(())()' is good, while the string
1710
+ '())' is not.
1711
+ Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
1712
+
1713
+ Examples:
1714
+ match_parens(['()(', ')']) == 'Yes'
1715
+ match_parens([')', ')']) == 'No'
1716
+ '''
1717
+ ",0.0,0.0,0.0
1718
+ "
1719
+ def maximum(arr, k):
1720
+ """"""
1721
+ Given an array arr of integers and a positive integer k, return a sorted list
1722
+ of length k with the maximum k numbers in arr.
1723
+
1724
+ Example 1:
1725
+
1726
+ Input: arr = [-3, -4, 5], k = 3
1727
+ Output: [-4, -3, 5]
1728
+
1729
+ Example 2:
1730
+
1731
+ Input: arr = [4, -4, 4], k = 2
1732
+ Output: [4, 4]
1733
+
1734
+ Example 3:
1735
+
1736
+ Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
1737
+ Output: [2]
1738
+
1739
+ Note:
1740
+ 1. The length of the array will be in the range of [1, 1000].
1741
+ 2. The elements in the array will be in the range of [-1000, 1000].
1742
+ 3. 0 <= k <= len(arr)
1743
+ """"""
1744
+ ",0.0,0.0,0.0
1745
+ "
1746
+ def solution(lst):
1747
+ """"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
1748
+
1749
+
1750
+ Examples
1751
+ solution([5, 8, 7, 1]) ==> 12
1752
+ solution([3, 3, 3, 3, 3]) ==> 9
1753
+ solution([30, 13, 24, 321]) ==>0
1754
+ """"""
1755
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1756
+ "
1757
+ def add_elements(arr, k):
1758
+ """"""
1759
+ Given a non-empty array of integers arr and an integer k, return
1760
+ the sum of the elements with at most two digits from the first k elements of arr.
1761
+
1762
+ Example:
1763
+
1764
+ Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
1765
+ Output: 24 # sum of 21 + 3
1766
+
1767
+ Constraints:
1768
+ 1. 1 <= len(arr) <= 100
1769
+ 2. 1 <= k <= len(arr)
1770
+ """"""
1771
+ ",0.0,0.0,0.0
1772
+ "
1773
+ def get_odd_collatz(n):
1774
+ """"""
1775
+ Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
1776
+
1777
+ The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
1778
+ as follows: start with any positive integer n. Then each term is obtained from the
1779
+ previous term as follows: if the previous term is even, the next term is one half of
1780
+ the previous term. If the previous term is odd, the next term is 3 times the previous
1781
+ term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
1782
+
1783
+ Note:
1784
+ 1. Collatz(1) is [1].
1785
+ 2. returned list sorted in increasing order.
1786
+
1787
+ For example:
1788
+ get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
1789
+ """"""
1790
+ ",0.25,0.8063080495356036,0.9837461300309598
1791
+ "
1792
+ def valid_date(date):
1793
+ """"""You have to write a function which validates a given date string and
1794
+ returns True if the date is valid otherwise False.
1795
+ The date is valid if all of the following rules are satisfied:
1796
+ 1. The date string is not empty.
1797
+ 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
1798
+ 3. The months should not be less than 1 or higher than 12.
1799
+ 4. The date should be in the format: mm-dd-yyyy
1800
+
1801
+ for example:
1802
+ valid_date('03-11-2000') => True
1803
+
1804
+ valid_date('15-01-2012') => False
1805
+
1806
+ valid_date('04-0-2040') => False
1807
+
1808
+ valid_date('06-04-2020') => True
1809
+
1810
+ valid_date('06/04/2020') => False
1811
+ """"""
1812
+ ",0.0,0.0,0.0
1813
+ "
1814
+ def split_words(txt):
1815
+ '''
1816
+ Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
1817
+ should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
1818
+ alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
1819
+ Examples
1820
+ split_words(""Hello world!"") ➞ [""Hello"", ""world!""]
1821
+ split_words(""Hello,world!"") ➞ [""Hello"", ""world!""]
1822
+ split_words(""abcdef"") == 3
1823
+ '''
1824
+ ",0.0,0.0,0.0
1825
+ "
1826
+ def is_sorted(lst):
1827
+ '''
1828
+ Given a list of numbers, return whether or not they are sorted
1829
+ in ascending order. If list has more than 1 duplicate of the same
1830
+ number, return False. Assume no negative numbers and only integers.
1831
+
1832
+ Examples
1833
+ is_sorted([5]) ➞ True
1834
+ is_sorted([1, 2, 3, 4, 5]) ➞ True
1835
+ is_sorted([1, 3, 2, 4, 5]) ➞ False
1836
+ is_sorted([1, 2, 3, 4, 5, 6]) ➞ True
1837
+ is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
1838
+ is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
1839
+ is_sorted([1, 2, 2, 3, 3, 4]) ➞ True
1840
+ is_sorted([1, 2, 2, 2, 3, 4]) ➞ False
1841
+ '''
1842
+ ",0.0,0.0,0.0
1843
+ "
1844
+ def intersection(interval1, interval2):
1845
+ """"""You are given two intervals,
1846
+ where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
1847
+ The given intervals are closed which means that the interval (start, end)
1848
+ includes both start and end.
1849
+ For each given interval, it is assumed that its start is less or equal its end.
1850
+ Your task is to determine whether the length of intersection of these two
1851
+ intervals is a prime number.
1852
+ Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
1853
+ which its length is 1, which not a prime number.
1854
+ If the length of the intersection is a prime number, return ""YES"",
1855
+ otherwise, return ""NO"".
1856
+ If the two intervals don't intersect, return ""NO"".
1857
+
1858
+
1859
+ [input/output] samples:
1860
+ intersection((1, 2), (2, 3)) ==> ""NO""
1861
+ intersection((-1, 1), (0, 4)) ==> ""NO""
1862
+ intersection((-3, -1), (-5, 5)) ==> ""YES""
1863
+ """"""
1864
+ ",0.4,0.9489164086687306,0.9996427720885925
1865
+ "
1866
+ def prod_signs(arr):
1867
+ """"""
1868
+ You are given an array arr of integers and you need to return
1869
+ sum of magnitudes of integers multiplied by product of all signs
1870
+ of each number in the array, represented by 1, -1 or 0.
1871
+ Note: return None for empty arr.
1872
+
1873
+ Example:
1874
+ >>> prod_signs([1, 2, 2, -4]) == -9
1875
+ >>> prod_signs([0, 1]) == 0
1876
+ >>> prod_signs([]) == None
1877
+ """"""
1878
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1879
+ "
1880
+ def minPath(grid, k):
1881
+ """"""
1882
+ Given a grid with N rows and N columns (N >= 2) and a positive integer k,
1883
+ each cell of the grid contains a value. Every integer in the range [1, N * N]
1884
+ inclusive appears exactly once on the cells of the grid.
1885
+
1886
+ You have to find the minimum path of length k in the grid. You can start
1887
+ from any cell, and in each step you can move to any of the neighbor cells,
1888
+ in other words, you can go to cells which share an edge with you current
1889
+ cell.
1890
+ Please note that a path of length k means visiting exactly k cells (not
1891
+ necessarily distinct).
1892
+ You CANNOT go off the grid.
1893
+ A path A (of length k) is considered less than a path B (of length k) if
1894
+ after making the ordered lists of the values on the cells that A and B go
1895
+ through (let's call them lst_A and lst_B), lst_A is lexicographically less
1896
+ than lst_B, in other words, there exist an integer index i (1 <= i <= k)
1897
+ such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
1898
+ lst_A[j] = lst_B[j].
1899
+ It is guaranteed that the answer is unique.
1900
+ Return an ordered list of the values on the cells that the minimum path go through.
1901
+
1902
+ Examples:
1903
+
1904
+ Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
1905
+ Output: [1, 2, 1]
1906
+
1907
+ Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
1908
+ Output: [1]
1909
+ """"""
1910
+ ",0.0,0.0,0.0
1911
+ "
1912
+ def tri(n):
1913
+ """"""Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
1914
+ the last couple centuries. However, what people don't know is Tribonacci sequence.
1915
+ Tribonacci sequence is defined by the recurrence:
1916
+ tri(1) = 3
1917
+ tri(n) = 1 + n / 2, if n is even.
1918
+ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
1919
+ For example:
1920
+ tri(2) = 1 + (2 / 2) = 2
1921
+ tri(4) = 3
1922
+ tri(3) = tri(2) + tri(1) + tri(4)
1923
+ = 2 + 3 + 3 = 8
1924
+ You are given a non-negative integer number n, you have to a return a list of the
1925
+ first n + 1 numbers of the Tribonacci sequence.
1926
+ Examples:
1927
+ tri(3) = [1, 3, 2, 8]
1928
+ """"""
1929
+ ",0.0,0.0,0.0
1930
+ "
1931
+ def digits(n):
1932
+ """"""Given a positive integer n, return the product of the odd digits.
1933
+ Return 0 if all digits are even.
1934
+ For example:
1935
+ digits(1) == 1
1936
+ digits(4) == 0
1937
+ digits(235) == 15
1938
+ """"""
1939
+ ",0.050000000000000044,0.25,0.5
1940
+ "
1941
+ def is_nested(string):
1942
+ '''
1943
+ Create a function that takes a string as input which contains only square brackets.
1944
+ The function should return True if and only if there is a valid subsequence of brackets
1945
+ where at least one bracket in the subsequence is nested.
1946
+
1947
+ is_nested('[[]]') ➞ True
1948
+ is_nested('[]]]]]]][[[[[]') ➞ False
1949
+ is_nested('[][]') ➞ False
1950
+ is_nested('[]') ➞ False
1951
+ is_nested('[[][]]') ➞ True
1952
+ is_nested('[[]][[') ➞ True
1953
+ '''
1954
+ ",0.0,0.0,0.0
1955
+ "
1956
+
1957
+ def sum_squares(lst):
1958
+ """"""You are given a list of numbers.
1959
+ You need to return the sum of squared numbers in the given list,
1960
+ round each element in the list to the upper int(Ceiling) first.
1961
+ Examples:
1962
+ For lst = [1,2,3] the output should be 14
1963
+ For lst = [1,4,9] the output should be 98
1964
+ For lst = [1,3,5,7] the output should be 84
1965
+ For lst = [1.4,4.2,0] the output should be 29
1966
+ For lst = [-2.4,1,1] the output should be 6
1967
+
1968
+
1969
+ """"""
1970
+ ",0.0,0.0,0.0
1971
+ "
1972
+ def check_if_last_char_is_a_letter(txt):
1973
+ '''
1974
+ Create a function that returns True if the last character
1975
+ of a given string is an alphabetical character and is not
1976
+ a part of a word, and False otherwise.
1977
+ Note: ""word"" is a group of characters separated by space.
1978
+
1979
+ Examples:
1980
+ check_if_last_char_is_a_letter(""apple pie"") ➞ False
1981
+ check_if_last_char_is_a_letter(""apple pi e"") ➞ True
1982
+ check_if_last_char_is_a_letter(""apple pi e "") ➞ False
1983
+ check_if_last_char_is_a_letter("""") ➞ False
1984
+ '''
1985
+ ",0.0,0.0,0.0
1986
+ "
1987
+ def can_arrange(arr):
1988
+ """"""Create a function which returns the largest index of an element which
1989
+ is not greater than or equal to the element immediately preceding it. If
1990
+ no such element exists then return -1. The given array will not contain
1991
+ duplicate values.
1992
+
1993
+ Examples:
1994
+ can_arrange([1,2,4,3,5]) = 3
1995
+ can_arrange([1,2,3]) = -1
1996
+ """"""
1997
+ ",0.0,0.0,0.0
1998
+ "
1999
+ def largest_smallest_integers(lst):
2000
+ '''
2001
+ Create a function that returns a tuple (a, b), where 'a' is
2002
+ the largest of negative integers, and 'b' is the smallest
2003
+ of positive integers in a list.
2004
+ If there is no negative or positive integers, return them as None.
2005
+
2006
+ Examples:
2007
+ largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
2008
+ largest_smallest_integers([]) == (None, None)
2009
+ largest_smallest_integers([0]) == (None, None)
2010
+ '''
2011
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2012
+ "
2013
+ def compare_one(a, b):
2014
+ """"""
2015
+ Create a function that takes integers, floats, or strings representing
2016
+ real numbers, and returns the larger variable in its given variable type.
2017
+ Return None if the values are equal.
2018
+ Note: If a real number is represented as a string, the floating point might be . or ,
2019
+
2020
+ compare_one(1, 2.5) ➞ 2.5
2021
+ compare_one(1, ""2,3"") ➞ ""2,3""
2022
+ compare_one(""5,1"", ""6"") ➞ ""6""
2023
+ compare_one(""1"", 1) ➞ None
2024
+ """"""
2025
+ ",0.0,0.0,0.0
2026
+ "
2027
+ def is_equal_to_sum_even(n):
2028
+ """"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
2029
+ Example
2030
+ is_equal_to_sum_even(4) == False
2031
+ is_equal_to_sum_even(6) == False
2032
+ is_equal_to_sum_even(8) == True
2033
+ """"""
2034
+ ",0.050000000000000044,0.25,0.5
2035
+ "
2036
+ def special_factorial(n):
2037
+ """"""The Brazilian factorial is defined as:
2038
+ brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
2039
+ where n > 0
2040
+
2041
+ For example:
2042
+ >>> special_factorial(4)
2043
+ 288
2044
+
2045
+ The function will receive an integer as input and should return the special
2046
+ factorial of this integer.
2047
+ """"""
2048
+ ",0.0,0.0,0.0
2049
+ "
2050
+ def fix_spaces(text):
2051
+ """"""
2052
+ Given a string text, replace all spaces in it with underscores,
2053
+ and if a string has more than 2 consecutive spaces,
2054
+ then replace all consecutive spaces with -
2055
+
2056
+ fix_spaces(""Example"") == ""Example""
2057
+ fix_spaces(""Example 1"") == ""Example_1""
2058
+ fix_spaces("" Example 2"") == ""_Example_2""
2059
+ fix_spaces("" Example 3"") == ""_Example-3""
2060
+ """"""
2061
+ ",0.0,0.0,0.0
2062
+ "
2063
+ def file_name_check(file_name):
2064
+ """"""Create a function which takes a string representing a file's name, and returns
2065
+ 'Yes' if the the file's name is valid, and returns 'No' otherwise.
2066
+ A file's name is considered to be valid if and only if all the following conditions
2067
+ are met:
2068
+ - There should not be more than three digits ('0'-'9') in the file's name.
2069
+ - The file's name contains exactly one dot '.'
2070
+ - The substring before the dot should not be empty, and it starts with a letter from
2071
+ the latin alphapet ('a'-'z' and 'A'-'Z').
2072
+ - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
2073
+ Examples:
2074
+ file_name_check(""example.txt"") # => 'Yes'
2075
+ file_name_check(""1example.dll"") # => 'No' (the name should start with a latin alphapet letter)
2076
+ """"""
2077
+ ",0.0,0.0,0.0
2078
+ "
2079
+
2080
+
2081
+ def sum_squares(lst):
2082
+ """"""""
2083
+ 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
2084
+ 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
2085
+ 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.
2086
+
2087
+ Examples:
2088
+ For lst = [1,2,3] the output should be 6
2089
+ For lst = [] the output should be 0
2090
+ For lst = [-1,-5,2,-1,-5] the output should be -126
2091
+ """"""
2092
+ ",0.0,0.0,0.0
2093
+ "
2094
+ def words_in_sentence(sentence):
2095
+ """"""
2096
+ You are given a string representing a sentence,
2097
+ the sentence contains some words separated by a space,
2098
+ and you have to return a string that contains the words from the original sentence,
2099
+ whose lengths are prime numbers,
2100
+ the order of the words in the new string should be the same as the original one.
2101
+
2102
+ Example 1:
2103
+ Input: sentence = ""This is a test""
2104
+ Output: ""is""
2105
+
2106
+ Example 2:
2107
+ Input: sentence = ""lets go for swimming""
2108
+ Output: ""go for""
2109
+
2110
+ Constraints:
2111
+ * 1 <= len(sentence) <= 100
2112
+ * sentence contains only letters
2113
+ """"""
2114
+ ",0.8999999999999999,1.0,1.0
2115
+ "
2116
+ def simplify(x, n):
2117
+ """"""Your task is to implement a function that will simplify the expression
2118
+ x * n. The function returns True if x * n evaluates to a whole number and False
2119
+ otherwise. Both x and n, are string representation of a fraction, and have the following format,
2120
+ <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
2121
+
2122
+ You can assume that x, and n are valid fractions, and do not have zero as denominator.
2123
+
2124
+ simplify(""1/5"", ""5/1"") = True
2125
+ simplify(""1/6"", ""2/1"") = False
2126
+ simplify(""7/10"", ""10/2"") = False
2127
+ """"""
2128
+ ",0.050000000000000044,0.25,0.5
2129
+ "
2130
+ def order_by_points(nums):
2131
+ """"""
2132
+ Write a function which sorts the given list of integers
2133
+ in ascending order according to the sum of their digits.
2134
+ Note: if there are several items with similar sum of their digits,
2135
+ order them based on their index in original list.
2136
+
2137
+ For example:
2138
+ >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
2139
+ >>> order_by_points([]) == []
2140
+ """"""
2141
+ ",0.0,0.0,0.0
2142
+ "
2143
+ def specialFilter(nums):
2144
+ """"""Write a function that takes an array of numbers as input and returns
2145
+ the number of elements in the array that are greater than 10 and both
2146
+ first and last digits of a number are odd (1, 3, 5, 7, 9).
2147
+ For example:
2148
+ specialFilter([15, -73, 14, -15]) => 1
2149
+ specialFilter([33, -2, -3, 45, 21, 109]) => 2
2150
+ """"""
2151
+ ",0.0,0.0,0.0
2152
+ "
2153
+ def get_max_triples(n):
2154
+ """"""
2155
+ You are given a positive integer n. You have to create an integer array a of length n.
2156
+ For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
2157
+ Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
2158
+ and a[i] + a[j] + a[k] is a multiple of 3.
2159
+
2160
+ Example :
2161
+ Input: n = 5
2162
+ Output: 1
2163
+ Explanation:
2164
+ a = [1, 3, 7, 13, 21]
2165
+ The only valid triple is (1, 7, 13).
2166
+ """"""
2167
+ ",0.050000000000000044,0.25,0.5
2168
+ "
2169
+ def bf(planet1, planet2):
2170
+ '''
2171
+ There are eight planets in our solar system: the closerst to the Sun
2172
+ is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
2173
+ Uranus, Neptune.
2174
+ Write a function that takes two planet names as strings planet1 and planet2.
2175
+ The function should return a tuple containing all planets whose orbits are
2176
+ located between the orbit of planet1 and the orbit of planet2, sorted by
2177
+ the proximity to the sun.
2178
+ The function should return an empty tuple if planet1 or planet2
2179
+ are not correct planet names.
2180
+ Examples
2181
+ bf(""Jupiter"", ""Neptune"") ==> (""Saturn"", ""Uranus"")
2182
+ bf(""Earth"", ""Mercury"") ==> (""Venus"")
2183
+ bf(""Mercury"", ""Uranus"") ==> (""Venus"", ""Earth"", ""Mars"", ""Jupiter"", ""Saturn"")
2184
+ '''
2185
+ ",0.8999999999999999,1.0,1.0
2186
+ "
2187
+ def sorted_list_sum(lst):
2188
+ """"""Write a function that accepts a list of strings as a parameter,
2189
+ deletes the strings that have odd lengths from it,
2190
+ and returns the resulted list with a sorted order,
2191
+ The list is always a list of strings and never an array of numbers,
2192
+ and it may contain duplicates.
2193
+ The order of the list should be ascending by length of each word, and you
2194
+ should return the list sorted by that rule.
2195
+ If two words have the same length, sort the list alphabetically.
2196
+ The function should return a list of strings in sorted order.
2197
+ You may assume that all words will have the same length.
2198
+ For example:
2199
+ assert list_sort([""aa"", ""a"", ""aaa""]) => [""aa""]
2200
+ assert list_sort([""ab"", ""a"", ""aaa"", ""cd""]) => [""ab"", ""cd""]
2201
+ """"""
2202
+ ",0.0,0.0,0.0
2203
+ "
2204
+ def x_or_y(n, x, y):
2205
+ """"""A simple program which should return the value of x if n is
2206
+ a prime number and should return the value of y otherwise.
2207
+
2208
+ Examples:
2209
+ for x_or_y(7, 34, 12) == 34
2210
+ for x_or_y(15, 8, 5) == 5
2211
+
2212
+ """"""
2213
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2214
+ "
2215
+ def double_the_difference(lst):
2216
+ '''
2217
+ Given a list of numbers, return the sum of squares of the numbers
2218
+ in the list that are odd. Ignore numbers that are negative or not integers.
2219
+
2220
+ double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
2221
+ double_the_difference([-1, -2, 0]) == 0
2222
+ double_the_difference([9, -2]) == 81
2223
+ double_the_difference([0]) == 0
2224
+
2225
+ If the input list is empty, return 0.
2226
+ '''
2227
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
2228
+ "
2229
+ def compare(game,guess):
2230
+ """"""I think we all remember that feeling when the result of some long-awaited
2231
+ event is finally known. The feelings and thoughts you have at that moment are
2232
+ definitely worth noting down and comparing.
2233
+ Your task is to determine if a person correctly guessed the results of a number of matches.
2234
+ You are given two arrays of scores and guesses of equal length, where each index shows a match.
2235
+ Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
2236
+ the value is 0, and if not, the value is the absolute difference between the guess and the score.
2237
+
2238
+
2239
+ example:
2240
+
2241
+ compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
2242
+ compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
2243
+ """"""
2244
+ ",1.0,1.0,1.0
2245
+ "
2246
+ def Strongest_Extension(class_name, extensions):
2247
+ """"""You will be given the name of a class (a string) and a list of extensions.
2248
+ The extensions are to be used to load additional classes to the class. The
2249
+ strength of the extension is as follows: Let CAP be the number of the uppercase
2250
+ letters in the extension's name, and let SM be the number of lowercase letters
2251
+ in the extension's name, the strength is given by the fraction CAP - SM.
2252
+ You should find the strongest extension and return a string in this
2253
+ format: ClassName.StrongestExtensionName.
2254
+ If there are two or more extensions with the same strength, you should
2255
+ choose the one that comes first in the list.
2256
+ For example, if you are given ""Slices"" as the class and a list of the
2257
+ extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
2258
+ return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
2259
+ (its strength is -1).
2260
+ Example:
2261
+ for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
2262
+ """"""
2263
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2264
+ "
2265
+ def cycpattern_check(a , b):
2266
+ """"""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
2267
+ cycpattern_check(""abcd"",""abd"") => False
2268
+ cycpattern_check(""hello"",""ell"") => True
2269
+ cycpattern_check(""whassup"",""psus"") => False
2270
+ cycpattern_check(""abab"",""baa"") => True
2271
+ cycpattern_check(""efef"",""eeff"") => False
2272
+ cycpattern_check(""himenss"",""simen"") => True
2273
+
2274
+ """"""
2275
+ ",0.25,0.8063080495356036,0.9837461300309598
2276
+ "
2277
+ def even_odd_count(num):
2278
+ """"""Given an integer. return a tuple that has the number of even and odd digits respectively.
2279
+
2280
+ Example:
2281
+ even_odd_count(-12) ==> (1, 1)
2282
+ even_odd_count(123) ==> (1, 2)
2283
+ """"""
2284
+ ",0.65,0.9986455108359134,1.0
2285
+ "
2286
+ def int_to_mini_roman(number):
2287
+ """"""
2288
+ Given a positive integer, obtain its roman numeral equivalent as a string,
2289
+ and return it in lowercase.
2290
+ Restrictions: 1 <= num <= 1000
2291
+
2292
+ Examples:
2293
+ >>> int_to_mini_roman(19) == 'xix'
2294
+ >>> int_to_mini_roman(152) == 'clii'
2295
+ >>> int_to_mini_roman(426) == 'cdxxvi'
2296
+ """"""
2297
+ ",0.95,1.0,1.0
2298
+ "
2299
+ def right_angle_triangle(a, b, c):
2300
+ '''
2301
+ Given the lengths of the three sides of a triangle. Return True if the three
2302
+ sides form a right-angled triangle, False otherwise.
2303
+ A right-angled triangle is a triangle in which one angle is right angle or
2304
+ 90 degree.
2305
+ Example:
2306
+ right_angle_triangle(3, 4, 5) == True
2307
+ right_angle_triangle(1, 2, 3) == False
2308
+ '''
2309
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2310
+ "
2311
+ def find_max(words):
2312
+ """"""Write a function that accepts a list of strings.
2313
+ The list contains different words. Return the word with maximum number
2314
+ of unique characters. If multiple strings have maximum number of unique
2315
+ characters, return the one which comes first in lexicographical order.
2316
+
2317
+ find_max([""name"", ""of"", ""string""]) == ""string""
2318
+ find_max([""name"", ""enam"", ""game""]) == ""enam""
2319
+ find_max([""aaaaaaa"", ""bb"" ,""cc""]) == """"aaaaaaa""
2320
+ """"""
2321
+ ",0.85,1.0,1.0
2322
+ "
2323
+ def eat(number, need, remaining):
2324
+ """"""
2325
+ You're a hungry rabbit, and you already have eaten a certain number of carrots,
2326
+ but now you need to eat more carrots to complete the day's meals.
2327
+ you should return an array of [ total number of eaten carrots after your meals,
2328
+ the number of carrots left after your meals ]
2329
+ if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
2330
+
2331
+ Example:
2332
+ * eat(5, 6, 10) -> [11, 4]
2333
+ * eat(4, 8, 9) -> [12, 1]
2334
+ * eat(1, 10, 10) -> [11, 0]
2335
+ * eat(2, 11, 5) -> [7, 0]
2336
+
2337
+ Variables:
2338
+ @number : integer
2339
+ the number of carrots that you have eaten.
2340
+ @need : integer
2341
+ the number of carrots that you need to eat.
2342
+ @remaining : integer
2343
+ the number of remaining carrots thet exist in stock
2344
+
2345
+ Constrain:
2346
+ * 0 <= number <= 1000
2347
+ * 0 <= need <= 1000
2348
+ * 0 <= remaining <= 1000
2349
+
2350
+ Have fun :)
2351
+ """"""
2352
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
2353
+ "
2354
+ def do_algebra(operator, operand):
2355
+ """"""
2356
+ Given two lists operator, and operand. The first list has basic algebra operations, and
2357
+ the second list is a list of integers. Use the two given lists to build the algebric
2358
+ expression and return the evaluation of this expression.
2359
+
2360
+ The basic algebra operations:
2361
+ Addition ( + )
2362
+ Subtraction ( - )
2363
+ Multiplication ( * )
2364
+ Floor division ( // )
2365
+ Exponentiation ( ** )
2366
+
2367
+ Example:
2368
+ operator['+', '*', '-']
2369
+ array = [2, 3, 4, 5]
2370
+ result = 2 + 3 * 4 - 5
2371
+ => result = 9
2372
+
2373
+ Note:
2374
+ The length of operator list is equal to the length of operand list minus one.
2375
+ Operand is a list of of non-negative integers.
2376
+ Operator list has at least one operator, and operand list has at least two operands.
2377
+
2378
+ """"""
2379
+ ",0.0,0.0,0.0
2380
+ "
2381
+ def solve(s):
2382
+ """"""You are given a string s.
2383
+ if s[i] is a letter, reverse its case from lower to upper or vise versa,
2384
+ otherwise keep it as it is.
2385
+ If the string contains no letters, reverse the string.
2386
+ The function should return the resulted string.
2387
+ Examples
2388
+ solve(""1234"") = ""4321""
2389
+ solve(""ab"") = ""AB""
2390
+ solve(""#a@C"") = ""#A@c""
2391
+ """"""
2392
+ ",0.6000000000000001,0.9963880288957688,1.0
2393
+ "
2394
+ def string_to_md5(text):
2395
+ """"""
2396
+ Given a string 'text', return its md5 hash equivalent string.
2397
+ If 'text' is an empty string, return None.
2398
+
2399
+ >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
2400
+ """"""
2401
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
2402
+ "
2403
+ def generate_integers(a, b):
2404
+ """"""
2405
+ Given two positive integers a and b, return the even digits between a
2406
+ and b, in ascending order.
2407
+
2408
+ For example:
2409
+ generate_integers(2, 8) => [2, 4, 6, 8]
2410
+ generate_integers(8, 2) => [2, 4, 6, 8]
2411
+ generate_integers(10, 14) => []
2412
+ """"""
2413
+ ",0.0,0.0,0.0
data/coding/humaneval/csv/4.csv ADDED
@@ -0,0 +1,2413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt,pass@1,pass@5,pass@10
2
+ "from typing import List
3
+
4
+
5
+ def has_close_elements(numbers: List[float], threshold: float) -> bool:
6
+ """""" Check if in given list of numbers, are any two numbers closer to each other than
7
+ given threshold.
8
+ >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
9
+ False
10
+ >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
11
+ True
12
+ """"""
13
+ ",0.0,0.0,0.0
14
+ "from typing import List
15
+
16
+
17
+ def separate_paren_groups(paren_string: str) -> List[str]:
18
+ """""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
19
+ separate those group into separate strings and return the list of those.
20
+ Separate groups are balanced (each open brace is properly closed) and not nested within each other
21
+ Ignore any spaces in the input string.
22
+ >>> separate_paren_groups('( ) (( )) (( )( ))')
23
+ ['()', '(())', '(()())']
24
+ """"""
25
+ ",0.4,0.9489164086687306,0.9996427720885925
26
+ "
27
+
28
+ def truncate_number(number: float) -> float:
29
+ """""" Given a positive floating point number, it can be decomposed into
30
+ and integer part (largest integer smaller than given number) and decimals
31
+ (leftover part always smaller than 1).
32
+
33
+ Return the decimal part of the number.
34
+ >>> truncate_number(3.5)
35
+ 0.5
36
+ """"""
37
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
38
+ "from typing import List
39
+
40
+
41
+ def below_zero(operations: List[int]) -> bool:
42
+ """""" You're given a list of deposit and withdrawal operations on a bank account that starts with
43
+ zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
44
+ at that point function should return True. Otherwise it should return False.
45
+ >>> below_zero([1, 2, 3])
46
+ False
47
+ >>> below_zero([1, 2, -4, 5])
48
+ True
49
+ """"""
50
+ ",1.0,1.0,1.0
51
+ "from typing import List
52
+
53
+
54
+ def mean_absolute_deviation(numbers: List[float]) -> float:
55
+ """""" For a given list of input numbers, calculate Mean Absolute Deviation
56
+ around the mean of this dataset.
57
+ Mean Absolute Deviation is the average absolute difference between each
58
+ element and a centerpoint (mean in this case):
59
+ MAD = average | x - x_mean |
60
+ >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
61
+ 1.0
62
+ """"""
63
+ ",0.95,1.0,1.0
64
+ "from typing import List
65
+
66
+
67
+ def intersperse(numbers: List[int], delimeter: int) -> List[int]:
68
+ """""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
69
+ >>> intersperse([], 4)
70
+ []
71
+ >>> intersperse([1, 2, 3], 4)
72
+ [1, 4, 2, 4, 3]
73
+ """"""
74
+ ",0.0,0.0,0.0
75
+ "from typing import List
76
+
77
+
78
+ def parse_nested_parens(paren_string: str) -> List[int]:
79
+ """""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
80
+ For each of the group, output the deepest level of nesting of parentheses.
81
+ E.g. (()()) has maximum two levels of nesting while ((())) has three.
82
+
83
+ >>> parse_nested_parens('(()()) ((())) () ((())()())')
84
+ [2, 3, 1, 3]
85
+ """"""
86
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
87
+ "from typing import List
88
+
89
+
90
+ def filter_by_substring(strings: List[str], substring: str) -> List[str]:
91
+ """""" Filter an input list of strings only for ones that contain given substring
92
+ >>> filter_by_substring([], 'a')
93
+ []
94
+ >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
95
+ ['abc', 'bacd', 'array']
96
+ """"""
97
+ ",1.0,1.0,1.0
98
+ "from typing import List, Tuple
99
+
100
+
101
+ def sum_product(numbers: List[int]) -> Tuple[int, int]:
102
+ """""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
103
+ Empty sum should be equal to 0 and empty product should be equal to 1.
104
+ >>> sum_product([])
105
+ (0, 1)
106
+ >>> sum_product([1, 2, 3, 4])
107
+ (10, 24)
108
+ """"""
109
+ ",0.95,1.0,1.0
110
+ "from typing import List, Tuple
111
+
112
+
113
+ def rolling_max(numbers: List[int]) -> List[int]:
114
+ """""" From a given list of integers, generate a list of rolling maximum element found until given moment
115
+ in the sequence.
116
+ >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
117
+ [1, 2, 3, 3, 3, 4, 4]
118
+ """"""
119
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
120
+ "
121
+
122
+ def is_palindrome(string: str) -> bool:
123
+ """""" Test if given string is a palindrome """"""
124
+ return string == string[::-1]
125
+
126
+
127
+ def make_palindrome(string: str) -> str:
128
+ """""" Find the shortest palindrome that begins with a supplied string.
129
+ Algorithm idea is simple:
130
+ - Find the longest postfix of supplied string that is a palindrome.
131
+ - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
132
+ >>> make_palindrome('')
133
+ ''
134
+ >>> make_palindrome('cat')
135
+ 'catac'
136
+ >>> make_palindrome('cata')
137
+ 'catac'
138
+ """"""
139
+ ",0.0,0.0,0.0
140
+ "from typing import List
141
+
142
+
143
+ def string_xor(a: str, b: str) -> str:
144
+ """""" Input are two strings a and b consisting only of 1s and 0s.
145
+ Perform binary XOR on these inputs and return result also as a string.
146
+ >>> string_xor('010', '110')
147
+ '100'
148
+ """"""
149
+ ",0.6000000000000001,0.9963880288957688,1.0
150
+ "from typing import List, Optional
151
+
152
+
153
+ def longest(strings: List[str]) -> Optional[str]:
154
+ """""" Out of list of strings, return the longest one. Return the first one in case of multiple
155
+ strings of the same length. Return None in case the input list is empty.
156
+ >>> longest([])
157
+
158
+ >>> longest(['a', 'b', 'c'])
159
+ 'a'
160
+ >>> longest(['a', 'bb', 'ccc'])
161
+ 'ccc'
162
+ """"""
163
+ ",1.0,1.0,1.0
164
+ "
165
+
166
+ def greatest_common_divisor(a: int, b: int) -> int:
167
+ """""" Return a greatest common divisor of two integers a and b
168
+ >>> greatest_common_divisor(3, 5)
169
+ 1
170
+ >>> greatest_common_divisor(25, 15)
171
+ 5
172
+ """"""
173
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
174
+ "from typing import List
175
+
176
+
177
+ def all_prefixes(string: str) -> List[str]:
178
+ """""" Return list of all prefixes from shortest to longest of the input string
179
+ >>> all_prefixes('abc')
180
+ ['a', 'ab', 'abc']
181
+ """"""
182
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
183
+ "
184
+
185
+ def string_sequence(n: int) -> str:
186
+ """""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
187
+ >>> string_sequence(0)
188
+ '0'
189
+ >>> string_sequence(5)
190
+ '0 1 2 3 4 5'
191
+ """"""
192
+ ",0.65,0.9986455108359134,1.0
193
+ "
194
+
195
+ def count_distinct_characters(string: str) -> int:
196
+ """""" Given a string, find out how many distinct characters (regardless of case) does it consist of
197
+ >>> count_distinct_characters('xyzXYZ')
198
+ 3
199
+ >>> count_distinct_characters('Jerry')
200
+ 4
201
+ """"""
202
+ ",0.25,0.8063080495356036,0.9837461300309598
203
+ "from typing import List
204
+
205
+
206
+ def parse_music(music_string: str) -> List[int]:
207
+ """""" Input to this function is a string representing musical notes in a special ASCII format.
208
+ Your task is to parse this string and return list of integers corresponding to how many beats does each
209
+ not last.
210
+
211
+ Here is a legend:
212
+ 'o' - whole note, lasts four beats
213
+ 'o|' - half note, lasts two beats
214
+ '.|' - quater note, lasts one beat
215
+
216
+ >>> parse_music('o o| .| o| o| .| .| .| .| o o')
217
+ [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
218
+ """"""
219
+ ",0.65,0.9986455108359134,1.0
220
+ "
221
+
222
+ def how_many_times(string: str, substring: str) -> int:
223
+ """""" Find how many times a given substring can be found in the original string. Count overlaping cases.
224
+ >>> how_many_times('', 'a')
225
+ 0
226
+ >>> how_many_times('aaa', 'a')
227
+ 3
228
+ >>> how_many_times('aaaa', 'aa')
229
+ 3
230
+ """"""
231
+ ",0.7999999999999999,1.0,1.0
232
+ "from typing import List
233
+
234
+
235
+ def sort_numbers(numbers: str) -> str:
236
+ """""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
237
+ Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
238
+ Return the string with numbers sorted from smallest to largest
239
+ >>> sort_numbers('three one five')
240
+ 'one three five'
241
+ """"""
242
+ ",0.0,0.0,0.0
243
+ "from typing import List, Tuple
244
+
245
+
246
+ def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
247
+ """""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
248
+ other and return them in order (smaller number, larger number).
249
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
250
+ (2.0, 2.2)
251
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
252
+ (2.0, 2.0)
253
+ """"""
254
+ ",0.65,0.9986455108359134,1.0
255
+ "from typing import List
256
+
257
+
258
+ def rescale_to_unit(numbers: List[float]) -> List[float]:
259
+ """""" Given list of numbers (of at least two elements), apply a linear transform to that list,
260
+ such that the smallest number will become 0 and the largest will become 1
261
+ >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
262
+ [0.0, 0.25, 0.5, 0.75, 1.0]
263
+ """"""
264
+ ",0.7999999999999999,1.0,1.0
265
+ "from typing import List, Any
266
+
267
+
268
+ def filter_integers(values: List[Any]) -> List[int]:
269
+ """""" Filter given list of any python values only for integers
270
+ >>> filter_integers(['a', 3.14, 5])
271
+ [5]
272
+ >>> filter_integers([1, 2, 3, 'abc', {}, []])
273
+ [1, 2, 3]
274
+ """"""
275
+ ",0.7,0.9996130030959752,1.0
276
+ "
277
+
278
+ def strlen(string: str) -> int:
279
+ """""" Return length of given string
280
+ >>> strlen('')
281
+ 0
282
+ >>> strlen('abc')
283
+ 3
284
+ """"""
285
+ ",0.85,1.0,1.0
286
+ "
287
+
288
+ def largest_divisor(n: int) -> int:
289
+ """""" For a given number n, find the largest number that divides n evenly, smaller than n
290
+ >>> largest_divisor(15)
291
+ 5
292
+ """"""
293
+ ",0.050000000000000044,0.25,0.5
294
+ "from typing import List
295
+
296
+
297
+ def factorize(n: int) -> List[int]:
298
+ """""" Return list of prime factors of given integer in the order from smallest to largest.
299
+ Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
300
+ Input number should be equal to the product of all factors
301
+ >>> factorize(8)
302
+ [2, 2, 2]
303
+ >>> factorize(25)
304
+ [5, 5]
305
+ >>> factorize(70)
306
+ [2, 5, 7]
307
+ """"""
308
+ ",0.95,1.0,1.0
309
+ "from typing import List
310
+
311
+
312
+ def remove_duplicates(numbers: List[int]) -> List[int]:
313
+ """""" From a list of integers, remove all elements that occur more than once.
314
+ Keep order of elements left the same as in the input.
315
+ >>> remove_duplicates([1, 2, 3, 2, 4])
316
+ [1, 3, 4]
317
+ """"""
318
+ ",0.050000000000000044,0.25,0.5
319
+ "
320
+
321
+ def flip_case(string: str) -> str:
322
+ """""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
323
+ >>> flip_case('Hello')
324
+ 'hELLO'
325
+ """"""
326
+ ",0.85,1.0,1.0
327
+ "from typing import List
328
+
329
+
330
+ def concatenate(strings: List[str]) -> str:
331
+ """""" Concatenate list of strings into a single string
332
+ >>> concatenate([])
333
+ ''
334
+ >>> concatenate(['a', 'b', 'c'])
335
+ 'abc'
336
+ """"""
337
+ ",0.7,0.9996130030959752,1.0
338
+ "from typing import List
339
+
340
+
341
+ def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
342
+ """""" Filter an input list of strings only for ones that start with a given prefix.
343
+ >>> filter_by_prefix([], 'a')
344
+ []
345
+ >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
346
+ ['abc', 'array']
347
+ """"""
348
+ ",0.8999999999999999,1.0,1.0
349
+ "
350
+
351
+ def get_positive(l: list):
352
+ """"""Return only positive numbers in the list.
353
+ >>> get_positive([-1, 2, -4, 5, 6])
354
+ [2, 5, 6]
355
+ >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
356
+ [5, 3, 2, 3, 9, 123, 1]
357
+ """"""
358
+ ",0.75,0.9999355005159959,1.0
359
+ "
360
+
361
+ def is_prime(n):
362
+ """"""Return true if a given number is prime, and false otherwise.
363
+ >>> is_prime(6)
364
+ False
365
+ >>> is_prime(101)
366
+ True
367
+ >>> is_prime(11)
368
+ True
369
+ >>> is_prime(13441)
370
+ True
371
+ >>> is_prime(61)
372
+ True
373
+ >>> is_prime(4)
374
+ False
375
+ >>> is_prime(1)
376
+ False
377
+ """"""
378
+ ",0.85,1.0,1.0
379
+ "import math
380
+
381
+
382
+ def poly(xs: list, x: float):
383
+ """"""
384
+ Evaluates polynomial with coefficients xs at point x.
385
+ return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
386
+ """"""
387
+ return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])
388
+
389
+
390
+ def find_zero(xs: list):
391
+ """""" xs are coefficients of a polynomial.
392
+ find_zero find x such that poly(x) = 0.
393
+ find_zero returns only only zero point, even if there are many.
394
+ Moreover, find_zero only takes list xs having even number of coefficients
395
+ and largest non zero coefficient as it guarantees
396
+ a solution.
397
+ >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
398
+ -0.5
399
+ >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
400
+ 1.0
401
+ """"""
402
+ ",0.0,0.0,0.0
403
+ "
404
+
405
+ def sort_third(l: list):
406
+ """"""This function takes a list l and returns a list l' such that
407
+ 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
408
+ to the values of the corresponding indicies of l, but sorted.
409
+ >>> sort_third([1, 2, 3])
410
+ [1, 2, 3]
411
+ >>> sort_third([5, 6, 3, 4, 8, 9, 2])
412
+ [2, 6, 3, 4, 8, 9, 5]
413
+ """"""
414
+ ",0.0,0.0,0.0
415
+ "
416
+
417
+ def unique(l: list):
418
+ """"""Return sorted unique elements in a list
419
+ >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
420
+ [0, 2, 3, 5, 9, 123]
421
+ """"""
422
+ ",0.7999999999999999,1.0,1.0
423
+ "
424
+
425
+ def max_element(l: list):
426
+ """"""Return maximum element in the list.
427
+ >>> max_element([1, 2, 3])
428
+ 3
429
+ >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
430
+ 123
431
+ """"""
432
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
433
+ "
434
+
435
+ def fizz_buzz(n: int):
436
+ """"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
437
+ >>> fizz_buzz(50)
438
+ 0
439
+ >>> fizz_buzz(78)
440
+ 2
441
+ >>> fizz_buzz(79)
442
+ 3
443
+ """"""
444
+ ",0.6000000000000001,0.9963880288957688,1.0
445
+ "
446
+
447
+ def sort_even(l: list):
448
+ """"""This function takes a list l and returns a list l' such that
449
+ l' is identical to l in the odd indicies, while its values at the even indicies are equal
450
+ to the values of the even indicies of l, but sorted.
451
+ >>> sort_even([1, 2, 3])
452
+ [1, 2, 3]
453
+ >>> sort_even([5, 6, 3, 4])
454
+ [3, 6, 5, 4]
455
+ """"""
456
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
457
+ "
458
+
459
+ def encode_cyclic(s: str):
460
+ """"""
461
+ returns encoded string by cycling groups of three characters.
462
+ """"""
463
+ # split string to groups. Each of length 3.
464
+ groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
465
+ # cycle elements in each group. Unless group has fewer elements than 3.
466
+ groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
467
+ return """".join(groups)
468
+
469
+
470
+ def decode_cyclic(s: str):
471
+ """"""
472
+ takes as input string encoded with encode_cyclic function. Returns decoded string.
473
+ """"""
474
+ ",0.0,0.0,0.0
475
+ "
476
+
477
+ def prime_fib(n: int):
478
+ """"""
479
+ prime_fib returns n-th number that is a Fibonacci number and it's also prime.
480
+ >>> prime_fib(1)
481
+ 2
482
+ >>> prime_fib(2)
483
+ 3
484
+ >>> prime_fib(3)
485
+ 5
486
+ >>> prime_fib(4)
487
+ 13
488
+ >>> prime_fib(5)
489
+ 89
490
+ """"""
491
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
492
+ "
493
+
494
+ def triples_sum_to_zero(l: list):
495
+ """"""
496
+ triples_sum_to_zero takes a list of integers as an input.
497
+ it returns True if there are three distinct elements in the list that
498
+ sum to zero, and False otherwise.
499
+
500
+ >>> triples_sum_to_zero([1, 3, 5, 0])
501
+ False
502
+ >>> triples_sum_to_zero([1, 3, -2, 1])
503
+ True
504
+ >>> triples_sum_to_zero([1, 2, 3, 7])
505
+ False
506
+ >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
507
+ True
508
+ >>> triples_sum_to_zero([1])
509
+ False
510
+ """"""
511
+ ",0.85,1.0,1.0
512
+ "
513
+
514
+ def car_race_collision(n: int):
515
+ """"""
516
+ Imagine a road that's a perfectly straight infinitely long line.
517
+ n cars are driving left to right; simultaneously, a different set of n cars
518
+ are driving right to left. The two sets of cars start out being very far from
519
+ each other. All cars move in the same speed. Two cars are said to collide
520
+ when a car that's moving left to right hits a car that's moving right to left.
521
+ However, the cars are infinitely sturdy and strong; as a result, they continue moving
522
+ in their trajectory as if they did not collide.
523
+
524
+ This function outputs the number of such collisions.
525
+ """"""
526
+ ",0.0,0.0,0.0
527
+ "
528
+
529
+ def incr_list(l: list):
530
+ """"""Return list with elements incremented by 1.
531
+ >>> incr_list([1, 2, 3])
532
+ [2, 3, 4]
533
+ >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
534
+ [6, 4, 6, 3, 4, 4, 10, 1, 124]
535
+ """"""
536
+ ",0.75,0.9999355005159959,1.0
537
+ "
538
+
539
+ def pairs_sum_to_zero(l):
540
+ """"""
541
+ pairs_sum_to_zero takes a list of integers as an input.
542
+ it returns True if there are two distinct elements in the list that
543
+ sum to zero, and False otherwise.
544
+ >>> pairs_sum_to_zero([1, 3, 5, 0])
545
+ False
546
+ >>> pairs_sum_to_zero([1, 3, -2, 1])
547
+ False
548
+ >>> pairs_sum_to_zero([1, 2, 3, 7])
549
+ False
550
+ >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
551
+ True
552
+ >>> pairs_sum_to_zero([1])
553
+ False
554
+ """"""
555
+ ",0.85,1.0,1.0
556
+ "
557
+
558
+ def change_base(x: int, base: int):
559
+ """"""Change numerical base of input number x to base.
560
+ return string representation after the conversion.
561
+ base numbers are less than 10.
562
+ >>> change_base(8, 3)
563
+ '22'
564
+ >>> change_base(8, 2)
565
+ '1000'
566
+ >>> change_base(7, 2)
567
+ '111'
568
+ """"""
569
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
570
+ "
571
+
572
+ def triangle_area(a, h):
573
+ """"""Given length of a side and high return area for a triangle.
574
+ >>> triangle_area(5, 3)
575
+ 7.5
576
+ """"""
577
+ ",0.8999999999999999,1.0,1.0
578
+ "
579
+
580
+ def fib4(n: int):
581
+ """"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
582
+ fib4(0) -> 0
583
+ fib4(1) -> 0
584
+ fib4(2) -> 2
585
+ fib4(3) -> 0
586
+ fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
587
+ Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
588
+ >>> fib4(5)
589
+ 4
590
+ >>> fib4(6)
591
+ 8
592
+ >>> fib4(7)
593
+ 14
594
+ """"""
595
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
596
+ "
597
+
598
+ def median(l: list):
599
+ """"""Return median of elements in the list l.
600
+ >>> median([3, 1, 2, 4, 5])
601
+ 3
602
+ >>> median([-10, 4, 6, 1000, 10, 20])
603
+ 15.0
604
+ """"""
605
+ ",0.75,0.9999355005159959,1.0
606
+ "
607
+
608
+ def is_palindrome(text: str):
609
+ """"""
610
+ Checks if given string is a palindrome
611
+ >>> is_palindrome('')
612
+ True
613
+ >>> is_palindrome('aba')
614
+ True
615
+ >>> is_palindrome('aaaaa')
616
+ True
617
+ >>> is_palindrome('zbcd')
618
+ False
619
+ """"""
620
+ ",0.4,0.9489164086687306,0.9996427720885925
621
+ "
622
+
623
+ def modp(n: int, p: int):
624
+ """"""Return 2^n modulo p (be aware of numerics).
625
+ >>> modp(3, 5)
626
+ 3
627
+ >>> modp(1101, 101)
628
+ 2
629
+ >>> modp(0, 101)
630
+ 1
631
+ >>> modp(3, 11)
632
+ 8
633
+ >>> modp(100, 101)
634
+ 1
635
+ """"""
636
+ ",0.0,0.0,0.0
637
+ "
638
+
639
+ def encode_shift(s: str):
640
+ """"""
641
+ returns encoded string by shifting every character by 5 in the alphabet.
642
+ """"""
643
+ return """".join([chr(((ord(ch) + 5 - ord(""a"")) % 26) + ord(""a"")) for ch in s])
644
+
645
+
646
+ def decode_shift(s: str):
647
+ """"""
648
+ takes as input string encoded with encode_shift function. Returns decoded string.
649
+ """"""
650
+ ",1.0,1.0,1.0
651
+ "
652
+
653
+ def remove_vowels(text):
654
+ """"""
655
+ remove_vowels is a function that takes string and returns string without vowels.
656
+ >>> remove_vowels('')
657
+ ''
658
+ >>> remove_vowels(""abcdef\nghijklm"")
659
+ 'bcdf\nghjklm'
660
+ >>> remove_vowels('abcdef')
661
+ 'bcdf'
662
+ >>> remove_vowels('aaaaa')
663
+ ''
664
+ >>> remove_vowels('aaBAA')
665
+ 'B'
666
+ >>> remove_vowels('zbcd')
667
+ 'zbcd'
668
+ """"""
669
+ ",0.85,1.0,1.0
670
+ "
671
+
672
+ def below_threshold(l: list, t: int):
673
+ """"""Return True if all numbers in the list l are below threshold t.
674
+ >>> below_threshold([1, 2, 4, 10], 100)
675
+ True
676
+ >>> below_threshold([1, 20, 4, 10], 5)
677
+ False
678
+ """"""
679
+ ",0.5499999999999998,0.9918730650154799,1.0
680
+ "
681
+
682
+ def add(x: int, y: int):
683
+ """"""Add two numbers x and y
684
+ >>> add(2, 3)
685
+ 5
686
+ >>> add(5, 7)
687
+ 12
688
+ """"""
689
+ ",0.7999999999999999,1.0,1.0
690
+ "
691
+
692
+ def same_chars(s0: str, s1: str):
693
+ """"""
694
+ Check if two words have the same characters.
695
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
696
+ True
697
+ >>> same_chars('abcd', 'dddddddabc')
698
+ True
699
+ >>> same_chars('dddddddabc', 'abcd')
700
+ True
701
+ >>> same_chars('eabcd', 'dddddddabc')
702
+ False
703
+ >>> same_chars('abcd', 'dddddddabce')
704
+ False
705
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
706
+ False
707
+ """"""
708
+ ",0.85,1.0,1.0
709
+ "
710
+
711
+ def fib(n: int):
712
+ """"""Return n-th Fibonacci number.
713
+ >>> fib(10)
714
+ 55
715
+ >>> fib(1)
716
+ 1
717
+ >>> fib(8)
718
+ 21
719
+ """"""
720
+ ",0.7999999999999999,1.0,1.0
721
+ "
722
+
723
+ def correct_bracketing(brackets: str):
724
+ """""" brackets is a string of ""<"" and "">"".
725
+ return True if every opening bracket has a corresponding closing bracket.
726
+
727
+ >>> correct_bracketing(""<"")
728
+ False
729
+ >>> correct_bracketing(""<>"")
730
+ True
731
+ >>> correct_bracketing(""<<><>>"")
732
+ True
733
+ >>> correct_bracketing(""><<>"")
734
+ False
735
+ """"""
736
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
737
+ "
738
+
739
+ def monotonic(l: list):
740
+ """"""Return True is list elements are monotonically increasing or decreasing.
741
+ >>> monotonic([1, 2, 4, 20])
742
+ True
743
+ >>> monotonic([1, 20, 4, 10])
744
+ False
745
+ >>> monotonic([4, 1, 0, -10])
746
+ True
747
+ """"""
748
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
749
+ "
750
+
751
+ def common(l1: list, l2: list):
752
+ """"""Return sorted unique common elements for two lists.
753
+ >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
754
+ [1, 5, 653]
755
+ >>> common([5, 3, 2, 8], [3, 2])
756
+ [2, 3]
757
+
758
+ """"""
759
+ ",0.75,0.9999355005159959,1.0
760
+ "
761
+
762
+ def largest_prime_factor(n: int):
763
+ """"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
764
+ >>> largest_prime_factor(13195)
765
+ 29
766
+ >>> largest_prime_factor(2048)
767
+ 2
768
+ """"""
769
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
770
+ "
771
+
772
+ def sum_to_n(n: int):
773
+ """"""sum_to_n is a function that sums numbers from 1 to n.
774
+ >>> sum_to_n(30)
775
+ 465
776
+ >>> sum_to_n(100)
777
+ 5050
778
+ >>> sum_to_n(5)
779
+ 15
780
+ >>> sum_to_n(10)
781
+ 55
782
+ >>> sum_to_n(1)
783
+ 1
784
+ """"""
785
+ ",0.5499999999999998,0.9918730650154799,1.0
786
+ "
787
+
788
+ def correct_bracketing(brackets: str):
789
+ """""" brackets is a string of ""("" and "")"".
790
+ return True if every opening bracket has a corresponding closing bracket.
791
+
792
+ >>> correct_bracketing(""("")
793
+ False
794
+ >>> correct_bracketing(""()"")
795
+ True
796
+ >>> correct_bracketing(""(()())"")
797
+ True
798
+ >>> correct_bracketing("")(()"")
799
+ False
800
+ """"""
801
+ ",0.050000000000000044,0.25,0.5
802
+ "
803
+
804
+ def derivative(xs: list):
805
+ """""" xs represent coefficients of a polynomial.
806
+ xs[0] + xs[1] * x + xs[2] * x^2 + ....
807
+ Return derivative of this polynomial in the same form.
808
+ >>> derivative([3, 1, 2, 4, 5])
809
+ [1, 4, 12, 20]
810
+ >>> derivative([1, 2, 3])
811
+ [2, 6]
812
+ """"""
813
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
814
+ "
815
+
816
+ def fibfib(n: int):
817
+ """"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
818
+ fibfib(0) == 0
819
+ fibfib(1) == 0
820
+ fibfib(2) == 1
821
+ fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
822
+ Please write a function to efficiently compute the n-th element of the fibfib number sequence.
823
+ >>> fibfib(1)
824
+ 0
825
+ >>> fibfib(5)
826
+ 4
827
+ >>> fibfib(8)
828
+ 24
829
+ """"""
830
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
831
+ "
832
+ FIX = """"""
833
+ Add more test cases.
834
+ """"""
835
+
836
+ def vowels_count(s):
837
+ """"""Write a function vowels_count which takes a string representing
838
+ a word as input and returns the number of vowels in the string.
839
+ Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
840
+ vowel, but only when it is at the end of the given word.
841
+
842
+ Example:
843
+ >>> vowels_count(""abcde"")
844
+ 2
845
+ >>> vowels_count(""ACEDY"")
846
+ 3
847
+ """"""
848
+ ",0.7,0.9996130030959752,1.0
849
+ "
850
+ def circular_shift(x, shift):
851
+ """"""Circular shift the digits of the integer x, shift the digits right by shift
852
+ and return the result as a string.
853
+ If shift > number of digits, return digits reversed.
854
+ >>> circular_shift(12, 1)
855
+ ""21""
856
+ >>> circular_shift(12, 2)
857
+ ""12""
858
+ """"""
859
+ ",0.050000000000000044,0.25,0.5
860
+ "
861
+ def digitSum(s):
862
+ """"""Task
863
+ Write a function that takes a string as input and returns the sum of the upper characters only'
864
+ ASCII codes.
865
+
866
+ Examples:
867
+ digitSum("""") => 0
868
+ digitSum(""abAB"") => 131
869
+ digitSum(""abcCd"") => 67
870
+ digitSum(""helloE"") => 69
871
+ digitSum(""woArBld"") => 131
872
+ digitSum(""aAaaaXa"") => 153
873
+ """"""
874
+ ",0.75,0.9999355005159959,1.0
875
+ "
876
+ def fruit_distribution(s,n):
877
+ """"""
878
+ In this task, you will be given a string that represents a number of apples and oranges
879
+ that are distributed in a basket of fruit this basket contains
880
+ apples, oranges, and mango fruits. Given the string that represents the total number of
881
+ the oranges and apples and an integer that represent the total number of the fruits
882
+ in the basket return the number of the mango fruits in the basket.
883
+ for examble:
884
+ fruit_distribution(""5 apples and 6 oranges"", 19) ->19 - 5 - 6 = 8
885
+ fruit_distribution(""0 apples and 1 oranges"",3) -> 3 - 0 - 1 = 2
886
+ fruit_distribution(""2 apples and 3 oranges"", 100) -> 100 - 2 - 3 = 95
887
+ fruit_distribution(""100 apples and 1 oranges"",120) -> 120 - 100 - 1 = 19
888
+ """"""
889
+ ",0.0,0.0,0.0
890
+ "
891
+ def pluck(arr):
892
+ """"""
893
+ ""Given an array representing a branch of a tree that has non-negative integer nodes
894
+ your task is to pluck one of the nodes and return it.
895
+ The plucked node should be the node with the smallest even value.
896
+ If multiple nodes with the same smallest even value are found return the node that has smallest index.
897
+
898
+ The plucked node should be returned in a list, [ smalest_value, its index ],
899
+ If there are no even values or the given array is empty, return [].
900
+
901
+ Example 1:
902
+ Input: [4,2,3]
903
+ Output: [2, 1]
904
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
905
+
906
+ Example 2:
907
+ Input: [1,2,3]
908
+ Output: [2, 1]
909
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
910
+
911
+ Example 3:
912
+ Input: []
913
+ Output: []
914
+
915
+ Example 4:
916
+ Input: [5, 0, 3, 0, 4, 2]
917
+ Output: [0, 1]
918
+ Explanation: 0 is the smallest value, but there are two zeros,
919
+ so we will choose the first zero, which has the smallest index.
920
+
921
+ Constraints:
922
+ * 1 <= nodes.length <= 10000
923
+ * 0 <= node.value
924
+ """"""
925
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
926
+ "
927
+ def search(lst):
928
+ '''
929
+ You are given a non-empty list of positive integers. Return the greatest integer that is greater than
930
+ zero, and has a frequency greater than or equal to the value of the integer itself.
931
+ The frequency of an integer is the number of times it appears in the list.
932
+ If no such a value exist, return -1.
933
+ Examples:
934
+ search([4, 1, 2, 2, 3, 1]) == 2
935
+ search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
936
+ search([5, 5, 4, 4, 4]) == -1
937
+ '''
938
+ ",0.0,0.0,0.0
939
+ "
940
+ def strange_sort_list(lst):
941
+ '''
942
+ Given list of integers, return list in strange order.
943
+ Strange sorting, is when you start with the minimum value,
944
+ then maximum of the remaining integers, then minimum and so on.
945
+
946
+ Examples:
947
+ strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
948
+ strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
949
+ strange_sort_list([]) == []
950
+ '''
951
+ ",0.0,0.0,0.0
952
+ "
953
+ def triangle_area(a, b, c):
954
+ '''
955
+ Given the lengths of the three sides of a triangle. Return the area of
956
+ the triangle rounded to 2 decimal points if the three sides form a valid triangle.
957
+ Otherwise return -1
958
+ Three sides make a valid triangle when the sum of any two sides is greater
959
+ than the third side.
960
+ Example:
961
+ triangle_area(3, 4, 5) == 6.00
962
+ triangle_area(1, 2, 10) == -1
963
+ '''
964
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
965
+ "
966
+ def will_it_fly(q,w):
967
+ '''
968
+ Write a function that returns True if the object q will fly, and False otherwise.
969
+ 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.
970
+
971
+ Example:
972
+ will_it_fly([1, 2], 5) ➞ False
973
+ # 1+2 is less than the maximum possible weight, but it's unbalanced.
974
+
975
+ will_it_fly([3, 2, 3], 1) ➞ False
976
+ # it's balanced, but 3+2+3 is more than the maximum possible weight.
977
+
978
+ will_it_fly([3, 2, 3], 9) ➞ True
979
+ # 3+2+3 is less than the maximum possible weight, and it's balanced.
980
+
981
+ will_it_fly([3], 5) ➞ True
982
+ # 3 is less than the maximum possible weight, and it's balanced.
983
+ '''
984
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
985
+ "
986
+ def smallest_change(arr):
987
+ """"""
988
+ Given an array arr of integers, find the minimum number of elements that
989
+ need to be changed to make the array palindromic. A palindromic array is an array that
990
+ is read the same backwards and forwards. In one change, you can change one element to any other element.
991
+
992
+ For example:
993
+ smallest_change([1,2,3,5,4,7,9,6]) == 4
994
+ smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
995
+ smallest_change([1, 2, 3, 2, 1]) == 0
996
+ """"""
997
+ ",0.0,0.0,0.0
998
+ "
999
+ def total_match(lst1, lst2):
1000
+ '''
1001
+ Write a function that accepts two lists of strings and returns the list that has
1002
+ total number of chars in the all strings of the list less than the other list.
1003
+
1004
+ if the two lists have the same number of chars, return the first list.
1005
+
1006
+ Examples
1007
+ total_match([], []) ➞ []
1008
+ total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
1009
+ total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
1010
+ total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
1011
+ total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
1012
+ '''
1013
+ ",0.0,0.0,0.0
1014
+ "
1015
+ def is_multiply_prime(a):
1016
+ """"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
1017
+ and false otherwise.
1018
+ Knowing that (a) is less then 100.
1019
+ Example:
1020
+ is_multiply_prime(30) == True
1021
+ 30 = 2 * 3 * 5
1022
+ """"""
1023
+ ",0.050000000000000044,0.25,0.5
1024
+ "
1025
+ def is_simple_power(x, n):
1026
+ """"""Your task is to write a function that returns true if a number x is a simple
1027
+ power of n and false in other cases.
1028
+ x is a simple power of n if n**int=x
1029
+ For example:
1030
+ is_simple_power(1, 4) => true
1031
+ is_simple_power(2, 2) => true
1032
+ is_simple_power(8, 2) => true
1033
+ is_simple_power(3, 2) => false
1034
+ is_simple_power(3, 1) => false
1035
+ is_simple_power(5, 3) => false
1036
+ """"""
1037
+ ",0.0,0.0,0.0
1038
+ "
1039
+ def iscube(a):
1040
+ '''
1041
+ Write a function that takes an integer a and returns True
1042
+ if this ingeger is a cube of some integer number.
1043
+ Note: you may assume the input is always valid.
1044
+ Examples:
1045
+ iscube(1) ==> True
1046
+ iscube(2) ==> False
1047
+ iscube(-1) ==> True
1048
+ iscube(64) ==> True
1049
+ iscube(0) ==> True
1050
+ iscube(180) ==> False
1051
+ '''
1052
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1053
+ "
1054
+ def hex_key(num):
1055
+ """"""You have been tasked to write a function that receives
1056
+ a hexadecimal number as a string and counts the number of hexadecimal
1057
+ digits that are primes (prime number, or a prime, is a natural number
1058
+ greater than 1 that is not a product of two smaller natural numbers).
1059
+ Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
1060
+ Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
1061
+ So you have to determine a number of the following digits: 2, 3, 5, 7,
1062
+ B (=decimal 11), D (=decimal 13).
1063
+ Note: you may assume the input is always correct or empty string,
1064
+ and symbols A,B,C,D,E,F are always uppercase.
1065
+ Examples:
1066
+ For num = ""AB"" the output should be 1.
1067
+ For num = ""1077E"" the output should be 2.
1068
+ For num = ""ABED1A33"" the output should be 4.
1069
+ For num = ""123456789ABCDEF0"" the output should be 6.
1070
+ For num = ""2020"" the output should be 2.
1071
+ """"""
1072
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1073
+ "
1074
+ def decimal_to_binary(decimal):
1075
+ """"""You will be given a number in decimal form and your task is to convert it to
1076
+ binary format. The function should return a string, with each character representing a binary
1077
+ number. Each character in the string will be '0' or '1'.
1078
+
1079
+ There will be an extra couple of characters 'db' at the beginning and at the end of the string.
1080
+ The extra characters are there to help with the format.
1081
+
1082
+ Examples:
1083
+ decimal_to_binary(15) # returns ""db1111db""
1084
+ decimal_to_binary(32) # returns ""db100000db""
1085
+ """"""
1086
+ ",0.65,0.9986455108359134,1.0
1087
+ "
1088
+ def is_happy(s):
1089
+ """"""You are given a string s.
1090
+ Your task is to check if the string is happy or not.
1091
+ A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
1092
+ For example:
1093
+ is_happy(a) => False
1094
+ is_happy(aa) => False
1095
+ is_happy(abcd) => True
1096
+ is_happy(aabb) => False
1097
+ is_happy(adb) => True
1098
+ is_happy(xyy) => False
1099
+ """"""
1100
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1101
+ "
1102
+ def numerical_letter_grade(grades):
1103
+ """"""It is the last week of the semester and the teacher has to give the grades
1104
+ to students. The teacher has been making her own algorithm for grading.
1105
+ The only problem is, she has lost the code she used for grading.
1106
+ She has given you a list of GPAs for some students and you have to write
1107
+ a function that can output a list of letter grades using the following table:
1108
+ GPA | Letter grade
1109
+ 4.0 A+
1110
+ > 3.7 A
1111
+ > 3.3 A-
1112
+ > 3.0 B+
1113
+ > 2.7 B
1114
+ > 2.3 B-
1115
+ > 2.0 C+
1116
+ > 1.7 C
1117
+ > 1.3 C-
1118
+ > 1.0 D+
1119
+ > 0.7 D
1120
+ > 0.0 D-
1121
+ 0.0 E
1122
+
1123
+
1124
+ Example:
1125
+ grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
1126
+ """"""
1127
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1128
+ "
1129
+ def prime_length(string):
1130
+ """"""Write a function that takes a string and returns True if the string
1131
+ length is a prime number or False otherwise
1132
+ Examples
1133
+ prime_length('Hello') == True
1134
+ prime_length('abcdcba') == True
1135
+ prime_length('kittens') == True
1136
+ prime_length('orange') == False
1137
+ """"""
1138
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1139
+ "
1140
+ def starts_one_ends(n):
1141
+ """"""
1142
+ Given a positive integer n, return the count of the numbers of n-digit
1143
+ positive integers that start or end with 1.
1144
+ """"""
1145
+ ",0.0,0.0,0.0
1146
+ "
1147
+ def solve(N):
1148
+ """"""Given a positive integer N, return the total sum of its digits in binary.
1149
+
1150
+ Example
1151
+ For N = 1000, the sum of digits will be 1 the output should be ""1"".
1152
+ For N = 150, the sum of digits will be 6 the output should be ""110"".
1153
+ For N = 147, the sum of digits will be 12 the output should be ""1100"".
1154
+
1155
+ Variables:
1156
+ @N integer
1157
+ Constraints: 0 ≤ N ≤ 10000.
1158
+ Output:
1159
+ a string of binary number
1160
+ """"""
1161
+ ",0.0,0.0,0.0
1162
+ "
1163
+ def add(lst):
1164
+ """"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
1165
+
1166
+
1167
+ Examples:
1168
+ add([4, 2, 6, 7]) ==> 2
1169
+ """"""
1170
+ ",0.4,0.9489164086687306,0.9996427720885925
1171
+ "
1172
+ def anti_shuffle(s):
1173
+ """"""
1174
+ Write a function that takes a string and returns an ordered version of it.
1175
+ Ordered version of string, is a string where all words (separated by space)
1176
+ are replaced by a new word where all the characters arranged in
1177
+ ascending order based on ascii value.
1178
+ Note: You should keep the order of words and blank spaces in the sentence.
1179
+
1180
+ For example:
1181
+ anti_shuffle('Hi') returns 'Hi'
1182
+ anti_shuffle('hello') returns 'ehllo'
1183
+ anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
1184
+ """"""
1185
+ ",0.5499999999999998,0.9918730650154799,1.0
1186
+ "
1187
+ def get_row(lst, x):
1188
+ """"""
1189
+ You are given a 2 dimensional data, as a nested lists,
1190
+ which is similar to matrix, however, unlike matrices,
1191
+ each row may contain a different number of columns.
1192
+ Given lst, and integer x, find integers x in the list,
1193
+ and return list of tuples, [(x1, y1), (x2, y2) ...] such that
1194
+ each tuple is a coordinate - (row, columns), starting with 0.
1195
+ Sort coordinates initially by rows in ascending order.
1196
+ Also, sort coordinates of the row by columns in descending order.
1197
+
1198
+ Examples:
1199
+ get_row([
1200
+ [1,2,3,4,5,6],
1201
+ [1,2,3,4,1,6],
1202
+ [1,2,3,4,5,1]
1203
+ ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
1204
+ get_row([], 1) == []
1205
+ get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
1206
+ """"""
1207
+ ",0.0,0.0,0.0
1208
+ "
1209
+ def sort_array(array):
1210
+ """"""
1211
+ Given an array of non-negative integers, return a copy of the given array after sorting,
1212
+ you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
1213
+ or sort it in descending order if the sum( first index value, last index value) is even.
1214
+
1215
+ Note:
1216
+ * don't change the given array.
1217
+
1218
+ Examples:
1219
+ * sort_array([]) => []
1220
+ * sort_array([5]) => [5]
1221
+ * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
1222
+ * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
1223
+ """"""
1224
+ ",0.050000000000000044,0.25,0.5
1225
+ "
1226
+ def encrypt(s):
1227
+ """"""Create a function encrypt that takes a string as an argument and
1228
+ returns a string encrypted with the alphabet being rotated.
1229
+ The alphabet should be rotated in a manner such that the letters
1230
+ shift down by two multiplied to two places.
1231
+ For example:
1232
+ encrypt('hi') returns 'lm'
1233
+ encrypt('asdfghjkl') returns 'ewhjklnop'
1234
+ encrypt('gf') returns 'kj'
1235
+ encrypt('et') returns 'ix'
1236
+ """"""
1237
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1238
+ "
1239
+ def next_smallest(lst):
1240
+ """"""
1241
+ You are given a list of integers.
1242
+ Write a function next_smallest() that returns the 2nd smallest element of the list.
1243
+ Return None if there is no such element.
1244
+
1245
+ next_smallest([1, 2, 3, 4, 5]) == 2
1246
+ next_smallest([5, 1, 4, 3, 2]) == 2
1247
+ next_smallest([]) == None
1248
+ next_smallest([1, 1]) == None
1249
+ """"""
1250
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1251
+ "
1252
+ def is_bored(S):
1253
+ """"""
1254
+ You'll be given a string of words, and your task is to count the number
1255
+ of boredoms. A boredom is a sentence that starts with the word ""I"".
1256
+ Sentences are delimited by '.', '?' or '!'.
1257
+
1258
+ For example:
1259
+ >>> is_bored(""Hello world"")
1260
+ 0
1261
+ >>> is_bored(""The sky is blue. The sun is shining. I love this weather"")
1262
+ 1
1263
+ """"""
1264
+ ",0.0,0.0,0.0
1265
+ "
1266
+ def any_int(x, y, z):
1267
+ '''
1268
+ Create a function that takes 3 numbers.
1269
+ Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
1270
+ Returns false in any other cases.
1271
+
1272
+ Examples
1273
+ any_int(5, 2, 7) ➞ True
1274
+
1275
+ any_int(3, 2, 2) ➞ False
1276
+
1277
+ any_int(3, -2, 1) ➞ True
1278
+
1279
+ any_int(3.6, -2.2, 2) ➞ False
1280
+
1281
+
1282
+
1283
+ '''
1284
+ ",0.4,0.9489164086687306,0.9996427720885925
1285
+ "
1286
+ def encode(message):
1287
+ """"""
1288
+ Write a function that takes a message, and encodes in such a
1289
+ way that it swaps case of all letters, replaces all vowels in
1290
+ the message with the letter that appears 2 places ahead of that
1291
+ vowel in the english alphabet.
1292
+ Assume only letters.
1293
+
1294
+ Examples:
1295
+ >>> encode('test')
1296
+ 'TGST'
1297
+ >>> encode('This is a message')
1298
+ 'tHKS KS C MGSSCGG'
1299
+ """"""
1300
+ ",0.0,0.0,0.0
1301
+ "
1302
+
1303
+ def skjkasdkd(lst):
1304
+ """"""You are given a list of integers.
1305
+ You need to find the largest prime value and return the sum of its digits.
1306
+
1307
+ Examples:
1308
+ For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
1309
+ For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
1310
+ For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
1311
+ For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
1312
+ For lst = [0,81,12,3,1,21] the output should be 3
1313
+ For lst = [0,8,1,2,1,7] the output should be 7
1314
+ """"""
1315
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1316
+ "
1317
+ def check_dict_case(dict):
1318
+ """"""
1319
+ Given a dictionary, return True if all keys are strings in lower
1320
+ case or all keys are strings in upper case, else return False.
1321
+ The function should return False is the given dictionary is empty.
1322
+ Examples:
1323
+ check_dict_case({""a"":""apple"", ""b"":""banana""}) should return True.
1324
+ check_dict_case({""a"":""apple"", ""A"":""banana"", ""B"":""banana""}) should return False.
1325
+ check_dict_case({""a"":""apple"", 8:""banana"", ""a"":""apple""}) should return False.
1326
+ check_dict_case({""Name"":""John"", ""Age"":""36"", ""City"":""Houston""}) should return False.
1327
+ check_dict_case({""STATE"":""NC"", ""ZIP"":""12345"" }) should return True.
1328
+ """"""
1329
+ ",0.050000000000000044,0.25,0.5
1330
+ "
1331
+ def count_up_to(n):
1332
+ """"""Implement a function that takes an non-negative integer and returns an array of the first n
1333
+ integers that are prime numbers and less than n.
1334
+ for example:
1335
+ count_up_to(5) => [2,3]
1336
+ count_up_to(11) => [2,3,5,7]
1337
+ count_up_to(0) => []
1338
+ count_up_to(20) => [2,3,5,7,11,13,17,19]
1339
+ count_up_to(1) => []
1340
+ count_up_to(18) => [2,3,5,7,11,13,17]
1341
+ """"""
1342
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
1343
+ "
1344
+ def multiply(a, b):
1345
+ """"""Complete the function that takes two integers and returns
1346
+ the product of their unit digits.
1347
+ Assume the input is always valid.
1348
+ Examples:
1349
+ multiply(148, 412) should return 16.
1350
+ multiply(19, 28) should return 72.
1351
+ multiply(2020, 1851) should return 0.
1352
+ multiply(14,-15) should return 20.
1353
+ """"""
1354
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1355
+ "
1356
+ def count_upper(s):
1357
+ """"""
1358
+ Given a string s, count the number of uppercase vowels in even indices.
1359
+
1360
+ For example:
1361
+ count_upper('aBCdEf') returns 1
1362
+ count_upper('abcdefg') returns 0
1363
+ count_upper('dBBE') returns 0
1364
+ """"""
1365
+ ",0.25,0.8063080495356036,0.9837461300309598
1366
+ "
1367
+ def closest_integer(value):
1368
+ '''
1369
+ Create a function that takes a value (string) representing a number
1370
+ and returns the closest integer to it. If the number is equidistant
1371
+ from two integers, round it away from zero.
1372
+
1373
+ Examples
1374
+ >>> closest_integer(""10"")
1375
+ 10
1376
+ >>> closest_integer(""15.3"")
1377
+ 15
1378
+
1379
+ Note:
1380
+ Rounding away from zero means that if the given number is equidistant
1381
+ from two integers, the one you should return is the one that is the
1382
+ farthest from zero. For example closest_integer(""14.5"") should
1383
+ return 15 and closest_integer(""-14.5"") should return -15.
1384
+ '''
1385
+ ",0.0,0.0,0.0
1386
+ "
1387
+ def make_a_pile(n):
1388
+ """"""
1389
+ Given a positive integer n, you have to make a pile of n levels of stones.
1390
+ The first level has n stones.
1391
+ The number of stones in the next level is:
1392
+ - the next odd number if n is odd.
1393
+ - the next even number if n is even.
1394
+ Return the number of stones in each level in a list, where element at index
1395
+ i represents the number of stones in the level (i+1).
1396
+
1397
+ Examples:
1398
+ >>> make_a_pile(3)
1399
+ [3, 5, 7]
1400
+ """"""
1401
+ ",0.050000000000000044,0.25,0.5
1402
+ "
1403
+ def words_string(s):
1404
+ """"""
1405
+ You will be given a string of words separated by commas or spaces. Your task is
1406
+ to split the string into words and return an array of the words.
1407
+
1408
+ For example:
1409
+ words_string(""Hi, my name is John"") == [""Hi"", ""my"", ""name"", ""is"", ""John""]
1410
+ words_string(""One, two, three, four, five, six"") == [""One"", ""two"", ""three"", ""four"", ""five"", ""six""]
1411
+ """"""
1412
+ ",0.0,0.0,0.0
1413
+ "
1414
+ def choose_num(x, y):
1415
+ """"""This function takes two positive numbers x and y and returns the
1416
+ biggest even integer number that is in the range [x, y] inclusive. If
1417
+ there's no such number, then the function should return -1.
1418
+
1419
+ For example:
1420
+ choose_num(12, 15) = 14
1421
+ choose_num(13, 12) = -1
1422
+ """"""
1423
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1424
+ "
1425
+ def rounded_avg(n, m):
1426
+ """"""You are given two positive integers n and m, and your task is to compute the
1427
+ average of the integers from n through m (including n and m).
1428
+ Round the answer to the nearest integer and convert that to binary.
1429
+ If n is greater than m, return -1.
1430
+ Example:
1431
+ rounded_avg(1, 5) => ""0b11""
1432
+ rounded_avg(7, 5) => -1
1433
+ rounded_avg(10, 20) => ""0b1111""
1434
+ rounded_avg(20, 33) => ""0b11010""
1435
+ """"""
1436
+ ",0.0,0.0,0.0
1437
+ "
1438
+ def unique_digits(x):
1439
+ """"""Given a list of positive integers x. return a sorted list of all
1440
+ elements that hasn't any even digit.
1441
+
1442
+ Note: Returned list should be sorted in increasing order.
1443
+
1444
+ For example:
1445
+ >>> unique_digits([15, 33, 1422, 1])
1446
+ [1, 15, 33]
1447
+ >>> unique_digits([152, 323, 1422, 10])
1448
+ []
1449
+ """"""
1450
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1451
+ "
1452
+ def by_length(arr):
1453
+ """"""
1454
+ Given an array of integers, sort the integers that are between 1 and 9 inclusive,
1455
+ reverse the resulting array, and then replace each digit by its corresponding name from
1456
+ ""One"", ""Two"", ""Three"", ""Four"", ""Five"", ""Six"", ""Seven"", ""Eight"", ""Nine"".
1457
+
1458
+ For example:
1459
+ arr = [2, 1, 1, 4, 5, 8, 2, 3]
1460
+ -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
1461
+ -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
1462
+ return [""Eight"", ""Five"", ""Four"", ""Three"", ""Two"", ""Two"", ""One"", ""One""]
1463
+
1464
+ If the array is empty, return an empty array:
1465
+ arr = []
1466
+ return []
1467
+
1468
+ If the array has any strange number ignore it:
1469
+ arr = [1, -1 , 55]
1470
+ -> sort arr -> [-1, 1, 55]
1471
+ -> reverse arr -> [55, 1, -1]
1472
+ return = ['One']
1473
+ """"""
1474
+ ",0.25,0.8063080495356036,0.9837461300309598
1475
+ "
1476
+ def f(n):
1477
+ """""" Implement the function f that takes n as a parameter,
1478
+ 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
1479
+ or the sum of numbers from 1 to i otherwise.
1480
+ i starts from 1.
1481
+ the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
1482
+ Example:
1483
+ f(5) == [1, 2, 6, 24, 15]
1484
+ """"""
1485
+ ",0.0,0.0,0.0
1486
+ "
1487
+ def even_odd_palindrome(n):
1488
+ """"""
1489
+ Given a positive integer n, return a tuple that has the number of even and odd
1490
+ integer palindromes that fall within the range(1, n), inclusive.
1491
+
1492
+ Example 1:
1493
+
1494
+ Input: 3
1495
+ Output: (1, 2)
1496
+ Explanation:
1497
+ Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
1498
+
1499
+ Example 2:
1500
+
1501
+ Input: 12
1502
+ Output: (4, 6)
1503
+ Explanation:
1504
+ Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
1505
+
1506
+ Note:
1507
+ 1. 1 <= n <= 10^3
1508
+ 2. returned tuple has the number of even and odd integer palindromes respectively.
1509
+ """"""
1510
+ ",0.95,1.0,1.0
1511
+ "
1512
+ def count_nums(arr):
1513
+ """"""
1514
+ Write a function count_nums which takes an array of integers and returns
1515
+ the number of elements which has a sum of digits > 0.
1516
+ If a number is negative, then its first signed digit will be negative:
1517
+ e.g. -123 has signed digits -1, 2, and 3.
1518
+ >>> count_nums([]) == 0
1519
+ >>> count_nums([-1, 11, -11]) == 1
1520
+ >>> count_nums([1, 1, 2]) == 3
1521
+ """"""
1522
+ ",0.0,0.0,0.0
1523
+ "
1524
+ def move_one_ball(arr):
1525
+ """"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
1526
+ numbers in the array will be randomly ordered. Your task is to determine if
1527
+ it is possible to get an array sorted in non-decreasing order by performing
1528
+ the following operation on the given array:
1529
+ You are allowed to perform right shift operation any number of times.
1530
+
1531
+ One right shift operation means shifting all elements of the array by one
1532
+ position in the right direction. The last element of the array will be moved to
1533
+ the starting position in the array i.e. 0th index.
1534
+
1535
+ If it is possible to obtain the sorted array by performing the above operation
1536
+ then return True else return False.
1537
+ If the given array is empty then return True.
1538
+
1539
+ Note: The given list is guaranteed to have unique elements.
1540
+
1541
+ For Example:
1542
+
1543
+ move_one_ball([3, 4, 5, 1, 2])==>True
1544
+ Explanation: By performin 2 right shift operations, non-decreasing order can
1545
+ be achieved for the given array.
1546
+ move_one_ball([3, 5, 4, 1, 2])==>False
1547
+ Explanation:It is not possible to get non-decreasing order for the given
1548
+ array by performing any number of right shift operations.
1549
+
1550
+ """"""
1551
+ ",0.050000000000000044,0.25,0.5
1552
+ "
1553
+ def exchange(lst1, lst2):
1554
+ """"""In this problem, you will implement a function that takes two lists of numbers,
1555
+ and determines whether it is possible to perform an exchange of elements
1556
+ between them to make lst1 a list of only even numbers.
1557
+ There is no limit on the number of exchanged elements between lst1 and lst2.
1558
+ If it is possible to exchange elements between the lst1 and lst2 to make
1559
+ all the elements of lst1 to be even, return ""YES"".
1560
+ Otherwise, return ""NO"".
1561
+ For example:
1562
+ exchange([1, 2, 3, 4], [1, 2, 3, 4]) => ""YES""
1563
+ exchange([1, 2, 3, 4], [1, 5, 3, 4]) => ""NO""
1564
+ It is assumed that the input lists will be non-empty.
1565
+ """"""
1566
+ ",0.0,0.0,0.0
1567
+ "
1568
+ def histogram(test):
1569
+ """"""Given a string representing a space separated lowercase letters, return a dictionary
1570
+ of the letter with the most repetition and containing the corresponding count.
1571
+ If several letters have the same occurrence, return all of them.
1572
+
1573
+ Example:
1574
+ histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
1575
+ histogram('a b b a') == {'a': 2, 'b': 2}
1576
+ histogram('a b c a b') == {'a': 2, 'b': 2}
1577
+ histogram('b b b b a') == {'b': 4}
1578
+ histogram('') == {}
1579
+
1580
+ """"""
1581
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1582
+ "
1583
+ def reverse_delete(s,c):
1584
+ """"""Task
1585
+ 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
1586
+ then check if the result string is palindrome.
1587
+ A string is called palindrome if it reads the same backward as forward.
1588
+ You should return a tuple containing the result string and True/False for the check.
1589
+ Example
1590
+ For s = ""abcde"", c = ""ae"", the result should be ('bcd',False)
1591
+ For s = ""abcdef"", c = ""b"" the result should be ('acdef',False)
1592
+ For s = ""abcdedcba"", c = ""ab"", the result should be ('cdedc',True)
1593
+ """"""
1594
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1595
+ "
1596
+ def odd_count(lst):
1597
+ """"""Given a list of strings, where each string consists of only digits, return a list.
1598
+ Each element i of the output should be ""the number of odd elements in the
1599
+ string i of the input."" where all the i's should be replaced by the number
1600
+ of odd digits in the i'th string of the input.
1601
+
1602
+ >>> odd_count(['1234567'])
1603
+ [""the number of odd elements 4n the str4ng 4 of the 4nput.""]
1604
+ >>> odd_count(['3',""11111111""])
1605
+ [""the number of odd elements 1n the str1ng 1 of the 1nput."",
1606
+ ""the number of odd elements 8n the str8ng 8 of the 8nput.""]
1607
+ """"""
1608
+ ",0.050000000000000044,0.25,0.5
1609
+ "
1610
+ def minSubArraySum(nums):
1611
+ """"""
1612
+ Given an array of integers nums, find the minimum sum of any non-empty sub-array
1613
+ of nums.
1614
+ Example
1615
+ minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
1616
+ minSubArraySum([-1, -2, -3]) == -6
1617
+ """"""
1618
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1619
+ "
1620
+ def max_fill(grid, capacity):
1621
+ import math
1622
+ """"""
1623
+ You are given a rectangular grid of wells. Each row represents a single well,
1624
+ and each 1 in a row represents a single unit of water.
1625
+ Each well has a corresponding bucket that can be used to extract water from it,
1626
+ and all buckets have the same capacity.
1627
+ Your task is to use the buckets to empty the wells.
1628
+ Output the number of times you need to lower the buckets.
1629
+
1630
+ Example 1:
1631
+ Input:
1632
+ grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
1633
+ bucket_capacity : 1
1634
+ Output: 6
1635
+
1636
+ Example 2:
1637
+ Input:
1638
+ grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
1639
+ bucket_capacity : 2
1640
+ Output: 5
1641
+
1642
+ Example 3:
1643
+ Input:
1644
+ grid : [[0,0,0], [0,0,0]]
1645
+ bucket_capacity : 5
1646
+ Output: 0
1647
+
1648
+ Constraints:
1649
+ * all wells have the same length
1650
+ * 1 <= grid.length <= 10^2
1651
+ * 1 <= grid[:,1].length <= 10^2
1652
+ * grid[i][j] -> 0 | 1
1653
+ * 1 <= capacity <= 10
1654
+ """"""
1655
+ ",0.0,0.0,0.0
1656
+ "
1657
+ def sort_array(arr):
1658
+ """"""
1659
+ In this Kata, you have to sort an array of non-negative integers according to
1660
+ number of ones in their binary representation in ascending order.
1661
+ For similar number of ones, sort based on decimal value.
1662
+
1663
+ It must be implemented like this:
1664
+ >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
1665
+ >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
1666
+ >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
1667
+ """"""
1668
+ ",0.85,1.0,1.0
1669
+ "
1670
+ def select_words(s, n):
1671
+ """"""Given a string s and a natural number n, you have been tasked to implement
1672
+ a function that returns a list of all words from string s that contain exactly
1673
+ n consonants, in order these words appear in the string s.
1674
+ If the string s is empty then the function should return an empty list.
1675
+ Note: you may assume the input string contains only letters and spaces.
1676
+ Examples:
1677
+ select_words(""Mary had a little lamb"", 4) ==> [""little""]
1678
+ select_words(""Mary had a little lamb"", 3) ==> [""Mary"", ""lamb""]
1679
+ select_words(""simple white space"", 2) ==> []
1680
+ select_words(""Hello world"", 4) ==> [""world""]
1681
+ select_words(""Uncle sam"", 3) ==> [""Uncle""]
1682
+ """"""
1683
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1684
+ "
1685
+ def get_closest_vowel(word):
1686
+ """"""You are given a word. Your task is to find the closest vowel that stands between
1687
+ two consonants from the right side of the word (case sensitive).
1688
+
1689
+ Vowels in the beginning and ending doesn't count. Return empty string if you didn't
1690
+ find any vowel met the above condition.
1691
+
1692
+ You may assume that the given string contains English letter only.
1693
+
1694
+ Example:
1695
+ get_closest_vowel(""yogurt"") ==> ""u""
1696
+ get_closest_vowel(""FULL"") ==> ""U""
1697
+ get_closest_vowel(""quick"") ==> """"
1698
+ get_closest_vowel(""ab"") ==> """"
1699
+ """"""
1700
+ ",0.050000000000000044,0.25,0.5
1701
+ "
1702
+ def match_parens(lst):
1703
+ '''
1704
+ You are given a list of two strings, both strings consist of open
1705
+ parentheses '(' or close parentheses ')' only.
1706
+ Your job is to check if it is possible to concatenate the two strings in
1707
+ some order, that the resulting string will be good.
1708
+ A string S is considered to be good if and only if all parentheses in S
1709
+ are balanced. For example: the string '(())()' is good, while the string
1710
+ '())' is not.
1711
+ Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
1712
+
1713
+ Examples:
1714
+ match_parens(['()(', ')']) == 'Yes'
1715
+ match_parens([')', ')']) == 'No'
1716
+ '''
1717
+ ",0.0,0.0,0.0
1718
+ "
1719
+ def maximum(arr, k):
1720
+ """"""
1721
+ Given an array arr of integers and a positive integer k, return a sorted list
1722
+ of length k with the maximum k numbers in arr.
1723
+
1724
+ Example 1:
1725
+
1726
+ Input: arr = [-3, -4, 5], k = 3
1727
+ Output: [-4, -3, 5]
1728
+
1729
+ Example 2:
1730
+
1731
+ Input: arr = [4, -4, 4], k = 2
1732
+ Output: [4, 4]
1733
+
1734
+ Example 3:
1735
+
1736
+ Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
1737
+ Output: [2]
1738
+
1739
+ Note:
1740
+ 1. The length of the array will be in the range of [1, 1000].
1741
+ 2. The elements in the array will be in the range of [-1000, 1000].
1742
+ 3. 0 <= k <= len(arr)
1743
+ """"""
1744
+ ",0.0,0.0,0.0
1745
+ "
1746
+ def solution(lst):
1747
+ """"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
1748
+
1749
+
1750
+ Examples
1751
+ solution([5, 8, 7, 1]) ==> 12
1752
+ solution([3, 3, 3, 3, 3]) ==> 9
1753
+ solution([30, 13, 24, 321]) ==>0
1754
+ """"""
1755
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1756
+ "
1757
+ def add_elements(arr, k):
1758
+ """"""
1759
+ Given a non-empty array of integers arr and an integer k, return
1760
+ the sum of the elements with at most two digits from the first k elements of arr.
1761
+
1762
+ Example:
1763
+
1764
+ Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
1765
+ Output: 24 # sum of 21 + 3
1766
+
1767
+ Constraints:
1768
+ 1. 1 <= len(arr) <= 100
1769
+ 2. 1 <= k <= len(arr)
1770
+ """"""
1771
+ ",0.050000000000000044,0.25,0.5
1772
+ "
1773
+ def get_odd_collatz(n):
1774
+ """"""
1775
+ Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
1776
+
1777
+ The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
1778
+ as follows: start with any positive integer n. Then each term is obtained from the
1779
+ previous term as follows: if the previous term is even, the next term is one half of
1780
+ the previous term. If the previous term is odd, the next term is 3 times the previous
1781
+ term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
1782
+
1783
+ Note:
1784
+ 1. Collatz(1) is [1].
1785
+ 2. returned list sorted in increasing order.
1786
+
1787
+ For example:
1788
+ get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
1789
+ """"""
1790
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1791
+ "
1792
+ def valid_date(date):
1793
+ """"""You have to write a function which validates a given date string and
1794
+ returns True if the date is valid otherwise False.
1795
+ The date is valid if all of the following rules are satisfied:
1796
+ 1. The date string is not empty.
1797
+ 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
1798
+ 3. The months should not be less than 1 or higher than 12.
1799
+ 4. The date should be in the format: mm-dd-yyyy
1800
+
1801
+ for example:
1802
+ valid_date('03-11-2000') => True
1803
+
1804
+ valid_date('15-01-2012') => False
1805
+
1806
+ valid_date('04-0-2040') => False
1807
+
1808
+ valid_date('06-04-2020') => True
1809
+
1810
+ valid_date('06/04/2020') => False
1811
+ """"""
1812
+ ",0.0,0.0,0.0
1813
+ "
1814
+ def split_words(txt):
1815
+ '''
1816
+ Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
1817
+ should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
1818
+ alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
1819
+ Examples
1820
+ split_words(""Hello world!"") ➞ [""Hello"", ""world!""]
1821
+ split_words(""Hello,world!"") ➞ [""Hello"", ""world!""]
1822
+ split_words(""abcdef"") == 3
1823
+ '''
1824
+ ",0.0,0.0,0.0
1825
+ "
1826
+ def is_sorted(lst):
1827
+ '''
1828
+ Given a list of numbers, return whether or not they are sorted
1829
+ in ascending order. If list has more than 1 duplicate of the same
1830
+ number, return False. Assume no negative numbers and only integers.
1831
+
1832
+ Examples
1833
+ is_sorted([5]) ➞ True
1834
+ is_sorted([1, 2, 3, 4, 5]) ➞ True
1835
+ is_sorted([1, 3, 2, 4, 5]) ➞ False
1836
+ is_sorted([1, 2, 3, 4, 5, 6]) ➞ True
1837
+ is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
1838
+ is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
1839
+ is_sorted([1, 2, 2, 3, 3, 4]) ➞ True
1840
+ is_sorted([1, 2, 2, 2, 3, 4]) ➞ False
1841
+ '''
1842
+ ",0.0,0.0,0.0
1843
+ "
1844
+ def intersection(interval1, interval2):
1845
+ """"""You are given two intervals,
1846
+ where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
1847
+ The given intervals are closed which means that the interval (start, end)
1848
+ includes both start and end.
1849
+ For each given interval, it is assumed that its start is less or equal its end.
1850
+ Your task is to determine whether the length of intersection of these two
1851
+ intervals is a prime number.
1852
+ Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
1853
+ which its length is 1, which not a prime number.
1854
+ If the length of the intersection is a prime number, return ""YES"",
1855
+ otherwise, return ""NO"".
1856
+ If the two intervals don't intersect, return ""NO"".
1857
+
1858
+
1859
+ [input/output] samples:
1860
+ intersection((1, 2), (2, 3)) ==> ""NO""
1861
+ intersection((-1, 1), (0, 4)) ==> ""NO""
1862
+ intersection((-3, -1), (-5, 5)) ==> ""YES""
1863
+ """"""
1864
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1865
+ "
1866
+ def prod_signs(arr):
1867
+ """"""
1868
+ You are given an array arr of integers and you need to return
1869
+ sum of magnitudes of integers multiplied by product of all signs
1870
+ of each number in the array, represented by 1, -1 or 0.
1871
+ Note: return None for empty arr.
1872
+
1873
+ Example:
1874
+ >>> prod_signs([1, 2, 2, -4]) == -9
1875
+ >>> prod_signs([0, 1]) == 0
1876
+ >>> prod_signs([]) == None
1877
+ """"""
1878
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1879
+ "
1880
+ def minPath(grid, k):
1881
+ """"""
1882
+ Given a grid with N rows and N columns (N >= 2) and a positive integer k,
1883
+ each cell of the grid contains a value. Every integer in the range [1, N * N]
1884
+ inclusive appears exactly once on the cells of the grid.
1885
+
1886
+ You have to find the minimum path of length k in the grid. You can start
1887
+ from any cell, and in each step you can move to any of the neighbor cells,
1888
+ in other words, you can go to cells which share an edge with you current
1889
+ cell.
1890
+ Please note that a path of length k means visiting exactly k cells (not
1891
+ necessarily distinct).
1892
+ You CANNOT go off the grid.
1893
+ A path A (of length k) is considered less than a path B (of length k) if
1894
+ after making the ordered lists of the values on the cells that A and B go
1895
+ through (let's call them lst_A and lst_B), lst_A is lexicographically less
1896
+ than lst_B, in other words, there exist an integer index i (1 <= i <= k)
1897
+ such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
1898
+ lst_A[j] = lst_B[j].
1899
+ It is guaranteed that the answer is unique.
1900
+ Return an ordered list of the values on the cells that the minimum path go through.
1901
+
1902
+ Examples:
1903
+
1904
+ Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
1905
+ Output: [1, 2, 1]
1906
+
1907
+ Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
1908
+ Output: [1]
1909
+ """"""
1910
+ ",0.0,0.0,0.0
1911
+ "
1912
+ def tri(n):
1913
+ """"""Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
1914
+ the last couple centuries. However, what people don't know is Tribonacci sequence.
1915
+ Tribonacci sequence is defined by the recurrence:
1916
+ tri(1) = 3
1917
+ tri(n) = 1 + n / 2, if n is even.
1918
+ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
1919
+ For example:
1920
+ tri(2) = 1 + (2 / 2) = 2
1921
+ tri(4) = 3
1922
+ tri(3) = tri(2) + tri(1) + tri(4)
1923
+ = 2 + 3 + 3 = 8
1924
+ You are given a non-negative integer number n, you have to a return a list of the
1925
+ first n + 1 numbers of the Tribonacci sequence.
1926
+ Examples:
1927
+ tri(3) = [1, 3, 2, 8]
1928
+ """"""
1929
+ ",0.0,0.0,0.0
1930
+ "
1931
+ def digits(n):
1932
+ """"""Given a positive integer n, return the product of the odd digits.
1933
+ Return 0 if all digits are even.
1934
+ For example:
1935
+ digits(1) == 1
1936
+ digits(4) == 0
1937
+ digits(235) == 15
1938
+ """"""
1939
+ ",0.0,0.0,0.0
1940
+ "
1941
+ def is_nested(string):
1942
+ '''
1943
+ Create a function that takes a string as input which contains only square brackets.
1944
+ The function should return True if and only if there is a valid subsequence of brackets
1945
+ where at least one bracket in the subsequence is nested.
1946
+
1947
+ is_nested('[[]]') ➞ True
1948
+ is_nested('[]]]]]]][[[[[]') ➞ False
1949
+ is_nested('[][]') ➞ False
1950
+ is_nested('[]') ➞ False
1951
+ is_nested('[[][]]') ➞ True
1952
+ is_nested('[[]][[') ➞ True
1953
+ '''
1954
+ ",0.0,0.0,0.0
1955
+ "
1956
+
1957
+ def sum_squares(lst):
1958
+ """"""You are given a list of numbers.
1959
+ You need to return the sum of squared numbers in the given list,
1960
+ round each element in the list to the upper int(Ceiling) first.
1961
+ Examples:
1962
+ For lst = [1,2,3] the output should be 14
1963
+ For lst = [1,4,9] the output should be 98
1964
+ For lst = [1,3,5,7] the output should be 84
1965
+ For lst = [1.4,4.2,0] the output should be 29
1966
+ For lst = [-2.4,1,1] the output should be 6
1967
+
1968
+
1969
+ """"""
1970
+ ",0.0,0.0,0.0
1971
+ "
1972
+ def check_if_last_char_is_a_letter(txt):
1973
+ '''
1974
+ Create a function that returns True if the last character
1975
+ of a given string is an alphabetical character and is not
1976
+ a part of a word, and False otherwise.
1977
+ Note: ""word"" is a group of characters separated by space.
1978
+
1979
+ Examples:
1980
+ check_if_last_char_is_a_letter(""apple pie"") ➞ False
1981
+ check_if_last_char_is_a_letter(""apple pi e"") ➞ True
1982
+ check_if_last_char_is_a_letter(""apple pi e "") ➞ False
1983
+ check_if_last_char_is_a_letter("""") ➞ False
1984
+ '''
1985
+ ",0.0,0.0,0.0
1986
+ "
1987
+ def can_arrange(arr):
1988
+ """"""Create a function which returns the largest index of an element which
1989
+ is not greater than or equal to the element immediately preceding it. If
1990
+ no such element exists then return -1. The given array will not contain
1991
+ duplicate values.
1992
+
1993
+ Examples:
1994
+ can_arrange([1,2,4,3,5]) = 3
1995
+ can_arrange([1,2,3]) = -1
1996
+ """"""
1997
+ ",0.050000000000000044,0.25,0.5
1998
+ "
1999
+ def largest_smallest_integers(lst):
2000
+ '''
2001
+ Create a function that returns a tuple (a, b), where 'a' is
2002
+ the largest of negative integers, and 'b' is the smallest
2003
+ of positive integers in a list.
2004
+ If there is no negative or positive integers, return them as None.
2005
+
2006
+ Examples:
2007
+ largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
2008
+ largest_smallest_integers([]) == (None, None)
2009
+ largest_smallest_integers([0]) == (None, None)
2010
+ '''
2011
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
2012
+ "
2013
+ def compare_one(a, b):
2014
+ """"""
2015
+ Create a function that takes integers, floats, or strings representing
2016
+ real numbers, and returns the larger variable in its given variable type.
2017
+ Return None if the values are equal.
2018
+ Note: If a real number is represented as a string, the floating point might be . or ,
2019
+
2020
+ compare_one(1, 2.5) ➞ 2.5
2021
+ compare_one(1, ""2,3"") ➞ ""2,3""
2022
+ compare_one(""5,1"", ""6"") ➞ ""6""
2023
+ compare_one(""1"", 1) ➞ None
2024
+ """"""
2025
+ ",0.0,0.0,0.0
2026
+ "
2027
+ def is_equal_to_sum_even(n):
2028
+ """"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
2029
+ Example
2030
+ is_equal_to_sum_even(4) == False
2031
+ is_equal_to_sum_even(6) == False
2032
+ is_equal_to_sum_even(8) == True
2033
+ """"""
2034
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2035
+ "
2036
+ def special_factorial(n):
2037
+ """"""The Brazilian factorial is defined as:
2038
+ brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
2039
+ where n > 0
2040
+
2041
+ For example:
2042
+ >>> special_factorial(4)
2043
+ 288
2044
+
2045
+ The function will receive an integer as input and should return the special
2046
+ factorial of this integer.
2047
+ """"""
2048
+ ",0.0,0.0,0.0
2049
+ "
2050
+ def fix_spaces(text):
2051
+ """"""
2052
+ Given a string text, replace all spaces in it with underscores,
2053
+ and if a string has more than 2 consecutive spaces,
2054
+ then replace all consecutive spaces with -
2055
+
2056
+ fix_spaces(""Example"") == ""Example""
2057
+ fix_spaces(""Example 1"") == ""Example_1""
2058
+ fix_spaces("" Example 2"") == ""_Example_2""
2059
+ fix_spaces("" Example 3"") == ""_Example-3""
2060
+ """"""
2061
+ ",0.0,0.0,0.0
2062
+ "
2063
+ def file_name_check(file_name):
2064
+ """"""Create a function which takes a string representing a file's name, and returns
2065
+ 'Yes' if the the file's name is valid, and returns 'No' otherwise.
2066
+ A file's name is considered to be valid if and only if all the following conditions
2067
+ are met:
2068
+ - There should not be more than three digits ('0'-'9') in the file's name.
2069
+ - The file's name contains exactly one dot '.'
2070
+ - The substring before the dot should not be empty, and it starts with a letter from
2071
+ the latin alphapet ('a'-'z' and 'A'-'Z').
2072
+ - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
2073
+ Examples:
2074
+ file_name_check(""example.txt"") # => 'Yes'
2075
+ file_name_check(""1example.dll"") # => 'No' (the name should start with a latin alphapet letter)
2076
+ """"""
2077
+ ",0.0,0.0,0.0
2078
+ "
2079
+
2080
+
2081
+ def sum_squares(lst):
2082
+ """"""""
2083
+ 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
2084
+ 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
2085
+ 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.
2086
+
2087
+ Examples:
2088
+ For lst = [1,2,3] the output should be 6
2089
+ For lst = [] the output should be 0
2090
+ For lst = [-1,-5,2,-1,-5] the output should be -126
2091
+ """"""
2092
+ ",0.0,0.0,0.0
2093
+ "
2094
+ def words_in_sentence(sentence):
2095
+ """"""
2096
+ You are given a string representing a sentence,
2097
+ the sentence contains some words separated by a space,
2098
+ and you have to return a string that contains the words from the original sentence,
2099
+ whose lengths are prime numbers,
2100
+ the order of the words in the new string should be the same as the original one.
2101
+
2102
+ Example 1:
2103
+ Input: sentence = ""This is a test""
2104
+ Output: ""is""
2105
+
2106
+ Example 2:
2107
+ Input: sentence = ""lets go for swimming""
2108
+ Output: ""go for""
2109
+
2110
+ Constraints:
2111
+ * 1 <= len(sentence) <= 100
2112
+ * sentence contains only letters
2113
+ """"""
2114
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2115
+ "
2116
+ def simplify(x, n):
2117
+ """"""Your task is to implement a function that will simplify the expression
2118
+ x * n. The function returns True if x * n evaluates to a whole number and False
2119
+ otherwise. Both x and n, are string representation of a fraction, and have the following format,
2120
+ <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
2121
+
2122
+ You can assume that x, and n are valid fractions, and do not have zero as denominator.
2123
+
2124
+ simplify(""1/5"", ""5/1"") = True
2125
+ simplify(""1/6"", ""2/1"") = False
2126
+ simplify(""7/10"", ""10/2"") = False
2127
+ """"""
2128
+ ",0.050000000000000044,0.25,0.5
2129
+ "
2130
+ def order_by_points(nums):
2131
+ """"""
2132
+ Write a function which sorts the given list of integers
2133
+ in ascending order according to the sum of their digits.
2134
+ Note: if there are several items with similar sum of their digits,
2135
+ order them based on their index in original list.
2136
+
2137
+ For example:
2138
+ >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
2139
+ >>> order_by_points([]) == []
2140
+ """"""
2141
+ ",0.0,0.0,0.0
2142
+ "
2143
+ def specialFilter(nums):
2144
+ """"""Write a function that takes an array of numbers as input and returns
2145
+ the number of elements in the array that are greater than 10 and both
2146
+ first and last digits of a number are odd (1, 3, 5, 7, 9).
2147
+ For example:
2148
+ specialFilter([15, -73, 14, -15]) => 1
2149
+ specialFilter([33, -2, -3, 45, 21, 109]) => 2
2150
+ """"""
2151
+ ",0.25,0.8063080495356036,0.9837461300309598
2152
+ "
2153
+ def get_max_triples(n):
2154
+ """"""
2155
+ You are given a positive integer n. You have to create an integer array a of length n.
2156
+ For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
2157
+ Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
2158
+ and a[i] + a[j] + a[k] is a multiple of 3.
2159
+
2160
+ Example :
2161
+ Input: n = 5
2162
+ Output: 1
2163
+ Explanation:
2164
+ a = [1, 3, 7, 13, 21]
2165
+ The only valid triple is (1, 7, 13).
2166
+ """"""
2167
+ ",0.050000000000000044,0.25,0.5
2168
+ "
2169
+ def bf(planet1, planet2):
2170
+ '''
2171
+ There are eight planets in our solar system: the closerst to the Sun
2172
+ is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
2173
+ Uranus, Neptune.
2174
+ Write a function that takes two planet names as strings planet1 and planet2.
2175
+ The function should return a tuple containing all planets whose orbits are
2176
+ located between the orbit of planet1 and the orbit of planet2, sorted by
2177
+ the proximity to the sun.
2178
+ The function should return an empty tuple if planet1 or planet2
2179
+ are not correct planet names.
2180
+ Examples
2181
+ bf(""Jupiter"", ""Neptune"") ==> (""Saturn"", ""Uranus"")
2182
+ bf(""Earth"", ""Mercury"") ==> (""Venus"")
2183
+ bf(""Mercury"", ""Uranus"") ==> (""Venus"", ""Earth"", ""Mars"", ""Jupiter"", ""Saturn"")
2184
+ '''
2185
+ ",0.85,1.0,1.0
2186
+ "
2187
+ def sorted_list_sum(lst):
2188
+ """"""Write a function that accepts a list of strings as a parameter,
2189
+ deletes the strings that have odd lengths from it,
2190
+ and returns the resulted list with a sorted order,
2191
+ The list is always a list of strings and never an array of numbers,
2192
+ and it may contain duplicates.
2193
+ The order of the list should be ascending by length of each word, and you
2194
+ should return the list sorted by that rule.
2195
+ If two words have the same length, sort the list alphabetically.
2196
+ The function should return a list of strings in sorted order.
2197
+ You may assume that all words will have the same length.
2198
+ For example:
2199
+ assert list_sort([""aa"", ""a"", ""aaa""]) => [""aa""]
2200
+ assert list_sort([""ab"", ""a"", ""aaa"", ""cd""]) => [""ab"", ""cd""]
2201
+ """"""
2202
+ ",0.0,0.0,0.0
2203
+ "
2204
+ def x_or_y(n, x, y):
2205
+ """"""A simple program which should return the value of x if n is
2206
+ a prime number and should return the value of y otherwise.
2207
+
2208
+ Examples:
2209
+ for x_or_y(7, 34, 12) == 34
2210
+ for x_or_y(15, 8, 5) == 5
2211
+
2212
+ """"""
2213
+ ",0.0,0.0,0.0
2214
+ "
2215
+ def double_the_difference(lst):
2216
+ '''
2217
+ Given a list of numbers, return the sum of squares of the numbers
2218
+ in the list that are odd. Ignore numbers that are negative or not integers.
2219
+
2220
+ double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
2221
+ double_the_difference([-1, -2, 0]) == 0
2222
+ double_the_difference([9, -2]) == 81
2223
+ double_the_difference([0]) == 0
2224
+
2225
+ If the input list is empty, return 0.
2226
+ '''
2227
+ ",0.4,0.9489164086687306,0.9996427720885925
2228
+ "
2229
+ def compare(game,guess):
2230
+ """"""I think we all remember that feeling when the result of some long-awaited
2231
+ event is finally known. The feelings and thoughts you have at that moment are
2232
+ definitely worth noting down and comparing.
2233
+ Your task is to determine if a person correctly guessed the results of a number of matches.
2234
+ You are given two arrays of scores and guesses of equal length, where each index shows a match.
2235
+ Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
2236
+ the value is 0, and if not, the value is the absolute difference between the guess and the score.
2237
+
2238
+
2239
+ example:
2240
+
2241
+ compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
2242
+ compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
2243
+ """"""
2244
+ ",0.85,1.0,1.0
2245
+ "
2246
+ def Strongest_Extension(class_name, extensions):
2247
+ """"""You will be given the name of a class (a string) and a list of extensions.
2248
+ The extensions are to be used to load additional classes to the class. The
2249
+ strength of the extension is as follows: Let CAP be the number of the uppercase
2250
+ letters in the extension's name, and let SM be the number of lowercase letters
2251
+ in the extension's name, the strength is given by the fraction CAP - SM.
2252
+ You should find the strongest extension and return a string in this
2253
+ format: ClassName.StrongestExtensionName.
2254
+ If there are two or more extensions with the same strength, you should
2255
+ choose the one that comes first in the list.
2256
+ For example, if you are given ""Slices"" as the class and a list of the
2257
+ extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
2258
+ return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
2259
+ (its strength is -1).
2260
+ Example:
2261
+ for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
2262
+ """"""
2263
+ ",0.25,0.8063080495356036,0.9837461300309598
2264
+ "
2265
+ def cycpattern_check(a , b):
2266
+ """"""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
2267
+ cycpattern_check(""abcd"",""abd"") => False
2268
+ cycpattern_check(""hello"",""ell"") => True
2269
+ cycpattern_check(""whassup"",""psus"") => False
2270
+ cycpattern_check(""abab"",""baa"") => True
2271
+ cycpattern_check(""efef"",""eeff"") => False
2272
+ cycpattern_check(""himenss"",""simen"") => True
2273
+
2274
+ """"""
2275
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
2276
+ "
2277
+ def even_odd_count(num):
2278
+ """"""Given an integer. return a tuple that has the number of even and odd digits respectively.
2279
+
2280
+ Example:
2281
+ even_odd_count(-12) ==> (1, 1)
2282
+ even_odd_count(123) ==> (1, 2)
2283
+ """"""
2284
+ ",0.65,0.9986455108359134,1.0
2285
+ "
2286
+ def int_to_mini_roman(number):
2287
+ """"""
2288
+ Given a positive integer, obtain its roman numeral equivalent as a string,
2289
+ and return it in lowercase.
2290
+ Restrictions: 1 <= num <= 1000
2291
+
2292
+ Examples:
2293
+ >>> int_to_mini_roman(19) == 'xix'
2294
+ >>> int_to_mini_roman(152) == 'clii'
2295
+ >>> int_to_mini_roman(426) == 'cdxxvi'
2296
+ """"""
2297
+ ",0.6000000000000001,0.9963880288957688,1.0
2298
+ "
2299
+ def right_angle_triangle(a, b, c):
2300
+ '''
2301
+ Given the lengths of the three sides of a triangle. Return True if the three
2302
+ sides form a right-angled triangle, False otherwise.
2303
+ A right-angled triangle is a triangle in which one angle is right angle or
2304
+ 90 degree.
2305
+ Example:
2306
+ right_angle_triangle(3, 4, 5) == True
2307
+ right_angle_triangle(1, 2, 3) == False
2308
+ '''
2309
+ ",0.25,0.8063080495356036,0.9837461300309598
2310
+ "
2311
+ def find_max(words):
2312
+ """"""Write a function that accepts a list of strings.
2313
+ The list contains different words. Return the word with maximum number
2314
+ of unique characters. If multiple strings have maximum number of unique
2315
+ characters, return the one which comes first in lexicographical order.
2316
+
2317
+ find_max([""name"", ""of"", ""string""]) == ""string""
2318
+ find_max([""name"", ""enam"", ""game""]) == ""enam""
2319
+ find_max([""aaaaaaa"", ""bb"" ,""cc""]) == """"aaaaaaa""
2320
+ """"""
2321
+ ",0.7,0.9996130030959752,1.0
2322
+ "
2323
+ def eat(number, need, remaining):
2324
+ """"""
2325
+ You're a hungry rabbit, and you already have eaten a certain number of carrots,
2326
+ but now you need to eat more carrots to complete the day's meals.
2327
+ you should return an array of [ total number of eaten carrots after your meals,
2328
+ the number of carrots left after your meals ]
2329
+ if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
2330
+
2331
+ Example:
2332
+ * eat(5, 6, 10) -> [11, 4]
2333
+ * eat(4, 8, 9) -> [12, 1]
2334
+ * eat(1, 10, 10) -> [11, 0]
2335
+ * eat(2, 11, 5) -> [7, 0]
2336
+
2337
+ Variables:
2338
+ @number : integer
2339
+ the number of carrots that you have eaten.
2340
+ @need : integer
2341
+ the number of carrots that you need to eat.
2342
+ @remaining : integer
2343
+ the number of remaining carrots thet exist in stock
2344
+
2345
+ Constrain:
2346
+ * 0 <= number <= 1000
2347
+ * 0 <= need <= 1000
2348
+ * 0 <= remaining <= 1000
2349
+
2350
+ Have fun :)
2351
+ """"""
2352
+ ",0.050000000000000044,0.25,0.5
2353
+ "
2354
+ def do_algebra(operator, operand):
2355
+ """"""
2356
+ Given two lists operator, and operand. The first list has basic algebra operations, and
2357
+ the second list is a list of integers. Use the two given lists to build the algebric
2358
+ expression and return the evaluation of this expression.
2359
+
2360
+ The basic algebra operations:
2361
+ Addition ( + )
2362
+ Subtraction ( - )
2363
+ Multiplication ( * )
2364
+ Floor division ( // )
2365
+ Exponentiation ( ** )
2366
+
2367
+ Example:
2368
+ operator['+', '*', '-']
2369
+ array = [2, 3, 4, 5]
2370
+ result = 2 + 3 * 4 - 5
2371
+ => result = 9
2372
+
2373
+ Note:
2374
+ The length of operator list is equal to the length of operand list minus one.
2375
+ Operand is a list of of non-negative integers.
2376
+ Operator list has at least one operator, and operand list has at least two operands.
2377
+
2378
+ """"""
2379
+ ",0.0,0.0,0.0
2380
+ "
2381
+ def solve(s):
2382
+ """"""You are given a string s.
2383
+ if s[i] is a letter, reverse its case from lower to upper or vise versa,
2384
+ otherwise keep it as it is.
2385
+ If the string contains no letters, reverse the string.
2386
+ The function should return the resulted string.
2387
+ Examples
2388
+ solve(""1234"") = ""4321""
2389
+ solve(""ab"") = ""AB""
2390
+ solve(""#a@C"") = ""#A@c""
2391
+ """"""
2392
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2393
+ "
2394
+ def string_to_md5(text):
2395
+ """"""
2396
+ Given a string 'text', return its md5 hash equivalent string.
2397
+ If 'text' is an empty string, return None.
2398
+
2399
+ >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
2400
+ """"""
2401
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
2402
+ "
2403
+ def generate_integers(a, b):
2404
+ """"""
2405
+ Given two positive integers a and b, return the even digits between a
2406
+ and b, in ascending order.
2407
+
2408
+ For example:
2409
+ generate_integers(2, 8) => [2, 4, 6, 8]
2410
+ generate_integers(8, 2) => [2, 4, 6, 8]
2411
+ generate_integers(10, 14) => []
2412
+ """"""
2413
+ ",0.0,0.0,0.0
data/coding/humaneval/csv/5.csv ADDED
@@ -0,0 +1,2413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt,pass@1,pass@5,pass@10
2
+ "from typing import List
3
+
4
+
5
+ def has_close_elements(numbers: List[float], threshold: float) -> bool:
6
+ """""" Check if in given list of numbers, are any two numbers closer to each other than
7
+ given threshold.
8
+ >>> has_close_elements([1.0, 2.0, 3.0], 0.5)
9
+ False
10
+ >>> has_close_elements([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
11
+ True
12
+ """"""
13
+ ",0.5499999999999998,0.9918730650154799,1.0
14
+ "from typing import List
15
+
16
+
17
+ def separate_paren_groups(paren_string: str) -> List[str]:
18
+ """""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
19
+ separate those group into separate strings and return the list of those.
20
+ Separate groups are balanced (each open brace is properly closed) and not nested within each other
21
+ Ignore any spaces in the input string.
22
+ >>> separate_paren_groups('( ) (( )) (( )( ))')
23
+ ['()', '(())', '(()())']
24
+ """"""
25
+ ",0.0,0.0,0.0
26
+ "
27
+
28
+ def truncate_number(number: float) -> float:
29
+ """""" Given a positive floating point number, it can be decomposed into
30
+ and integer part (largest integer smaller than given number) and decimals
31
+ (leftover part always smaller than 1).
32
+
33
+ Return the decimal part of the number.
34
+ >>> truncate_number(3.5)
35
+ 0.5
36
+ """"""
37
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
38
+ "from typing import List
39
+
40
+
41
+ def below_zero(operations: List[int]) -> bool:
42
+ """""" You're given a list of deposit and withdrawal operations on a bank account that starts with
43
+ zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
44
+ at that point function should return True. Otherwise it should return False.
45
+ >>> below_zero([1, 2, 3])
46
+ False
47
+ >>> below_zero([1, 2, -4, 5])
48
+ True
49
+ """"""
50
+ ",1.0,1.0,1.0
51
+ "from typing import List
52
+
53
+
54
+ def mean_absolute_deviation(numbers: List[float]) -> float:
55
+ """""" For a given list of input numbers, calculate Mean Absolute Deviation
56
+ around the mean of this dataset.
57
+ Mean Absolute Deviation is the average absolute difference between each
58
+ element and a centerpoint (mean in this case):
59
+ MAD = average | x - x_mean |
60
+ >>> mean_absolute_deviation([1.0, 2.0, 3.0, 4.0])
61
+ 1.0
62
+ """"""
63
+ ",1.0,1.0,1.0
64
+ "from typing import List
65
+
66
+
67
+ def intersperse(numbers: List[int], delimeter: int) -> List[int]:
68
+ """""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
69
+ >>> intersperse([], 4)
70
+ []
71
+ >>> intersperse([1, 2, 3], 4)
72
+ [1, 4, 2, 4, 3]
73
+ """"""
74
+ ",0.0,0.0,0.0
75
+ "from typing import List
76
+
77
+
78
+ def parse_nested_parens(paren_string: str) -> List[int]:
79
+ """""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
80
+ For each of the group, output the deepest level of nesting of parentheses.
81
+ E.g. (()()) has maximum two levels of nesting while ((())) has three.
82
+
83
+ >>> parse_nested_parens('(()()) ((())) () ((())()())')
84
+ [2, 3, 1, 3]
85
+ """"""
86
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
87
+ "from typing import List
88
+
89
+
90
+ def filter_by_substring(strings: List[str], substring: str) -> List[str]:
91
+ """""" Filter an input list of strings only for ones that contain given substring
92
+ >>> filter_by_substring([], 'a')
93
+ []
94
+ >>> filter_by_substring(['abc', 'bacd', 'cde', 'array'], 'a')
95
+ ['abc', 'bacd', 'array']
96
+ """"""
97
+ ",0.95,1.0,1.0
98
+ "from typing import List, Tuple
99
+
100
+
101
+ def sum_product(numbers: List[int]) -> Tuple[int, int]:
102
+ """""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
103
+ Empty sum should be equal to 0 and empty product should be equal to 1.
104
+ >>> sum_product([])
105
+ (0, 1)
106
+ >>> sum_product([1, 2, 3, 4])
107
+ (10, 24)
108
+ """"""
109
+ ",1.0,1.0,1.0
110
+ "from typing import List, Tuple
111
+
112
+
113
+ def rolling_max(numbers: List[int]) -> List[int]:
114
+ """""" From a given list of integers, generate a list of rolling maximum element found until given moment
115
+ in the sequence.
116
+ >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
117
+ [1, 2, 3, 3, 3, 4, 4]
118
+ """"""
119
+ ",0.25,0.8063080495356036,0.9837461300309598
120
+ "
121
+
122
+ def is_palindrome(string: str) -> bool:
123
+ """""" Test if given string is a palindrome """"""
124
+ return string == string[::-1]
125
+
126
+
127
+ def make_palindrome(string: str) -> str:
128
+ """""" Find the shortest palindrome that begins with a supplied string.
129
+ Algorithm idea is simple:
130
+ - Find the longest postfix of supplied string that is a palindrome.
131
+ - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
132
+ >>> make_palindrome('')
133
+ ''
134
+ >>> make_palindrome('cat')
135
+ 'catac'
136
+ >>> make_palindrome('cata')
137
+ 'catac'
138
+ """"""
139
+ ",0.0,0.0,0.0
140
+ "from typing import List
141
+
142
+
143
+ def string_xor(a: str, b: str) -> str:
144
+ """""" Input are two strings a and b consisting only of 1s and 0s.
145
+ Perform binary XOR on these inputs and return result also as a string.
146
+ >>> string_xor('010', '110')
147
+ '100'
148
+ """"""
149
+ ",0.7,0.9996130030959752,1.0
150
+ "from typing import List, Optional
151
+
152
+
153
+ def longest(strings: List[str]) -> Optional[str]:
154
+ """""" Out of list of strings, return the longest one. Return the first one in case of multiple
155
+ strings of the same length. Return None in case the input list is empty.
156
+ >>> longest([])
157
+
158
+ >>> longest(['a', 'b', 'c'])
159
+ 'a'
160
+ >>> longest(['a', 'bb', 'ccc'])
161
+ 'ccc'
162
+ """"""
163
+ ",1.0,1.0,1.0
164
+ "
165
+
166
+ def greatest_common_divisor(a: int, b: int) -> int:
167
+ """""" Return a greatest common divisor of two integers a and b
168
+ >>> greatest_common_divisor(3, 5)
169
+ 1
170
+ >>> greatest_common_divisor(25, 15)
171
+ 5
172
+ """"""
173
+ ",0.65,0.9986455108359134,1.0
174
+ "from typing import List
175
+
176
+
177
+ def all_prefixes(string: str) -> List[str]:
178
+ """""" Return list of all prefixes from shortest to longest of the input string
179
+ >>> all_prefixes('abc')
180
+ ['a', 'ab', 'abc']
181
+ """"""
182
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
183
+ "
184
+
185
+ def string_sequence(n: int) -> str:
186
+ """""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
187
+ >>> string_sequence(0)
188
+ '0'
189
+ >>> string_sequence(5)
190
+ '0 1 2 3 4 5'
191
+ """"""
192
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
193
+ "
194
+
195
+ def count_distinct_characters(string: str) -> int:
196
+ """""" Given a string, find out how many distinct characters (regardless of case) does it consist of
197
+ >>> count_distinct_characters('xyzXYZ')
198
+ 3
199
+ >>> count_distinct_characters('Jerry')
200
+ 4
201
+ """"""
202
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
203
+ "from typing import List
204
+
205
+
206
+ def parse_music(music_string: str) -> List[int]:
207
+ """""" Input to this function is a string representing musical notes in a special ASCII format.
208
+ Your task is to parse this string and return list of integers corresponding to how many beats does each
209
+ not last.
210
+
211
+ Here is a legend:
212
+ 'o' - whole note, lasts four beats
213
+ 'o|' - half note, lasts two beats
214
+ '.|' - quater note, lasts one beat
215
+
216
+ >>> parse_music('o o| .| o| o| .| .| .| .| o o')
217
+ [4, 2, 1, 2, 2, 1, 1, 1, 1, 4, 4]
218
+ """"""
219
+ ",0.85,1.0,1.0
220
+ "
221
+
222
+ def how_many_times(string: str, substring: str) -> int:
223
+ """""" Find how many times a given substring can be found in the original string. Count overlaping cases.
224
+ >>> how_many_times('', 'a')
225
+ 0
226
+ >>> how_many_times('aaa', 'a')
227
+ 3
228
+ >>> how_many_times('aaaa', 'aa')
229
+ 3
230
+ """"""
231
+ ",0.7999999999999999,1.0,1.0
232
+ "from typing import List
233
+
234
+
235
+ def sort_numbers(numbers: str) -> str:
236
+ """""" Input is a space-delimited string of numberals from 'zero' to 'nine'.
237
+ Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
238
+ Return the string with numbers sorted from smallest to largest
239
+ >>> sort_numbers('three one five')
240
+ 'one three five'
241
+ """"""
242
+ ",0.0,0.0,0.0
243
+ "from typing import List, Tuple
244
+
245
+
246
+ def find_closest_elements(numbers: List[float]) -> Tuple[float, float]:
247
+ """""" From a supplied list of numbers (of length at least two) select and return two that are the closest to each
248
+ other and return them in order (smaller number, larger number).
249
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.2])
250
+ (2.0, 2.2)
251
+ >>> find_closest_elements([1.0, 2.0, 3.0, 4.0, 5.0, 2.0])
252
+ (2.0, 2.0)
253
+ """"""
254
+ ",0.7,0.9996130030959752,1.0
255
+ "from typing import List
256
+
257
+
258
+ def rescale_to_unit(numbers: List[float]) -> List[float]:
259
+ """""" Given list of numbers (of at least two elements), apply a linear transform to that list,
260
+ such that the smallest number will become 0 and the largest will become 1
261
+ >>> rescale_to_unit([1.0, 2.0, 3.0, 4.0, 5.0])
262
+ [0.0, 0.25, 0.5, 0.75, 1.0]
263
+ """"""
264
+ ",0.85,1.0,1.0
265
+ "from typing import List, Any
266
+
267
+
268
+ def filter_integers(values: List[Any]) -> List[int]:
269
+ """""" Filter given list of any python values only for integers
270
+ >>> filter_integers(['a', 3.14, 5])
271
+ [5]
272
+ >>> filter_integers([1, 2, 3, 'abc', {}, []])
273
+ [1, 2, 3]
274
+ """"""
275
+ ",0.6000000000000001,0.9963880288957688,1.0
276
+ "
277
+
278
+ def strlen(string: str) -> int:
279
+ """""" Return length of given string
280
+ >>> strlen('')
281
+ 0
282
+ >>> strlen('abc')
283
+ 3
284
+ """"""
285
+ ",0.85,1.0,1.0
286
+ "
287
+
288
+ def largest_divisor(n: int) -> int:
289
+ """""" For a given number n, find the largest number that divides n evenly, smaller than n
290
+ >>> largest_divisor(15)
291
+ 5
292
+ """"""
293
+ ",0.050000000000000044,0.25,0.5
294
+ "from typing import List
295
+
296
+
297
+ def factorize(n: int) -> List[int]:
298
+ """""" Return list of prime factors of given integer in the order from smallest to largest.
299
+ Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
300
+ Input number should be equal to the product of all factors
301
+ >>> factorize(8)
302
+ [2, 2, 2]
303
+ >>> factorize(25)
304
+ [5, 5]
305
+ >>> factorize(70)
306
+ [2, 5, 7]
307
+ """"""
308
+ ",1.0,1.0,1.0
309
+ "from typing import List
310
+
311
+
312
+ def remove_duplicates(numbers: List[int]) -> List[int]:
313
+ """""" From a list of integers, remove all elements that occur more than once.
314
+ Keep order of elements left the same as in the input.
315
+ >>> remove_duplicates([1, 2, 3, 2, 4])
316
+ [1, 3, 4]
317
+ """"""
318
+ ",0.0,0.0,0.0
319
+ "
320
+
321
+ def flip_case(string: str) -> str:
322
+ """""" For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
323
+ >>> flip_case('Hello')
324
+ 'hELLO'
325
+ """"""
326
+ ",1.0,1.0,1.0
327
+ "from typing import List
328
+
329
+
330
+ def concatenate(strings: List[str]) -> str:
331
+ """""" Concatenate list of strings into a single string
332
+ >>> concatenate([])
333
+ ''
334
+ >>> concatenate(['a', 'b', 'c'])
335
+ 'abc'
336
+ """"""
337
+ ",0.7999999999999999,1.0,1.0
338
+ "from typing import List
339
+
340
+
341
+ def filter_by_prefix(strings: List[str], prefix: str) -> List[str]:
342
+ """""" Filter an input list of strings only for ones that start with a given prefix.
343
+ >>> filter_by_prefix([], 'a')
344
+ []
345
+ >>> filter_by_prefix(['abc', 'bcd', 'cde', 'array'], 'a')
346
+ ['abc', 'array']
347
+ """"""
348
+ ",0.95,1.0,1.0
349
+ "
350
+
351
+ def get_positive(l: list):
352
+ """"""Return only positive numbers in the list.
353
+ >>> get_positive([-1, 2, -4, 5, 6])
354
+ [2, 5, 6]
355
+ >>> get_positive([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
356
+ [5, 3, 2, 3, 9, 123, 1]
357
+ """"""
358
+ ",0.7999999999999999,1.0,1.0
359
+ "
360
+
361
+ def is_prime(n):
362
+ """"""Return true if a given number is prime, and false otherwise.
363
+ >>> is_prime(6)
364
+ False
365
+ >>> is_prime(101)
366
+ True
367
+ >>> is_prime(11)
368
+ True
369
+ >>> is_prime(13441)
370
+ True
371
+ >>> is_prime(61)
372
+ True
373
+ >>> is_prime(4)
374
+ False
375
+ >>> is_prime(1)
376
+ False
377
+ """"""
378
+ ",0.8999999999999999,1.0,1.0
379
+ "import math
380
+
381
+
382
+ def poly(xs: list, x: float):
383
+ """"""
384
+ Evaluates polynomial with coefficients xs at point x.
385
+ return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n
386
+ """"""
387
+ return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])
388
+
389
+
390
+ def find_zero(xs: list):
391
+ """""" xs are coefficients of a polynomial.
392
+ find_zero find x such that poly(x) = 0.
393
+ find_zero returns only only zero point, even if there are many.
394
+ Moreover, find_zero only takes list xs having even number of coefficients
395
+ and largest non zero coefficient as it guarantees
396
+ a solution.
397
+ >>> round(find_zero([1, 2]), 2) # f(x) = 1 + 2x
398
+ -0.5
399
+ >>> round(find_zero([-6, 11, -6, 1]), 2) # (x - 1) * (x - 2) * (x - 3) = -6 + 11x - 6x^2 + x^3
400
+ 1.0
401
+ """"""
402
+ ",0.0,0.0,0.0
403
+ "
404
+
405
+ def sort_third(l: list):
406
+ """"""This function takes a list l and returns a list l' such that
407
+ 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
408
+ to the values of the corresponding indicies of l, but sorted.
409
+ >>> sort_third([1, 2, 3])
410
+ [1, 2, 3]
411
+ >>> sort_third([5, 6, 3, 4, 8, 9, 2])
412
+ [2, 6, 3, 4, 8, 9, 5]
413
+ """"""
414
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
415
+ "
416
+
417
+ def unique(l: list):
418
+ """"""Return sorted unique elements in a list
419
+ >>> unique([5, 3, 5, 2, 3, 3, 9, 0, 123])
420
+ [0, 2, 3, 5, 9, 123]
421
+ """"""
422
+ ",0.85,1.0,1.0
423
+ "
424
+
425
+ def max_element(l: list):
426
+ """"""Return maximum element in the list.
427
+ >>> max_element([1, 2, 3])
428
+ 3
429
+ >>> max_element([5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10])
430
+ 123
431
+ """"""
432
+ ",0.5499999999999998,0.9918730650154799,1.0
433
+ "
434
+
435
+ def fizz_buzz(n: int):
436
+ """"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
437
+ >>> fizz_buzz(50)
438
+ 0
439
+ >>> fizz_buzz(78)
440
+ 2
441
+ >>> fizz_buzz(79)
442
+ 3
443
+ """"""
444
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
445
+ "
446
+
447
+ def sort_even(l: list):
448
+ """"""This function takes a list l and returns a list l' such that
449
+ l' is identical to l in the odd indicies, while its values at the even indicies are equal
450
+ to the values of the even indicies of l, but sorted.
451
+ >>> sort_even([1, 2, 3])
452
+ [1, 2, 3]
453
+ >>> sort_even([5, 6, 3, 4])
454
+ [3, 6, 5, 4]
455
+ """"""
456
+ ",0.050000000000000044,0.25,0.5
457
+ "
458
+
459
+ def encode_cyclic(s: str):
460
+ """"""
461
+ returns encoded string by cycling groups of three characters.
462
+ """"""
463
+ # split string to groups. Each of length 3.
464
+ groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]
465
+ # cycle elements in each group. Unless group has fewer elements than 3.
466
+ groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]
467
+ return """".join(groups)
468
+
469
+
470
+ def decode_cyclic(s: str):
471
+ """"""
472
+ takes as input string encoded with encode_cyclic function. Returns decoded string.
473
+ """"""
474
+ ",0.0,0.0,0.0
475
+ "
476
+
477
+ def prime_fib(n: int):
478
+ """"""
479
+ prime_fib returns n-th number that is a Fibonacci number and it's also prime.
480
+ >>> prime_fib(1)
481
+ 2
482
+ >>> prime_fib(2)
483
+ 3
484
+ >>> prime_fib(3)
485
+ 5
486
+ >>> prime_fib(4)
487
+ 13
488
+ >>> prime_fib(5)
489
+ 89
490
+ """"""
491
+ ",0.050000000000000044,0.25,0.5
492
+ "
493
+
494
+ def triples_sum_to_zero(l: list):
495
+ """"""
496
+ triples_sum_to_zero takes a list of integers as an input.
497
+ it returns True if there are three distinct elements in the list that
498
+ sum to zero, and False otherwise.
499
+
500
+ >>> triples_sum_to_zero([1, 3, 5, 0])
501
+ False
502
+ >>> triples_sum_to_zero([1, 3, -2, 1])
503
+ True
504
+ >>> triples_sum_to_zero([1, 2, 3, 7])
505
+ False
506
+ >>> triples_sum_to_zero([2, 4, -5, 3, 9, 7])
507
+ True
508
+ >>> triples_sum_to_zero([1])
509
+ False
510
+ """"""
511
+ ",0.75,0.9999355005159959,1.0
512
+ "
513
+
514
+ def car_race_collision(n: int):
515
+ """"""
516
+ Imagine a road that's a perfectly straight infinitely long line.
517
+ n cars are driving left to right; simultaneously, a different set of n cars
518
+ are driving right to left. The two sets of cars start out being very far from
519
+ each other. All cars move in the same speed. Two cars are said to collide
520
+ when a car that's moving left to right hits a car that's moving right to left.
521
+ However, the cars are infinitely sturdy and strong; as a result, they continue moving
522
+ in their trajectory as if they did not collide.
523
+
524
+ This function outputs the number of such collisions.
525
+ """"""
526
+ ",0.0,0.0,0.0
527
+ "
528
+
529
+ def incr_list(l: list):
530
+ """"""Return list with elements incremented by 1.
531
+ >>> incr_list([1, 2, 3])
532
+ [2, 3, 4]
533
+ >>> incr_list([5, 3, 5, 2, 3, 3, 9, 0, 123])
534
+ [6, 4, 6, 3, 4, 4, 10, 1, 124]
535
+ """"""
536
+ ",0.6000000000000001,0.9963880288957688,1.0
537
+ "
538
+
539
+ def pairs_sum_to_zero(l):
540
+ """"""
541
+ pairs_sum_to_zero takes a list of integers as an input.
542
+ it returns True if there are two distinct elements in the list that
543
+ sum to zero, and False otherwise.
544
+ >>> pairs_sum_to_zero([1, 3, 5, 0])
545
+ False
546
+ >>> pairs_sum_to_zero([1, 3, -2, 1])
547
+ False
548
+ >>> pairs_sum_to_zero([1, 2, 3, 7])
549
+ False
550
+ >>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
551
+ True
552
+ >>> pairs_sum_to_zero([1])
553
+ False
554
+ """"""
555
+ ",0.95,1.0,1.0
556
+ "
557
+
558
+ def change_base(x: int, base: int):
559
+ """"""Change numerical base of input number x to base.
560
+ return string representation after the conversion.
561
+ base numbers are less than 10.
562
+ >>> change_base(8, 3)
563
+ '22'
564
+ >>> change_base(8, 2)
565
+ '1000'
566
+ >>> change_base(7, 2)
567
+ '111'
568
+ """"""
569
+ ",0.25,0.8063080495356036,0.9837461300309598
570
+ "
571
+
572
+ def triangle_area(a, h):
573
+ """"""Given length of a side and high return area for a triangle.
574
+ >>> triangle_area(5, 3)
575
+ 7.5
576
+ """"""
577
+ ",0.8999999999999999,1.0,1.0
578
+ "
579
+
580
+ def fib4(n: int):
581
+ """"""The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
582
+ fib4(0) -> 0
583
+ fib4(1) -> 0
584
+ fib4(2) -> 2
585
+ fib4(3) -> 0
586
+ fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
587
+ Please write a function to efficiently compute the n-th element of the fib4 number sequence. Do not use recursion.
588
+ >>> fib4(5)
589
+ 4
590
+ >>> fib4(6)
591
+ 8
592
+ >>> fib4(7)
593
+ 14
594
+ """"""
595
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
596
+ "
597
+
598
+ def median(l: list):
599
+ """"""Return median of elements in the list l.
600
+ >>> median([3, 1, 2, 4, 5])
601
+ 3
602
+ >>> median([-10, 4, 6, 1000, 10, 20])
603
+ 15.0
604
+ """"""
605
+ ",0.7,0.9996130030959752,1.0
606
+ "
607
+
608
+ def is_palindrome(text: str):
609
+ """"""
610
+ Checks if given string is a palindrome
611
+ >>> is_palindrome('')
612
+ True
613
+ >>> is_palindrome('aba')
614
+ True
615
+ >>> is_palindrome('aaaaa')
616
+ True
617
+ >>> is_palindrome('zbcd')
618
+ False
619
+ """"""
620
+ ",0.4,0.9489164086687306,0.9996427720885925
621
+ "
622
+
623
+ def modp(n: int, p: int):
624
+ """"""Return 2^n modulo p (be aware of numerics).
625
+ >>> modp(3, 5)
626
+ 3
627
+ >>> modp(1101, 101)
628
+ 2
629
+ >>> modp(0, 101)
630
+ 1
631
+ >>> modp(3, 11)
632
+ 8
633
+ >>> modp(100, 101)
634
+ 1
635
+ """"""
636
+ ",0.0,0.0,0.0
637
+ "
638
+
639
+ def encode_shift(s: str):
640
+ """"""
641
+ returns encoded string by shifting every character by 5 in the alphabet.
642
+ """"""
643
+ return """".join([chr(((ord(ch) + 5 - ord(""a"")) % 26) + ord(""a"")) for ch in s])
644
+
645
+
646
+ def decode_shift(s: str):
647
+ """"""
648
+ takes as input string encoded with encode_shift function. Returns decoded string.
649
+ """"""
650
+ ",1.0,1.0,1.0
651
+ "
652
+
653
+ def remove_vowels(text):
654
+ """"""
655
+ remove_vowels is a function that takes string and returns string without vowels.
656
+ >>> remove_vowels('')
657
+ ''
658
+ >>> remove_vowels(""abcdef\nghijklm"")
659
+ 'bcdf\nghjklm'
660
+ >>> remove_vowels('abcdef')
661
+ 'bcdf'
662
+ >>> remove_vowels('aaaaa')
663
+ ''
664
+ >>> remove_vowels('aaBAA')
665
+ 'B'
666
+ >>> remove_vowels('zbcd')
667
+ 'zbcd'
668
+ """"""
669
+ ",0.7999999999999999,1.0,1.0
670
+ "
671
+
672
+ def below_threshold(l: list, t: int):
673
+ """"""Return True if all numbers in the list l are below threshold t.
674
+ >>> below_threshold([1, 2, 4, 10], 100)
675
+ True
676
+ >>> below_threshold([1, 20, 4, 10], 5)
677
+ False
678
+ """"""
679
+ ",0.6000000000000001,0.9963880288957688,1.0
680
+ "
681
+
682
+ def add(x: int, y: int):
683
+ """"""Add two numbers x and y
684
+ >>> add(2, 3)
685
+ 5
686
+ >>> add(5, 7)
687
+ 12
688
+ """"""
689
+ ",0.65,0.9986455108359134,1.0
690
+ "
691
+
692
+ def same_chars(s0: str, s1: str):
693
+ """"""
694
+ Check if two words have the same characters.
695
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddeddabc')
696
+ True
697
+ >>> same_chars('abcd', 'dddddddabc')
698
+ True
699
+ >>> same_chars('dddddddabc', 'abcd')
700
+ True
701
+ >>> same_chars('eabcd', 'dddddddabc')
702
+ False
703
+ >>> same_chars('abcd', 'dddddddabce')
704
+ False
705
+ >>> same_chars('eabcdzzzz', 'dddzzzzzzzddddabc')
706
+ False
707
+ """"""
708
+ ",0.8999999999999999,1.0,1.0
709
+ "
710
+
711
+ def fib(n: int):
712
+ """"""Return n-th Fibonacci number.
713
+ >>> fib(10)
714
+ 55
715
+ >>> fib(1)
716
+ 1
717
+ >>> fib(8)
718
+ 21
719
+ """"""
720
+ ",0.65,0.9986455108359134,1.0
721
+ "
722
+
723
+ def correct_bracketing(brackets: str):
724
+ """""" brackets is a string of ""<"" and "">"".
725
+ return True if every opening bracket has a corresponding closing bracket.
726
+
727
+ >>> correct_bracketing(""<"")
728
+ False
729
+ >>> correct_bracketing(""<>"")
730
+ True
731
+ >>> correct_bracketing(""<<><>>"")
732
+ True
733
+ >>> correct_bracketing(""><<>"")
734
+ False
735
+ """"""
736
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
737
+ "
738
+
739
+ def monotonic(l: list):
740
+ """"""Return True is list elements are monotonically increasing or decreasing.
741
+ >>> monotonic([1, 2, 4, 20])
742
+ True
743
+ >>> monotonic([1, 20, 4, 10])
744
+ False
745
+ >>> monotonic([4, 1, 0, -10])
746
+ True
747
+ """"""
748
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
749
+ "
750
+
751
+ def common(l1: list, l2: list):
752
+ """"""Return sorted unique common elements for two lists.
753
+ >>> common([1, 4, 3, 34, 653, 2, 5], [5, 7, 1, 5, 9, 653, 121])
754
+ [1, 5, 653]
755
+ >>> common([5, 3, 2, 8], [3, 2])
756
+ [2, 3]
757
+
758
+ """"""
759
+ ",0.95,1.0,1.0
760
+ "
761
+
762
+ def largest_prime_factor(n: int):
763
+ """"""Return the largest prime factor of n. Assume n > 1 and is not a prime.
764
+ >>> largest_prime_factor(13195)
765
+ 29
766
+ >>> largest_prime_factor(2048)
767
+ 2
768
+ """"""
769
+ ",0.5499999999999998,0.9918730650154799,1.0
770
+ "
771
+
772
+ def sum_to_n(n: int):
773
+ """"""sum_to_n is a function that sums numbers from 1 to n.
774
+ >>> sum_to_n(30)
775
+ 465
776
+ >>> sum_to_n(100)
777
+ 5050
778
+ >>> sum_to_n(5)
779
+ 15
780
+ >>> sum_to_n(10)
781
+ 55
782
+ >>> sum_to_n(1)
783
+ 1
784
+ """"""
785
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
786
+ "
787
+
788
+ def correct_bracketing(brackets: str):
789
+ """""" brackets is a string of ""("" and "")"".
790
+ return True if every opening bracket has a corresponding closing bracket.
791
+
792
+ >>> correct_bracketing(""("")
793
+ False
794
+ >>> correct_bracketing(""()"")
795
+ True
796
+ >>> correct_bracketing(""(()())"")
797
+ True
798
+ >>> correct_bracketing("")(()"")
799
+ False
800
+ """"""
801
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
802
+ "
803
+
804
+ def derivative(xs: list):
805
+ """""" xs represent coefficients of a polynomial.
806
+ xs[0] + xs[1] * x + xs[2] * x^2 + ....
807
+ Return derivative of this polynomial in the same form.
808
+ >>> derivative([3, 1, 2, 4, 5])
809
+ [1, 4, 12, 20]
810
+ >>> derivative([1, 2, 3])
811
+ [2, 6]
812
+ """"""
813
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
814
+ "
815
+
816
+ def fibfib(n: int):
817
+ """"""The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
818
+ fibfib(0) == 0
819
+ fibfib(1) == 0
820
+ fibfib(2) == 1
821
+ fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
822
+ Please write a function to efficiently compute the n-th element of the fibfib number sequence.
823
+ >>> fibfib(1)
824
+ 0
825
+ >>> fibfib(5)
826
+ 4
827
+ >>> fibfib(8)
828
+ 24
829
+ """"""
830
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
831
+ "
832
+ FIX = """"""
833
+ Add more test cases.
834
+ """"""
835
+
836
+ def vowels_count(s):
837
+ """"""Write a function vowels_count which takes a string representing
838
+ a word as input and returns the number of vowels in the string.
839
+ Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
840
+ vowel, but only when it is at the end of the given word.
841
+
842
+ Example:
843
+ >>> vowels_count(""abcde"")
844
+ 2
845
+ >>> vowels_count(""ACEDY"")
846
+ 3
847
+ """"""
848
+ ",0.65,0.9986455108359134,1.0
849
+ "
850
+ def circular_shift(x, shift):
851
+ """"""Circular shift the digits of the integer x, shift the digits right by shift
852
+ and return the result as a string.
853
+ If shift > number of digits, return digits reversed.
854
+ >>> circular_shift(12, 1)
855
+ ""21""
856
+ >>> circular_shift(12, 2)
857
+ ""12""
858
+ """"""
859
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
860
+ "
861
+ def digitSum(s):
862
+ """"""Task
863
+ Write a function that takes a string as input and returns the sum of the upper characters only'
864
+ ASCII codes.
865
+
866
+ Examples:
867
+ digitSum("""") => 0
868
+ digitSum(""abAB"") => 131
869
+ digitSum(""abcCd"") => 67
870
+ digitSum(""helloE"") => 69
871
+ digitSum(""woArBld"") => 131
872
+ digitSum(""aAaaaXa"") => 153
873
+ """"""
874
+ ",0.5499999999999998,0.9918730650154799,1.0
875
+ "
876
+ def fruit_distribution(s,n):
877
+ """"""
878
+ In this task, you will be given a string that represents a number of apples and oranges
879
+ that are distributed in a basket of fruit this basket contains
880
+ apples, oranges, and mango fruits. Given the string that represents the total number of
881
+ the oranges and apples and an integer that represent the total number of the fruits
882
+ in the basket return the number of the mango fruits in the basket.
883
+ for examble:
884
+ fruit_distribution(""5 apples and 6 oranges"", 19) ->19 - 5 - 6 = 8
885
+ fruit_distribution(""0 apples and 1 oranges"",3) -> 3 - 0 - 1 = 2
886
+ fruit_distribution(""2 apples and 3 oranges"", 100) -> 100 - 2 - 3 = 95
887
+ fruit_distribution(""100 apples and 1 oranges"",120) -> 120 - 100 - 1 = 19
888
+ """"""
889
+ ",0.0,0.0,0.0
890
+ "
891
+ def pluck(arr):
892
+ """"""
893
+ ""Given an array representing a branch of a tree that has non-negative integer nodes
894
+ your task is to pluck one of the nodes and return it.
895
+ The plucked node should be the node with the smallest even value.
896
+ If multiple nodes with the same smallest even value are found return the node that has smallest index.
897
+
898
+ The plucked node should be returned in a list, [ smalest_value, its index ],
899
+ If there are no even values or the given array is empty, return [].
900
+
901
+ Example 1:
902
+ Input: [4,2,3]
903
+ Output: [2, 1]
904
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
905
+
906
+ Example 2:
907
+ Input: [1,2,3]
908
+ Output: [2, 1]
909
+ Explanation: 2 has the smallest even value, and 2 has the smallest index.
910
+
911
+ Example 3:
912
+ Input: []
913
+ Output: []
914
+
915
+ Example 4:
916
+ Input: [5, 0, 3, 0, 4, 2]
917
+ Output: [0, 1]
918
+ Explanation: 0 is the smallest value, but there are two zeros,
919
+ so we will choose the first zero, which has the smallest index.
920
+
921
+ Constraints:
922
+ * 1 <= nodes.length <= 10000
923
+ * 0 <= node.value
924
+ """"""
925
+ ",0.4,0.9489164086687306,0.9996427720885925
926
+ "
927
+ def search(lst):
928
+ '''
929
+ You are given a non-empty list of positive integers. Return the greatest integer that is greater than
930
+ zero, and has a frequency greater than or equal to the value of the integer itself.
931
+ The frequency of an integer is the number of times it appears in the list.
932
+ If no such a value exist, return -1.
933
+ Examples:
934
+ search([4, 1, 2, 2, 3, 1]) == 2
935
+ search([1, 2, 2, 3, 3, 3, 4, 4, 4]) == 3
936
+ search([5, 5, 4, 4, 4]) == -1
937
+ '''
938
+ ",0.0,0.0,0.0
939
+ "
940
+ def strange_sort_list(lst):
941
+ '''
942
+ Given list of integers, return list in strange order.
943
+ Strange sorting, is when you start with the minimum value,
944
+ then maximum of the remaining integers, then minimum and so on.
945
+
946
+ Examples:
947
+ strange_sort_list([1, 2, 3, 4]) == [1, 4, 2, 3]
948
+ strange_sort_list([5, 5, 5, 5]) == [5, 5, 5, 5]
949
+ strange_sort_list([]) == []
950
+ '''
951
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
952
+ "
953
+ def triangle_area(a, b, c):
954
+ '''
955
+ Given the lengths of the three sides of a triangle. Return the area of
956
+ the triangle rounded to 2 decimal points if the three sides form a valid triangle.
957
+ Otherwise return -1
958
+ Three sides make a valid triangle when the sum of any two sides is greater
959
+ than the third side.
960
+ Example:
961
+ triangle_area(3, 4, 5) == 6.00
962
+ triangle_area(1, 2, 10) == -1
963
+ '''
964
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
965
+ "
966
+ def will_it_fly(q,w):
967
+ '''
968
+ Write a function that returns True if the object q will fly, and False otherwise.
969
+ 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.
970
+
971
+ Example:
972
+ will_it_fly([1, 2], 5) ➞ False
973
+ # 1+2 is less than the maximum possible weight, but it's unbalanced.
974
+
975
+ will_it_fly([3, 2, 3], 1) ➞ False
976
+ # it's balanced, but 3+2+3 is more than the maximum possible weight.
977
+
978
+ will_it_fly([3, 2, 3], 9) ➞ True
979
+ # 3+2+3 is less than the maximum possible weight, and it's balanced.
980
+
981
+ will_it_fly([3], 5) ➞ True
982
+ # 3 is less than the maximum possible weight, and it's balanced.
983
+ '''
984
+ ",0.7,0.9996130030959752,1.0
985
+ "
986
+ def smallest_change(arr):
987
+ """"""
988
+ Given an array arr of integers, find the minimum number of elements that
989
+ need to be changed to make the array palindromic. A palindromic array is an array that
990
+ is read the same backwards and forwards. In one change, you can change one element to any other element.
991
+
992
+ For example:
993
+ smallest_change([1,2,3,5,4,7,9,6]) == 4
994
+ smallest_change([1, 2, 3, 4, 3, 2, 2]) == 1
995
+ smallest_change([1, 2, 3, 2, 1]) == 0
996
+ """"""
997
+ ",0.0,0.0,0.0
998
+ "
999
+ def total_match(lst1, lst2):
1000
+ '''
1001
+ Write a function that accepts two lists of strings and returns the list that has
1002
+ total number of chars in the all strings of the list less than the other list.
1003
+
1004
+ if the two lists have the same number of chars, return the first list.
1005
+
1006
+ Examples
1007
+ total_match([], []) ➞ []
1008
+ total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
1009
+ total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
1010
+ total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
1011
+ total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
1012
+ '''
1013
+ ",0.0,0.0,0.0
1014
+ "
1015
+ def is_multiply_prime(a):
1016
+ """"""Write a function that returns true if the given number is the multiplication of 3 prime numbers
1017
+ and false otherwise.
1018
+ Knowing that (a) is less then 100.
1019
+ Example:
1020
+ is_multiply_prime(30) == True
1021
+ 30 = 2 * 3 * 5
1022
+ """"""
1023
+ ",0.0,0.0,0.0
1024
+ "
1025
+ def is_simple_power(x, n):
1026
+ """"""Your task is to write a function that returns true if a number x is a simple
1027
+ power of n and false in other cases.
1028
+ x is a simple power of n if n**int=x
1029
+ For example:
1030
+ is_simple_power(1, 4) => true
1031
+ is_simple_power(2, 2) => true
1032
+ is_simple_power(8, 2) => true
1033
+ is_simple_power(3, 2) => false
1034
+ is_simple_power(3, 1) => false
1035
+ is_simple_power(5, 3) => false
1036
+ """"""
1037
+ ",0.050000000000000044,0.25,0.5
1038
+ "
1039
+ def iscube(a):
1040
+ '''
1041
+ Write a function that takes an integer a and returns True
1042
+ if this ingeger is a cube of some integer number.
1043
+ Note: you may assume the input is always valid.
1044
+ Examples:
1045
+ iscube(1) ==> True
1046
+ iscube(2) ==> False
1047
+ iscube(-1) ==> True
1048
+ iscube(64) ==> True
1049
+ iscube(0) ==> True
1050
+ iscube(180) ==> False
1051
+ '''
1052
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1053
+ "
1054
+ def hex_key(num):
1055
+ """"""You have been tasked to write a function that receives
1056
+ a hexadecimal number as a string and counts the number of hexadecimal
1057
+ digits that are primes (prime number, or a prime, is a natural number
1058
+ greater than 1 that is not a product of two smaller natural numbers).
1059
+ Hexadecimal digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
1060
+ Prime numbers are 2, 3, 5, 7, 11, 13, 17,...
1061
+ So you have to determine a number of the following digits: 2, 3, 5, 7,
1062
+ B (=decimal 11), D (=decimal 13).
1063
+ Note: you may assume the input is always correct or empty string,
1064
+ and symbols A,B,C,D,E,F are always uppercase.
1065
+ Examples:
1066
+ For num = ""AB"" the output should be 1.
1067
+ For num = ""1077E"" the output should be 2.
1068
+ For num = ""ABED1A33"" the output should be 4.
1069
+ For num = ""123456789ABCDEF0"" the output should be 6.
1070
+ For num = ""2020"" the output should be 2.
1071
+ """"""
1072
+ ",0.4,0.9489164086687306,0.9996427720885925
1073
+ "
1074
+ def decimal_to_binary(decimal):
1075
+ """"""You will be given a number in decimal form and your task is to convert it to
1076
+ binary format. The function should return a string, with each character representing a binary
1077
+ number. Each character in the string will be '0' or '1'.
1078
+
1079
+ There will be an extra couple of characters 'db' at the beginning and at the end of the string.
1080
+ The extra characters are there to help with the format.
1081
+
1082
+ Examples:
1083
+ decimal_to_binary(15) # returns ""db1111db""
1084
+ decimal_to_binary(32) # returns ""db100000db""
1085
+ """"""
1086
+ ",0.7,0.9996130030959752,1.0
1087
+ "
1088
+ def is_happy(s):
1089
+ """"""You are given a string s.
1090
+ Your task is to check if the string is happy or not.
1091
+ A string is happy if its length is at least 3 and every 3 consecutive letters are distinct
1092
+ For example:
1093
+ is_happy(a) => False
1094
+ is_happy(aa) => False
1095
+ is_happy(abcd) => True
1096
+ is_happy(aabb) => False
1097
+ is_happy(adb) => True
1098
+ is_happy(xyy) => False
1099
+ """"""
1100
+ ",0.20000000000000007,0.7182662538699691,0.956656346749226
1101
+ "
1102
+ def numerical_letter_grade(grades):
1103
+ """"""It is the last week of the semester and the teacher has to give the grades
1104
+ to students. The teacher has been making her own algorithm for grading.
1105
+ The only problem is, she has lost the code she used for grading.
1106
+ She has given you a list of GPAs for some students and you have to write
1107
+ a function that can output a list of letter grades using the following table:
1108
+ GPA | Letter grade
1109
+ 4.0 A+
1110
+ > 3.7 A
1111
+ > 3.3 A-
1112
+ > 3.0 B+
1113
+ > 2.7 B
1114
+ > 2.3 B-
1115
+ > 2.0 C+
1116
+ > 1.7 C
1117
+ > 1.3 C-
1118
+ > 1.0 D+
1119
+ > 0.7 D
1120
+ > 0.0 D-
1121
+ 0.0 E
1122
+
1123
+
1124
+ Example:
1125
+ grade_equation([4.0, 3, 1.7, 2, 3.5]) ==> ['A+', 'B', 'C-', 'C', 'A-']
1126
+ """"""
1127
+ ",0.25,0.8063080495356036,0.9837461300309598
1128
+ "
1129
+ def prime_length(string):
1130
+ """"""Write a function that takes a string and returns True if the string
1131
+ length is a prime number or False otherwise
1132
+ Examples
1133
+ prime_length('Hello') == True
1134
+ prime_length('abcdcba') == True
1135
+ prime_length('kittens') == True
1136
+ prime_length('orange') == False
1137
+ """"""
1138
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1139
+ "
1140
+ def starts_one_ends(n):
1141
+ """"""
1142
+ Given a positive integer n, return the count of the numbers of n-digit
1143
+ positive integers that start or end with 1.
1144
+ """"""
1145
+ ",0.0,0.0,0.0
1146
+ "
1147
+ def solve(N):
1148
+ """"""Given a positive integer N, return the total sum of its digits in binary.
1149
+
1150
+ Example
1151
+ For N = 1000, the sum of digits will be 1 the output should be ""1"".
1152
+ For N = 150, the sum of digits will be 6 the output should be ""110"".
1153
+ For N = 147, the sum of digits will be 12 the output should be ""1100"".
1154
+
1155
+ Variables:
1156
+ @N integer
1157
+ Constraints: 0 ≤ N ≤ 10000.
1158
+ Output:
1159
+ a string of binary number
1160
+ """"""
1161
+ ",0.0,0.0,0.0
1162
+ "
1163
+ def add(lst):
1164
+ """"""Given a non-empty list of integers lst. add the even elements that are at odd indices..
1165
+
1166
+
1167
+ Examples:
1168
+ add([4, 2, 6, 7]) ==> 2
1169
+ """"""
1170
+ ",0.5499999999999998,0.9918730650154799,1.0
1171
+ "
1172
+ def anti_shuffle(s):
1173
+ """"""
1174
+ Write a function that takes a string and returns an ordered version of it.
1175
+ Ordered version of string, is a string where all words (separated by space)
1176
+ are replaced by a new word where all the characters arranged in
1177
+ ascending order based on ascii value.
1178
+ Note: You should keep the order of words and blank spaces in the sentence.
1179
+
1180
+ For example:
1181
+ anti_shuffle('Hi') returns 'Hi'
1182
+ anti_shuffle('hello') returns 'ehllo'
1183
+ anti_shuffle('Hello World!!!') returns 'Hello !!!Wdlor'
1184
+ """"""
1185
+ ",0.4,0.9489164086687306,0.9996427720885925
1186
+ "
1187
+ def get_row(lst, x):
1188
+ """"""
1189
+ You are given a 2 dimensional data, as a nested lists,
1190
+ which is similar to matrix, however, unlike matrices,
1191
+ each row may contain a different number of columns.
1192
+ Given lst, and integer x, find integers x in the list,
1193
+ and return list of tuples, [(x1, y1), (x2, y2) ...] such that
1194
+ each tuple is a coordinate - (row, columns), starting with 0.
1195
+ Sort coordinates initially by rows in ascending order.
1196
+ Also, sort coordinates of the row by columns in descending order.
1197
+
1198
+ Examples:
1199
+ get_row([
1200
+ [1,2,3,4,5,6],
1201
+ [1,2,3,4,1,6],
1202
+ [1,2,3,4,5,1]
1203
+ ], 1) == [(0, 0), (1, 4), (1, 0), (2, 5), (2, 0)]
1204
+ get_row([], 1) == []
1205
+ get_row([[], [1], [1, 2, 3]], 3) == [(2, 2)]
1206
+ """"""
1207
+ ",0.0,0.0,0.0
1208
+ "
1209
+ def sort_array(array):
1210
+ """"""
1211
+ Given an array of non-negative integers, return a copy of the given array after sorting,
1212
+ you will sort the given array in ascending order if the sum( first index value, last index value) is odd,
1213
+ or sort it in descending order if the sum( first index value, last index value) is even.
1214
+
1215
+ Note:
1216
+ * don't change the given array.
1217
+
1218
+ Examples:
1219
+ * sort_array([]) => []
1220
+ * sort_array([5]) => [5]
1221
+ * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]
1222
+ * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]
1223
+ """"""
1224
+ ",0.050000000000000044,0.25,0.5
1225
+ "
1226
+ def encrypt(s):
1227
+ """"""Create a function encrypt that takes a string as an argument and
1228
+ returns a string encrypted with the alphabet being rotated.
1229
+ The alphabet should be rotated in a manner such that the letters
1230
+ shift down by two multiplied to two places.
1231
+ For example:
1232
+ encrypt('hi') returns 'lm'
1233
+ encrypt('asdfghjkl') returns 'ewhjklnop'
1234
+ encrypt('gf') returns 'kj'
1235
+ encrypt('et') returns 'ix'
1236
+ """"""
1237
+ ",0.0,0.0,0.0
1238
+ "
1239
+ def next_smallest(lst):
1240
+ """"""
1241
+ You are given a list of integers.
1242
+ Write a function next_smallest() that returns the 2nd smallest element of the list.
1243
+ Return None if there is no such element.
1244
+
1245
+ next_smallest([1, 2, 3, 4, 5]) == 2
1246
+ next_smallest([5, 1, 4, 3, 2]) == 2
1247
+ next_smallest([]) == None
1248
+ next_smallest([1, 1]) == None
1249
+ """"""
1250
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1251
+ "
1252
+ def is_bored(S):
1253
+ """"""
1254
+ You'll be given a string of words, and your task is to count the number
1255
+ of boredoms. A boredom is a sentence that starts with the word ""I"".
1256
+ Sentences are delimited by '.', '?' or '!'.
1257
+
1258
+ For example:
1259
+ >>> is_bored(""Hello world"")
1260
+ 0
1261
+ >>> is_bored(""The sky is blue. The sun is shining. I love this weather"")
1262
+ 1
1263
+ """"""
1264
+ ",0.0,0.0,0.0
1265
+ "
1266
+ def any_int(x, y, z):
1267
+ '''
1268
+ Create a function that takes 3 numbers.
1269
+ Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
1270
+ Returns false in any other cases.
1271
+
1272
+ Examples
1273
+ any_int(5, 2, 7) ➞ True
1274
+
1275
+ any_int(3, 2, 2) ➞ False
1276
+
1277
+ any_int(3, -2, 1) ➞ True
1278
+
1279
+ any_int(3.6, -2.2, 2) ➞ False
1280
+
1281
+
1282
+
1283
+ '''
1284
+ ",0.6000000000000001,0.9963880288957688,1.0
1285
+ "
1286
+ def encode(message):
1287
+ """"""
1288
+ Write a function that takes a message, and encodes in such a
1289
+ way that it swaps case of all letters, replaces all vowels in
1290
+ the message with the letter that appears 2 places ahead of that
1291
+ vowel in the english alphabet.
1292
+ Assume only letters.
1293
+
1294
+ Examples:
1295
+ >>> encode('test')
1296
+ 'TGST'
1297
+ >>> encode('This is a message')
1298
+ 'tHKS KS C MGSSCGG'
1299
+ """"""
1300
+ ",0.0,0.0,0.0
1301
+ "
1302
+
1303
+ def skjkasdkd(lst):
1304
+ """"""You are given a list of integers.
1305
+ You need to find the largest prime value and return the sum of its digits.
1306
+
1307
+ Examples:
1308
+ For lst = [0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3] the output should be 10
1309
+ For lst = [1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1] the output should be 25
1310
+ For lst = [1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3] the output should be 13
1311
+ For lst = [0,724,32,71,99,32,6,0,5,91,83,0,5,6] the output should be 11
1312
+ For lst = [0,81,12,3,1,21] the output should be 3
1313
+ For lst = [0,8,1,2,1,7] the output should be 7
1314
+ """"""
1315
+ ",0.4,0.9489164086687306,0.9996427720885925
1316
+ "
1317
+ def check_dict_case(dict):
1318
+ """"""
1319
+ Given a dictionary, return True if all keys are strings in lower
1320
+ case or all keys are strings in upper case, else return False.
1321
+ The function should return False is the given dictionary is empty.
1322
+ Examples:
1323
+ check_dict_case({""a"":""apple"", ""b"":""banana""}) should return True.
1324
+ check_dict_case({""a"":""apple"", ""A"":""banana"", ""B"":""banana""}) should return False.
1325
+ check_dict_case({""a"":""apple"", 8:""banana"", ""a"":""apple""}) should return False.
1326
+ check_dict_case({""Name"":""John"", ""Age"":""36"", ""City"":""Houston""}) should return False.
1327
+ check_dict_case({""STATE"":""NC"", ""ZIP"":""12345"" }) should return True.
1328
+ """"""
1329
+ ",0.050000000000000044,0.25,0.5
1330
+ "
1331
+ def count_up_to(n):
1332
+ """"""Implement a function that takes an non-negative integer and returns an array of the first n
1333
+ integers that are prime numbers and less than n.
1334
+ for example:
1335
+ count_up_to(5) => [2,3]
1336
+ count_up_to(11) => [2,3,5,7]
1337
+ count_up_to(0) => []
1338
+ count_up_to(20) => [2,3,5,7,11,13,17,19]
1339
+ count_up_to(1) => []
1340
+ count_up_to(18) => [2,3,5,7,11,13,17]
1341
+ """"""
1342
+ ",0.6000000000000001,0.9963880288957688,1.0
1343
+ "
1344
+ def multiply(a, b):
1345
+ """"""Complete the function that takes two integers and returns
1346
+ the product of their unit digits.
1347
+ Assume the input is always valid.
1348
+ Examples:
1349
+ multiply(148, 412) should return 16.
1350
+ multiply(19, 28) should return 72.
1351
+ multiply(2020, 1851) should return 0.
1352
+ multiply(14,-15) should return 20.
1353
+ """"""
1354
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1355
+ "
1356
+ def count_upper(s):
1357
+ """"""
1358
+ Given a string s, count the number of uppercase vowels in even indices.
1359
+
1360
+ For example:
1361
+ count_upper('aBCdEf') returns 1
1362
+ count_upper('abcdefg') returns 0
1363
+ count_upper('dBBE') returns 0
1364
+ """"""
1365
+ ",0.25,0.8063080495356036,0.9837461300309598
1366
+ "
1367
+ def closest_integer(value):
1368
+ '''
1369
+ Create a function that takes a value (string) representing a number
1370
+ and returns the closest integer to it. If the number is equidistant
1371
+ from two integers, round it away from zero.
1372
+
1373
+ Examples
1374
+ >>> closest_integer(""10"")
1375
+ 10
1376
+ >>> closest_integer(""15.3"")
1377
+ 15
1378
+
1379
+ Note:
1380
+ Rounding away from zero means that if the given number is equidistant
1381
+ from two integers, the one you should return is the one that is the
1382
+ farthest from zero. For example closest_integer(""14.5"") should
1383
+ return 15 and closest_integer(""-14.5"") should return -15.
1384
+ '''
1385
+ ",0.050000000000000044,0.25,0.5
1386
+ "
1387
+ def make_a_pile(n):
1388
+ """"""
1389
+ Given a positive integer n, you have to make a pile of n levels of stones.
1390
+ The first level has n stones.
1391
+ The number of stones in the next level is:
1392
+ - the next odd number if n is odd.
1393
+ - the next even number if n is even.
1394
+ Return the number of stones in each level in a list, where element at index
1395
+ i represents the number of stones in the level (i+1).
1396
+
1397
+ Examples:
1398
+ >>> make_a_pile(3)
1399
+ [3, 5, 7]
1400
+ """"""
1401
+ ",0.0,0.0,0.0
1402
+ "
1403
+ def words_string(s):
1404
+ """"""
1405
+ You will be given a string of words separated by commas or spaces. Your task is
1406
+ to split the string into words and return an array of the words.
1407
+
1408
+ For example:
1409
+ words_string(""Hi, my name is John"") == [""Hi"", ""my"", ""name"", ""is"", ""John""]
1410
+ words_string(""One, two, three, four, five, six"") == [""One"", ""two"", ""three"", ""four"", ""five"", ""six""]
1411
+ """"""
1412
+ ",0.0,0.0,0.0
1413
+ "
1414
+ def choose_num(x, y):
1415
+ """"""This function takes two positive numbers x and y and returns the
1416
+ biggest even integer number that is in the range [x, y] inclusive. If
1417
+ there's no such number, then the function should return -1.
1418
+
1419
+ For example:
1420
+ choose_num(12, 15) = 14
1421
+ choose_num(13, 12) = -1
1422
+ """"""
1423
+ ",0.050000000000000044,0.25,0.5
1424
+ "
1425
+ def rounded_avg(n, m):
1426
+ """"""You are given two positive integers n and m, and your task is to compute the
1427
+ average of the integers from n through m (including n and m).
1428
+ Round the answer to the nearest integer and convert that to binary.
1429
+ If n is greater than m, return -1.
1430
+ Example:
1431
+ rounded_avg(1, 5) => ""0b11""
1432
+ rounded_avg(7, 5) => -1
1433
+ rounded_avg(10, 20) => ""0b1111""
1434
+ rounded_avg(20, 33) => ""0b11010""
1435
+ """"""
1436
+ ",0.0,0.0,0.0
1437
+ "
1438
+ def unique_digits(x):
1439
+ """"""Given a list of positive integers x. return a sorted list of all
1440
+ elements that hasn't any even digit.
1441
+
1442
+ Note: Returned list should be sorted in increasing order.
1443
+
1444
+ For example:
1445
+ >>> unique_digits([15, 33, 1422, 1])
1446
+ [1, 15, 33]
1447
+ >>> unique_digits([152, 323, 1422, 10])
1448
+ []
1449
+ """"""
1450
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
1451
+ "
1452
+ def by_length(arr):
1453
+ """"""
1454
+ Given an array of integers, sort the integers that are between 1 and 9 inclusive,
1455
+ reverse the resulting array, and then replace each digit by its corresponding name from
1456
+ ""One"", ""Two"", ""Three"", ""Four"", ""Five"", ""Six"", ""Seven"", ""Eight"", ""Nine"".
1457
+
1458
+ For example:
1459
+ arr = [2, 1, 1, 4, 5, 8, 2, 3]
1460
+ -> sort arr -> [1, 1, 2, 2, 3, 4, 5, 8]
1461
+ -> reverse arr -> [8, 5, 4, 3, 2, 2, 1, 1]
1462
+ return [""Eight"", ""Five"", ""Four"", ""Three"", ""Two"", ""Two"", ""One"", ""One""]
1463
+
1464
+ If the array is empty, return an empty array:
1465
+ arr = []
1466
+ return []
1467
+
1468
+ If the array has any strange number ignore it:
1469
+ arr = [1, -1 , 55]
1470
+ -> sort arr -> [-1, 1, 55]
1471
+ -> reverse arr -> [55, 1, -1]
1472
+ return = ['One']
1473
+ """"""
1474
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1475
+ "
1476
+ def f(n):
1477
+ """""" Implement the function f that takes n as a parameter,
1478
+ 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
1479
+ or the sum of numbers from 1 to i otherwise.
1480
+ i starts from 1.
1481
+ the factorial of i is the multiplication of the numbers from 1 to i (1 * 2 * ... * i).
1482
+ Example:
1483
+ f(5) == [1, 2, 6, 24, 15]
1484
+ """"""
1485
+ ",0.0,0.0,0.0
1486
+ "
1487
+ def even_odd_palindrome(n):
1488
+ """"""
1489
+ Given a positive integer n, return a tuple that has the number of even and odd
1490
+ integer palindromes that fall within the range(1, n), inclusive.
1491
+
1492
+ Example 1:
1493
+
1494
+ Input: 3
1495
+ Output: (1, 2)
1496
+ Explanation:
1497
+ Integer palindrome are 1, 2, 3. one of them is even, and two of them are odd.
1498
+
1499
+ Example 2:
1500
+
1501
+ Input: 12
1502
+ Output: (4, 6)
1503
+ Explanation:
1504
+ Integer palindrome are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11. four of them are even, and 6 of them are odd.
1505
+
1506
+ Note:
1507
+ 1. 1 <= n <= 10^3
1508
+ 2. returned tuple has the number of even and odd integer palindromes respectively.
1509
+ """"""
1510
+ ",0.95,1.0,1.0
1511
+ "
1512
+ def count_nums(arr):
1513
+ """"""
1514
+ Write a function count_nums which takes an array of integers and returns
1515
+ the number of elements which has a sum of digits > 0.
1516
+ If a number is negative, then its first signed digit will be negative:
1517
+ e.g. -123 has signed digits -1, 2, and 3.
1518
+ >>> count_nums([]) == 0
1519
+ >>> count_nums([-1, 11, -11]) == 1
1520
+ >>> count_nums([1, 1, 2]) == 3
1521
+ """"""
1522
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1523
+ "
1524
+ def move_one_ball(arr):
1525
+ """"""We have an array 'arr' of N integers arr[1], arr[2], ..., arr[N].The
1526
+ numbers in the array will be randomly ordered. Your task is to determine if
1527
+ it is possible to get an array sorted in non-decreasing order by performing
1528
+ the following operation on the given array:
1529
+ You are allowed to perform right shift operation any number of times.
1530
+
1531
+ One right shift operation means shifting all elements of the array by one
1532
+ position in the right direction. The last element of the array will be moved to
1533
+ the starting position in the array i.e. 0th index.
1534
+
1535
+ If it is possible to obtain the sorted array by performing the above operation
1536
+ then return True else return False.
1537
+ If the given array is empty then return True.
1538
+
1539
+ Note: The given list is guaranteed to have unique elements.
1540
+
1541
+ For Example:
1542
+
1543
+ move_one_ball([3, 4, 5, 1, 2])==>True
1544
+ Explanation: By performin 2 right shift operations, non-decreasing order can
1545
+ be achieved for the given array.
1546
+ move_one_ball([3, 5, 4, 1, 2])==>False
1547
+ Explanation:It is not possible to get non-decreasing order for the given
1548
+ array by performing any number of right shift operations.
1549
+
1550
+ """"""
1551
+ ",0.0,0.0,0.0
1552
+ "
1553
+ def exchange(lst1, lst2):
1554
+ """"""In this problem, you will implement a function that takes two lists of numbers,
1555
+ and determines whether it is possible to perform an exchange of elements
1556
+ between them to make lst1 a list of only even numbers.
1557
+ There is no limit on the number of exchanged elements between lst1 and lst2.
1558
+ If it is possible to exchange elements between the lst1 and lst2 to make
1559
+ all the elements of lst1 to be even, return ""YES"".
1560
+ Otherwise, return ""NO"".
1561
+ For example:
1562
+ exchange([1, 2, 3, 4], [1, 2, 3, 4]) => ""YES""
1563
+ exchange([1, 2, 3, 4], [1, 5, 3, 4]) => ""NO""
1564
+ It is assumed that the input lists will be non-empty.
1565
+ """"""
1566
+ ",0.0,0.0,0.0
1567
+ "
1568
+ def histogram(test):
1569
+ """"""Given a string representing a space separated lowercase letters, return a dictionary
1570
+ of the letter with the most repetition and containing the corresponding count.
1571
+ If several letters have the same occurrence, return all of them.
1572
+
1573
+ Example:
1574
+ histogram('a b c') == {'a': 1, 'b': 1, 'c': 1}
1575
+ histogram('a b b a') == {'a': 2, 'b': 2}
1576
+ histogram('a b c a b') == {'a': 2, 'b': 2}
1577
+ histogram('b b b b a') == {'b': 4}
1578
+ histogram('') == {}
1579
+
1580
+ """"""
1581
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1582
+ "
1583
+ def reverse_delete(s,c):
1584
+ """"""Task
1585
+ 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
1586
+ then check if the result string is palindrome.
1587
+ A string is called palindrome if it reads the same backward as forward.
1588
+ You should return a tuple containing the result string and True/False for the check.
1589
+ Example
1590
+ For s = ""abcde"", c = ""ae"", the result should be ('bcd',False)
1591
+ For s = ""abcdef"", c = ""b"" the result should be ('acdef',False)
1592
+ For s = ""abcdedcba"", c = ""ab"", the result should be ('cdedc',True)
1593
+ """"""
1594
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
1595
+ "
1596
+ def odd_count(lst):
1597
+ """"""Given a list of strings, where each string consists of only digits, return a list.
1598
+ Each element i of the output should be ""the number of odd elements in the
1599
+ string i of the input."" where all the i's should be replaced by the number
1600
+ of odd digits in the i'th string of the input.
1601
+
1602
+ >>> odd_count(['1234567'])
1603
+ [""the number of odd elements 4n the str4ng 4 of the 4nput.""]
1604
+ >>> odd_count(['3',""11111111""])
1605
+ [""the number of odd elements 1n the str1ng 1 of the 1nput."",
1606
+ ""the number of odd elements 8n the str8ng 8 of the 8nput.""]
1607
+ """"""
1608
+ ",0.0,0.0,0.0
1609
+ "
1610
+ def minSubArraySum(nums):
1611
+ """"""
1612
+ Given an array of integers nums, find the minimum sum of any non-empty sub-array
1613
+ of nums.
1614
+ Example
1615
+ minSubArraySum([2, 3, 4, 1, 2, 4]) == 1
1616
+ minSubArraySum([-1, -2, -3]) == -6
1617
+ """"""
1618
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1619
+ "
1620
+ def max_fill(grid, capacity):
1621
+ import math
1622
+ """"""
1623
+ You are given a rectangular grid of wells. Each row represents a single well,
1624
+ and each 1 in a row represents a single unit of water.
1625
+ Each well has a corresponding bucket that can be used to extract water from it,
1626
+ and all buckets have the same capacity.
1627
+ Your task is to use the buckets to empty the wells.
1628
+ Output the number of times you need to lower the buckets.
1629
+
1630
+ Example 1:
1631
+ Input:
1632
+ grid : [[0,0,1,0], [0,1,0,0], [1,1,1,1]]
1633
+ bucket_capacity : 1
1634
+ Output: 6
1635
+
1636
+ Example 2:
1637
+ Input:
1638
+ grid : [[0,0,1,1], [0,0,0,0], [1,1,1,1], [0,1,1,1]]
1639
+ bucket_capacity : 2
1640
+ Output: 5
1641
+
1642
+ Example 3:
1643
+ Input:
1644
+ grid : [[0,0,0], [0,0,0]]
1645
+ bucket_capacity : 5
1646
+ Output: 0
1647
+
1648
+ Constraints:
1649
+ * all wells have the same length
1650
+ * 1 <= grid.length <= 10^2
1651
+ * 1 <= grid[:,1].length <= 10^2
1652
+ * grid[i][j] -> 0 | 1
1653
+ * 1 <= capacity <= 10
1654
+ """"""
1655
+ ",0.0,0.0,0.0
1656
+ "
1657
+ def sort_array(arr):
1658
+ """"""
1659
+ In this Kata, you have to sort an array of non-negative integers according to
1660
+ number of ones in their binary representation in ascending order.
1661
+ For similar number of ones, sort based on decimal value.
1662
+
1663
+ It must be implemented like this:
1664
+ >>> sort_array([1, 5, 2, 3, 4]) == [1, 2, 3, 4, 5]
1665
+ >>> sort_array([-2, -3, -4, -5, -6]) == [-6, -5, -4, -3, -2]
1666
+ >>> sort_array([1, 0, 2, 3, 4]) [0, 1, 2, 3, 4]
1667
+ """"""
1668
+ ",0.85,1.0,1.0
1669
+ "
1670
+ def select_words(s, n):
1671
+ """"""Given a string s and a natural number n, you have been tasked to implement
1672
+ a function that returns a list of all words from string s that contain exactly
1673
+ n consonants, in order these words appear in the string s.
1674
+ If the string s is empty then the function should return an empty list.
1675
+ Note: you may assume the input string contains only letters and spaces.
1676
+ Examples:
1677
+ select_words(""Mary had a little lamb"", 4) ==> [""little""]
1678
+ select_words(""Mary had a little lamb"", 3) ==> [""Mary"", ""lamb""]
1679
+ select_words(""simple white space"", 2) ==> []
1680
+ select_words(""Hello world"", 4) ==> [""world""]
1681
+ select_words(""Uncle sam"", 3) ==> [""Uncle""]
1682
+ """"""
1683
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1684
+ "
1685
+ def get_closest_vowel(word):
1686
+ """"""You are given a word. Your task is to find the closest vowel that stands between
1687
+ two consonants from the right side of the word (case sensitive).
1688
+
1689
+ Vowels in the beginning and ending doesn't count. Return empty string if you didn't
1690
+ find any vowel met the above condition.
1691
+
1692
+ You may assume that the given string contains English letter only.
1693
+
1694
+ Example:
1695
+ get_closest_vowel(""yogurt"") ==> ""u""
1696
+ get_closest_vowel(""FULL"") ==> ""U""
1697
+ get_closest_vowel(""quick"") ==> """"
1698
+ get_closest_vowel(""ab"") ==> """"
1699
+ """"""
1700
+ ",0.0,0.0,0.0
1701
+ "
1702
+ def match_parens(lst):
1703
+ '''
1704
+ You are given a list of two strings, both strings consist of open
1705
+ parentheses '(' or close parentheses ')' only.
1706
+ Your job is to check if it is possible to concatenate the two strings in
1707
+ some order, that the resulting string will be good.
1708
+ A string S is considered to be good if and only if all parentheses in S
1709
+ are balanced. For example: the string '(())()' is good, while the string
1710
+ '())' is not.
1711
+ Return 'Yes' if there's a way to make a good string, and return 'No' otherwise.
1712
+
1713
+ Examples:
1714
+ match_parens(['()(', ')']) == 'Yes'
1715
+ match_parens([')', ')']) == 'No'
1716
+ '''
1717
+ ",0.0,0.0,0.0
1718
+ "
1719
+ def maximum(arr, k):
1720
+ """"""
1721
+ Given an array arr of integers and a positive integer k, return a sorted list
1722
+ of length k with the maximum k numbers in arr.
1723
+
1724
+ Example 1:
1725
+
1726
+ Input: arr = [-3, -4, 5], k = 3
1727
+ Output: [-4, -3, 5]
1728
+
1729
+ Example 2:
1730
+
1731
+ Input: arr = [4, -4, 4], k = 2
1732
+ Output: [4, 4]
1733
+
1734
+ Example 3:
1735
+
1736
+ Input: arr = [-3, 2, 1, 2, -1, -2, 1], k = 1
1737
+ Output: [2]
1738
+
1739
+ Note:
1740
+ 1. The length of the array will be in the range of [1, 1000].
1741
+ 2. The elements in the array will be in the range of [-1000, 1000].
1742
+ 3. 0 <= k <= len(arr)
1743
+ """"""
1744
+ ",0.0,0.0,0.0
1745
+ "
1746
+ def solution(lst):
1747
+ """"""Given a non-empty list of integers, return the sum of all of the odd elements that are in even positions.
1748
+
1749
+
1750
+ Examples
1751
+ solution([5, 8, 7, 1]) ==> 12
1752
+ solution([3, 3, 3, 3, 3]) ==> 9
1753
+ solution([30, 13, 24, 321]) ==>0
1754
+ """"""
1755
+ ",0.0,0.0,0.0
1756
+ "
1757
+ def add_elements(arr, k):
1758
+ """"""
1759
+ Given a non-empty array of integers arr and an integer k, return
1760
+ the sum of the elements with at most two digits from the first k elements of arr.
1761
+
1762
+ Example:
1763
+
1764
+ Input: arr = [111,21,3,4000,5,6,7,8,9], k = 4
1765
+ Output: 24 # sum of 21 + 3
1766
+
1767
+ Constraints:
1768
+ 1. 1 <= len(arr) <= 100
1769
+ 2. 1 <= k <= len(arr)
1770
+ """"""
1771
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1772
+ "
1773
+ def get_odd_collatz(n):
1774
+ """"""
1775
+ Given a positive integer n, return a sorted list that has the odd numbers in collatz sequence.
1776
+
1777
+ The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
1778
+ as follows: start with any positive integer n. Then each term is obtained from the
1779
+ previous term as follows: if the previous term is even, the next term is one half of
1780
+ the previous term. If the previous term is odd, the next term is 3 times the previous
1781
+ term plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.
1782
+
1783
+ Note:
1784
+ 1. Collatz(1) is [1].
1785
+ 2. returned list sorted in increasing order.
1786
+
1787
+ For example:
1788
+ get_odd_collatz(5) returns [1, 5] # The collatz sequence for 5 is [5, 16, 8, 4, 2, 1], so the odd numbers are only 1, and 5.
1789
+ """"""
1790
+ ",0.25,0.8063080495356036,0.9837461300309598
1791
+ "
1792
+ def valid_date(date):
1793
+ """"""You have to write a function which validates a given date string and
1794
+ returns True if the date is valid otherwise False.
1795
+ The date is valid if all of the following rules are satisfied:
1796
+ 1. The date string is not empty.
1797
+ 2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.
1798
+ 3. The months should not be less than 1 or higher than 12.
1799
+ 4. The date should be in the format: mm-dd-yyyy
1800
+
1801
+ for example:
1802
+ valid_date('03-11-2000') => True
1803
+
1804
+ valid_date('15-01-2012') => False
1805
+
1806
+ valid_date('04-0-2040') => False
1807
+
1808
+ valid_date('06-04-2020') => True
1809
+
1810
+ valid_date('06/04/2020') => False
1811
+ """"""
1812
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
1813
+ "
1814
+ def split_words(txt):
1815
+ '''
1816
+ Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
1817
+ should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
1818
+ alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
1819
+ Examples
1820
+ split_words(""Hello world!"") ➞ [""Hello"", ""world!""]
1821
+ split_words(""Hello,world!"") ➞ [""Hello"", ""world!""]
1822
+ split_words(""abcdef"") == 3
1823
+ '''
1824
+ ",0.0,0.0,0.0
1825
+ "
1826
+ def is_sorted(lst):
1827
+ '''
1828
+ Given a list of numbers, return whether or not they are sorted
1829
+ in ascending order. If list has more than 1 duplicate of the same
1830
+ number, return False. Assume no negative numbers and only integers.
1831
+
1832
+ Examples
1833
+ is_sorted([5]) ➞ True
1834
+ is_sorted([1, 2, 3, 4, 5]) ➞ True
1835
+ is_sorted([1, 3, 2, 4, 5]) ➞ False
1836
+ is_sorted([1, 2, 3, 4, 5, 6]) ➞ True
1837
+ is_sorted([1, 2, 3, 4, 5, 6, 7]) ➞ True
1838
+ is_sorted([1, 3, 2, 4, 5, 6, 7]) ➞ False
1839
+ is_sorted([1, 2, 2, 3, 3, 4]) ➞ True
1840
+ is_sorted([1, 2, 2, 2, 3, 4]) ➞ False
1841
+ '''
1842
+ ",0.0,0.0,0.0
1843
+ "
1844
+ def intersection(interval1, interval2):
1845
+ """"""You are given two intervals,
1846
+ where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
1847
+ The given intervals are closed which means that the interval (start, end)
1848
+ includes both start and end.
1849
+ For each given interval, it is assumed that its start is less or equal its end.
1850
+ Your task is to determine whether the length of intersection of these two
1851
+ intervals is a prime number.
1852
+ Example, the intersection of the intervals (1, 3), (2, 4) is (2, 3)
1853
+ which its length is 1, which not a prime number.
1854
+ If the length of the intersection is a prime number, return ""YES"",
1855
+ otherwise, return ""NO"".
1856
+ If the two intervals don't intersect, return ""NO"".
1857
+
1858
+
1859
+ [input/output] samples:
1860
+ intersection((1, 2), (2, 3)) ==> ""NO""
1861
+ intersection((-1, 1), (0, 4)) ==> ""NO""
1862
+ intersection((-3, -1), (-5, 5)) ==> ""YES""
1863
+ """"""
1864
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1865
+ "
1866
+ def prod_signs(arr):
1867
+ """"""
1868
+ You are given an array arr of integers and you need to return
1869
+ sum of magnitudes of integers multiplied by product of all signs
1870
+ of each number in the array, represented by 1, -1 or 0.
1871
+ Note: return None for empty arr.
1872
+
1873
+ Example:
1874
+ >>> prod_signs([1, 2, 2, -4]) == -9
1875
+ >>> prod_signs([0, 1]) == 0
1876
+ >>> prod_signs([]) == None
1877
+ """"""
1878
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
1879
+ "
1880
+ def minPath(grid, k):
1881
+ """"""
1882
+ Given a grid with N rows and N columns (N >= 2) and a positive integer k,
1883
+ each cell of the grid contains a value. Every integer in the range [1, N * N]
1884
+ inclusive appears exactly once on the cells of the grid.
1885
+
1886
+ You have to find the minimum path of length k in the grid. You can start
1887
+ from any cell, and in each step you can move to any of the neighbor cells,
1888
+ in other words, you can go to cells which share an edge with you current
1889
+ cell.
1890
+ Please note that a path of length k means visiting exactly k cells (not
1891
+ necessarily distinct).
1892
+ You CANNOT go off the grid.
1893
+ A path A (of length k) is considered less than a path B (of length k) if
1894
+ after making the ordered lists of the values on the cells that A and B go
1895
+ through (let's call them lst_A and lst_B), lst_A is lexicographically less
1896
+ than lst_B, in other words, there exist an integer index i (1 <= i <= k)
1897
+ such that lst_A[i] < lst_B[i] and for any j (1 <= j < i) we have
1898
+ lst_A[j] = lst_B[j].
1899
+ It is guaranteed that the answer is unique.
1900
+ Return an ordered list of the values on the cells that the minimum path go through.
1901
+
1902
+ Examples:
1903
+
1904
+ Input: grid = [ [1,2,3], [4,5,6], [7,8,9]], k = 3
1905
+ Output: [1, 2, 1]
1906
+
1907
+ Input: grid = [ [5,9,3], [4,1,6], [7,8,2]], k = 1
1908
+ Output: [1]
1909
+ """"""
1910
+ ",0.0,0.0,0.0
1911
+ "
1912
+ def tri(n):
1913
+ """"""Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
1914
+ the last couple centuries. However, what people don't know is Tribonacci sequence.
1915
+ Tribonacci sequence is defined by the recurrence:
1916
+ tri(1) = 3
1917
+ tri(n) = 1 + n / 2, if n is even.
1918
+ tri(n) = tri(n - 1) + tri(n - 2) + tri(n + 1), if n is odd.
1919
+ For example:
1920
+ tri(2) = 1 + (2 / 2) = 2
1921
+ tri(4) = 3
1922
+ tri(3) = tri(2) + tri(1) + tri(4)
1923
+ = 2 + 3 + 3 = 8
1924
+ You are given a non-negative integer number n, you have to a return a list of the
1925
+ first n + 1 numbers of the Tribonacci sequence.
1926
+ Examples:
1927
+ tri(3) = [1, 3, 2, 8]
1928
+ """"""
1929
+ ",0.0,0.0,0.0
1930
+ "
1931
+ def digits(n):
1932
+ """"""Given a positive integer n, return the product of the odd digits.
1933
+ Return 0 if all digits are even.
1934
+ For example:
1935
+ digits(1) == 1
1936
+ digits(4) == 0
1937
+ digits(235) == 15
1938
+ """"""
1939
+ ",0.0,0.0,0.0
1940
+ "
1941
+ def is_nested(string):
1942
+ '''
1943
+ Create a function that takes a string as input which contains only square brackets.
1944
+ The function should return True if and only if there is a valid subsequence of brackets
1945
+ where at least one bracket in the subsequence is nested.
1946
+
1947
+ is_nested('[[]]') ➞ True
1948
+ is_nested('[]]]]]]][[[[[]') ➞ False
1949
+ is_nested('[][]') ➞ False
1950
+ is_nested('[]') ➞ False
1951
+ is_nested('[[][]]') ➞ True
1952
+ is_nested('[[]][[') ➞ True
1953
+ '''
1954
+ ",0.0,0.0,0.0
1955
+ "
1956
+
1957
+ def sum_squares(lst):
1958
+ """"""You are given a list of numbers.
1959
+ You need to return the sum of squared numbers in the given list,
1960
+ round each element in the list to the upper int(Ceiling) first.
1961
+ Examples:
1962
+ For lst = [1,2,3] the output should be 14
1963
+ For lst = [1,4,9] the output should be 98
1964
+ For lst = [1,3,5,7] the output should be 84
1965
+ For lst = [1.4,4.2,0] the output should be 29
1966
+ For lst = [-2.4,1,1] the output should be 6
1967
+
1968
+
1969
+ """"""
1970
+ ",0.0,0.0,0.0
1971
+ "
1972
+ def check_if_last_char_is_a_letter(txt):
1973
+ '''
1974
+ Create a function that returns True if the last character
1975
+ of a given string is an alphabetical character and is not
1976
+ a part of a word, and False otherwise.
1977
+ Note: ""word"" is a group of characters separated by space.
1978
+
1979
+ Examples:
1980
+ check_if_last_char_is_a_letter(""apple pie"") ➞ False
1981
+ check_if_last_char_is_a_letter(""apple pi e"") ➞ True
1982
+ check_if_last_char_is_a_letter(""apple pi e "") ➞ False
1983
+ check_if_last_char_is_a_letter("""") ➞ False
1984
+ '''
1985
+ ",0.0,0.0,0.0
1986
+ "
1987
+ def can_arrange(arr):
1988
+ """"""Create a function which returns the largest index of an element which
1989
+ is not greater than or equal to the element immediately preceding it. If
1990
+ no such element exists then return -1. The given array will not contain
1991
+ duplicate values.
1992
+
1993
+ Examples:
1994
+ can_arrange([1,2,4,3,5]) = 3
1995
+ can_arrange([1,2,3]) = -1
1996
+ """"""
1997
+ ",0.0,0.0,0.0
1998
+ "
1999
+ def largest_smallest_integers(lst):
2000
+ '''
2001
+ Create a function that returns a tuple (a, b), where 'a' is
2002
+ the largest of negative integers, and 'b' is the smallest
2003
+ of positive integers in a list.
2004
+ If there is no negative or positive integers, return them as None.
2005
+
2006
+ Examples:
2007
+ largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
2008
+ largest_smallest_integers([]) == (None, None)
2009
+ largest_smallest_integers([0]) == (None, None)
2010
+ '''
2011
+ ",0.30000000000000004,0.8708720330237358,0.9945820433436533
2012
+ "
2013
+ def compare_one(a, b):
2014
+ """"""
2015
+ Create a function that takes integers, floats, or strings representing
2016
+ real numbers, and returns the larger variable in its given variable type.
2017
+ Return None if the values are equal.
2018
+ Note: If a real number is represented as a string, the floating point might be . or ,
2019
+
2020
+ compare_one(1, 2.5) ➞ 2.5
2021
+ compare_one(1, ""2,3"") ➞ ""2,3""
2022
+ compare_one(""5,1"", ""6"") ➞ ""6""
2023
+ compare_one(""1"", 1) ➞ None
2024
+ """"""
2025
+ ",0.050000000000000044,0.25,0.5
2026
+ "
2027
+ def is_equal_to_sum_even(n):
2028
+ """"""Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
2029
+ Example
2030
+ is_equal_to_sum_even(4) == False
2031
+ is_equal_to_sum_even(6) == False
2032
+ is_equal_to_sum_even(8) == True
2033
+ """"""
2034
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2035
+ "
2036
+ def special_factorial(n):
2037
+ """"""The Brazilian factorial is defined as:
2038
+ brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
2039
+ where n > 0
2040
+
2041
+ For example:
2042
+ >>> special_factorial(4)
2043
+ 288
2044
+
2045
+ The function will receive an integer as input and should return the special
2046
+ factorial of this integer.
2047
+ """"""
2048
+ ",0.0,0.0,0.0
2049
+ "
2050
+ def fix_spaces(text):
2051
+ """"""
2052
+ Given a string text, replace all spaces in it with underscores,
2053
+ and if a string has more than 2 consecutive spaces,
2054
+ then replace all consecutive spaces with -
2055
+
2056
+ fix_spaces(""Example"") == ""Example""
2057
+ fix_spaces(""Example 1"") == ""Example_1""
2058
+ fix_spaces("" Example 2"") == ""_Example_2""
2059
+ fix_spaces("" Example 3"") == ""_Example-3""
2060
+ """"""
2061
+ ",0.0,0.0,0.0
2062
+ "
2063
+ def file_name_check(file_name):
2064
+ """"""Create a function which takes a string representing a file's name, and returns
2065
+ 'Yes' if the the file's name is valid, and returns 'No' otherwise.
2066
+ A file's name is considered to be valid if and only if all the following conditions
2067
+ are met:
2068
+ - There should not be more than three digits ('0'-'9') in the file's name.
2069
+ - The file's name contains exactly one dot '.'
2070
+ - The substring before the dot should not be empty, and it starts with a letter from
2071
+ the latin alphapet ('a'-'z' and 'A'-'Z').
2072
+ - The substring after the dot should be one of these: ['txt', 'exe', 'dll']
2073
+ Examples:
2074
+ file_name_check(""example.txt"") # => 'Yes'
2075
+ file_name_check(""1example.dll"") # => 'No' (the name should start with a latin alphapet letter)
2076
+ """"""
2077
+ ",0.0,0.0,0.0
2078
+ "
2079
+
2080
+
2081
+ def sum_squares(lst):
2082
+ """"""""
2083
+ 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
2084
+ 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
2085
+ 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.
2086
+
2087
+ Examples:
2088
+ For lst = [1,2,3] the output should be 6
2089
+ For lst = [] the output should be 0
2090
+ For lst = [-1,-5,2,-1,-5] the output should be -126
2091
+ """"""
2092
+ ",0.0,0.0,0.0
2093
+ "
2094
+ def words_in_sentence(sentence):
2095
+ """"""
2096
+ You are given a string representing a sentence,
2097
+ the sentence contains some words separated by a space,
2098
+ and you have to return a string that contains the words from the original sentence,
2099
+ whose lengths are prime numbers,
2100
+ the order of the words in the new string should be the same as the original one.
2101
+
2102
+ Example 1:
2103
+ Input: sentence = ""This is a test""
2104
+ Output: ""is""
2105
+
2106
+ Example 2:
2107
+ Input: sentence = ""lets go for swimming""
2108
+ Output: ""go for""
2109
+
2110
+ Constraints:
2111
+ * 1 <= len(sentence) <= 100
2112
+ * sentence contains only letters
2113
+ """"""
2114
+ ",0.65,0.9986455108359134,1.0
2115
+ "
2116
+ def simplify(x, n):
2117
+ """"""Your task is to implement a function that will simplify the expression
2118
+ x * n. The function returns True if x * n evaluates to a whole number and False
2119
+ otherwise. Both x and n, are string representation of a fraction, and have the following format,
2120
+ <numerator>/<denominator> where both numerator and denominator are positive whole numbers.
2121
+
2122
+ You can assume that x, and n are valid fractions, and do not have zero as denominator.
2123
+
2124
+ simplify(""1/5"", ""5/1"") = True
2125
+ simplify(""1/6"", ""2/1"") = False
2126
+ simplify(""7/10"", ""10/2"") = False
2127
+ """"""
2128
+ ",0.0,0.0,0.0
2129
+ "
2130
+ def order_by_points(nums):
2131
+ """"""
2132
+ Write a function which sorts the given list of integers
2133
+ in ascending order according to the sum of their digits.
2134
+ Note: if there are several items with similar sum of their digits,
2135
+ order them based on their index in original list.
2136
+
2137
+ For example:
2138
+ >>> order_by_points([1, 11, -1, -11, -12]) == [-1, -11, 1, -12, 11]
2139
+ >>> order_by_points([]) == []
2140
+ """"""
2141
+ ",0.0,0.0,0.0
2142
+ "
2143
+ def specialFilter(nums):
2144
+ """"""Write a function that takes an array of numbers as input and returns
2145
+ the number of elements in the array that are greater than 10 and both
2146
+ first and last digits of a number are odd (1, 3, 5, 7, 9).
2147
+ For example:
2148
+ specialFilter([15, -73, 14, -15]) => 1
2149
+ specialFilter([33, -2, -3, 45, 21, 109]) => 2
2150
+ """"""
2151
+ ",0.09999999999999998,0.4473684210526315,0.763157894736842
2152
+ "
2153
+ def get_max_triples(n):
2154
+ """"""
2155
+ You are given a positive integer n. You have to create an integer array a of length n.
2156
+ For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
2157
+ Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
2158
+ and a[i] + a[j] + a[k] is a multiple of 3.
2159
+
2160
+ Example :
2161
+ Input: n = 5
2162
+ Output: 1
2163
+ Explanation:
2164
+ a = [1, 3, 7, 13, 21]
2165
+ The only valid triple is (1, 7, 13).
2166
+ """"""
2167
+ ",0.0,0.0,0.0
2168
+ "
2169
+ def bf(planet1, planet2):
2170
+ '''
2171
+ There are eight planets in our solar system: the closerst to the Sun
2172
+ is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
2173
+ Uranus, Neptune.
2174
+ Write a function that takes two planet names as strings planet1 and planet2.
2175
+ The function should return a tuple containing all planets whose orbits are
2176
+ located between the orbit of planet1 and the orbit of planet2, sorted by
2177
+ the proximity to the sun.
2178
+ The function should return an empty tuple if planet1 or planet2
2179
+ are not correct planet names.
2180
+ Examples
2181
+ bf(""Jupiter"", ""Neptune"") ==> (""Saturn"", ""Uranus"")
2182
+ bf(""Earth"", ""Mercury"") ==> (""Venus"")
2183
+ bf(""Mercury"", ""Uranus"") ==> (""Venus"", ""Earth"", ""Mars"", ""Jupiter"", ""Saturn"")
2184
+ '''
2185
+ ",1.0,1.0,1.0
2186
+ "
2187
+ def sorted_list_sum(lst):
2188
+ """"""Write a function that accepts a list of strings as a parameter,
2189
+ deletes the strings that have odd lengths from it,
2190
+ and returns the resulted list with a sorted order,
2191
+ The list is always a list of strings and never an array of numbers,
2192
+ and it may contain duplicates.
2193
+ The order of the list should be ascending by length of each word, and you
2194
+ should return the list sorted by that rule.
2195
+ If two words have the same length, sort the list alphabetically.
2196
+ The function should return a list of strings in sorted order.
2197
+ You may assume that all words will have the same length.
2198
+ For example:
2199
+ assert list_sort([""aa"", ""a"", ""aaa""]) => [""aa""]
2200
+ assert list_sort([""ab"", ""a"", ""aaa"", ""cd""]) => [""ab"", ""cd""]
2201
+ """"""
2202
+ ",0.0,0.0,0.0
2203
+ "
2204
+ def x_or_y(n, x, y):
2205
+ """"""A simple program which should return the value of x if n is
2206
+ a prime number and should return the value of y otherwise.
2207
+
2208
+ Examples:
2209
+ for x_or_y(7, 34, 12) == 34
2210
+ for x_or_y(15, 8, 5) == 5
2211
+
2212
+ """"""
2213
+ ",0.050000000000000044,0.25,0.5
2214
+ "
2215
+ def double_the_difference(lst):
2216
+ '''
2217
+ Given a list of numbers, return the sum of squares of the numbers
2218
+ in the list that are odd. Ignore numbers that are negative or not integers.
2219
+
2220
+ double_the_difference([1, 3, 2, 0]) == 1 + 9 + 0 + 0 = 10
2221
+ double_the_difference([-1, -2, 0]) == 0
2222
+ double_the_difference([9, -2]) == 81
2223
+ double_the_difference([0]) == 0
2224
+
2225
+ If the input list is empty, return 0.
2226
+ '''
2227
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2228
+ "
2229
+ def compare(game,guess):
2230
+ """"""I think we all remember that feeling when the result of some long-awaited
2231
+ event is finally known. The feelings and thoughts you have at that moment are
2232
+ definitely worth noting down and comparing.
2233
+ Your task is to determine if a person correctly guessed the results of a number of matches.
2234
+ You are given two arrays of scores and guesses of equal length, where each index shows a match.
2235
+ Return an array of the same length denoting how far off each guess was. If they have guessed correctly,
2236
+ the value is 0, and if not, the value is the absolute difference between the guess and the score.
2237
+
2238
+
2239
+ example:
2240
+
2241
+ compare([1,2,3,4,5,1],[1,2,3,4,2,-2]) -> [0,0,0,0,3,3]
2242
+ compare([0,5,0,0,0,4],[4,1,1,0,0,-2]) -> [4,4,1,0,0,6]
2243
+ """"""
2244
+ ",0.75,0.9999355005159959,1.0
2245
+ "
2246
+ def Strongest_Extension(class_name, extensions):
2247
+ """"""You will be given the name of a class (a string) and a list of extensions.
2248
+ The extensions are to be used to load additional classes to the class. The
2249
+ strength of the extension is as follows: Let CAP be the number of the uppercase
2250
+ letters in the extension's name, and let SM be the number of lowercase letters
2251
+ in the extension's name, the strength is given by the fraction CAP - SM.
2252
+ You should find the strongest extension and return a string in this
2253
+ format: ClassName.StrongestExtensionName.
2254
+ If there are two or more extensions with the same strength, you should
2255
+ choose the one that comes first in the list.
2256
+ For example, if you are given ""Slices"" as the class and a list of the
2257
+ extensions: ['SErviNGSliCes', 'Cheese', 'StuFfed'] then you should
2258
+ return 'Slices.SErviNGSliCes' since 'SErviNGSliCes' is the strongest extension
2259
+ (its strength is -1).
2260
+ Example:
2261
+ for Strongest_Extension('my_class', ['AA', 'Be', 'CC']) == 'my_class.AA'
2262
+ """"""
2263
+ ",0.15000000000000002,0.6008771929824561,0.8947368421052632
2264
+ "
2265
+ def cycpattern_check(a , b):
2266
+ """"""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
2267
+ cycpattern_check(""abcd"",""abd"") => False
2268
+ cycpattern_check(""hello"",""ell"") => True
2269
+ cycpattern_check(""whassup"",""psus"") => False
2270
+ cycpattern_check(""abab"",""baa"") => True
2271
+ cycpattern_check(""efef"",""eeff"") => False
2272
+ cycpattern_check(""himenss"",""simen"") => True
2273
+
2274
+ """"""
2275
+ ",0.0,0.0,0.0
2276
+ "
2277
+ def even_odd_count(num):
2278
+ """"""Given an integer. return a tuple that has the number of even and odd digits respectively.
2279
+
2280
+ Example:
2281
+ even_odd_count(-12) ==> (1, 1)
2282
+ even_odd_count(123) ==> (1, 2)
2283
+ """"""
2284
+ ",0.75,0.9999355005159959,1.0
2285
+ "
2286
+ def int_to_mini_roman(number):
2287
+ """"""
2288
+ Given a positive integer, obtain its roman numeral equivalent as a string,
2289
+ and return it in lowercase.
2290
+ Restrictions: 1 <= num <= 1000
2291
+
2292
+ Examples:
2293
+ >>> int_to_mini_roman(19) == 'xix'
2294
+ >>> int_to_mini_roman(152) == 'clii'
2295
+ >>> int_to_mini_roman(426) == 'cdxxvi'
2296
+ """"""
2297
+ ",0.7,0.9996130030959752,1.0
2298
+ "
2299
+ def right_angle_triangle(a, b, c):
2300
+ '''
2301
+ Given the lengths of the three sides of a triangle. Return True if the three
2302
+ sides form a right-angled triangle, False otherwise.
2303
+ A right-angled triangle is a triangle in which one angle is right angle or
2304
+ 90 degree.
2305
+ Example:
2306
+ right_angle_triangle(3, 4, 5) == True
2307
+ right_angle_triangle(1, 2, 3) == False
2308
+ '''
2309
+ ",0.4999999999999999,0.9837461300309598,0.9999945874558878
2310
+ "
2311
+ def find_max(words):
2312
+ """"""Write a function that accepts a list of strings.
2313
+ The list contains different words. Return the word with maximum number
2314
+ of unique characters. If multiple strings have maximum number of unique
2315
+ characters, return the one which comes first in lexicographical order.
2316
+
2317
+ find_max([""name"", ""of"", ""string""]) == ""string""
2318
+ find_max([""name"", ""enam"", ""game""]) == ""enam""
2319
+ find_max([""aaaaaaa"", ""bb"" ,""cc""]) == """"aaaaaaa""
2320
+ """"""
2321
+ ",0.7,0.9996130030959752,1.0
2322
+ "
2323
+ def eat(number, need, remaining):
2324
+ """"""
2325
+ You're a hungry rabbit, and you already have eaten a certain number of carrots,
2326
+ but now you need to eat more carrots to complete the day's meals.
2327
+ you should return an array of [ total number of eaten carrots after your meals,
2328
+ the number of carrots left after your meals ]
2329
+ if there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.
2330
+
2331
+ Example:
2332
+ * eat(5, 6, 10) -> [11, 4]
2333
+ * eat(4, 8, 9) -> [12, 1]
2334
+ * eat(1, 10, 10) -> [11, 0]
2335
+ * eat(2, 11, 5) -> [7, 0]
2336
+
2337
+ Variables:
2338
+ @number : integer
2339
+ the number of carrots that you have eaten.
2340
+ @need : integer
2341
+ the number of carrots that you need to eat.
2342
+ @remaining : integer
2343
+ the number of remaining carrots thet exist in stock
2344
+
2345
+ Constrain:
2346
+ * 0 <= number <= 1000
2347
+ * 0 <= need <= 1000
2348
+ * 0 <= remaining <= 1000
2349
+
2350
+ Have fun :)
2351
+ """"""
2352
+ ",0.3500000000000001,0.9169891640866873,0.9984520123839009
2353
+ "
2354
+ def do_algebra(operator, operand):
2355
+ """"""
2356
+ Given two lists operator, and operand. The first list has basic algebra operations, and
2357
+ the second list is a list of integers. Use the two given lists to build the algebric
2358
+ expression and return the evaluation of this expression.
2359
+
2360
+ The basic algebra operations:
2361
+ Addition ( + )
2362
+ Subtraction ( - )
2363
+ Multiplication ( * )
2364
+ Floor division ( // )
2365
+ Exponentiation ( ** )
2366
+
2367
+ Example:
2368
+ operator['+', '*', '-']
2369
+ array = [2, 3, 4, 5]
2370
+ result = 2 + 3 * 4 - 5
2371
+ => result = 9
2372
+
2373
+ Note:
2374
+ The length of operator list is equal to the length of operand list minus one.
2375
+ Operand is a list of of non-negative integers.
2376
+ Operator list has at least one operator, and operand list has at least two operands.
2377
+
2378
+ """"""
2379
+ ",0.0,0.0,0.0
2380
+ "
2381
+ def solve(s):
2382
+ """"""You are given a string s.
2383
+ if s[i] is a letter, reverse its case from lower to upper or vise versa,
2384
+ otherwise keep it as it is.
2385
+ If the string contains no letters, reverse the string.
2386
+ The function should return the resulted string.
2387
+ Examples
2388
+ solve(""1234"") = ""4321""
2389
+ solve(""ab"") = ""AB""
2390
+ solve(""#a@C"") = ""#A@c""
2391
+ """"""
2392
+ ",0.5499999999999998,0.9918730650154799,1.0
2393
+ "
2394
+ def string_to_md5(text):
2395
+ """"""
2396
+ Given a string 'text', return its md5 hash equivalent string.
2397
+ If 'text' is an empty string, return None.
2398
+
2399
+ >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
2400
+ """"""
2401
+ ",0.44999999999999984,0.9702012383900929,0.9999404620147654
2402
+ "
2403
+ def generate_integers(a, b):
2404
+ """"""
2405
+ Given two positive integers a and b, return the even digits between a
2406
+ and b, in ascending order.
2407
+
2408
+ For example:
2409
+ generate_integers(2, 8) => [2, 4, 6, 8]
2410
+ generate_integers(8, 2) => [2, 4, 6, 8]
2411
+ generate_integers(10, 14) => []
2412
+ """"""
2413
+ ",0.0,0.0,0.0
data/coding/humaneval/json/1.json ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pass@1": [
3
+ 0.5499999999999998,
4
+ 0.0,
5
+ 0.4,
6
+ 1.0,
7
+ 1.0,
8
+ 0.0,
9
+ 0.15000000000000002,
10
+ 0.8999999999999999,
11
+ 1.0,
12
+ 0.4,
13
+ 0.0,
14
+ 0.6000000000000001,
15
+ 1.0,
16
+ 0.6000000000000001,
17
+ 0.30000000000000004,
18
+ 0.7,
19
+ 0.30000000000000004,
20
+ 0.6000000000000001,
21
+ 0.7999999999999999,
22
+ 0.0,
23
+ 0.5499999999999998,
24
+ 0.75,
25
+ 0.4999999999999999,
26
+ 0.8999999999999999,
27
+ 0.0,
28
+ 1.0,
29
+ 0.050000000000000044,
30
+ 0.7999999999999999,
31
+ 0.95,
32
+ 0.8999999999999999,
33
+ 0.44999999999999984,
34
+ 0.6000000000000001,
35
+ 0.0,
36
+ 0.050000000000000044,
37
+ 0.7,
38
+ 0.44999999999999984,
39
+ 0.0,
40
+ 0.050000000000000044,
41
+ 0.0,
42
+ 0.0,
43
+ 0.7,
44
+ 0.0,
45
+ 0.5499999999999998,
46
+ 0.7,
47
+ 0.30000000000000004,
48
+ 1.0,
49
+ 0.3500000000000001,
50
+ 0.85,
51
+ 0.3500000000000001,
52
+ 0.0,
53
+ 1.0,
54
+ 0.7999999999999999,
55
+ 0.4999999999999999,
56
+ 0.8999999999999999,
57
+ 0.44999999999999984,
58
+ 0.5499999999999998,
59
+ 0.6000000000000001,
60
+ 0.65,
61
+ 0.8999999999999999,
62
+ 0.09999999999999998,
63
+ 0.6000000000000001,
64
+ 0.25,
65
+ 0.25,
66
+ 0.15000000000000002,
67
+ 0.7,
68
+ 0.09999999999999998,
69
+ 0.65,
70
+ 0.0,
71
+ 0.44999999999999984,
72
+ 0.25,
73
+ 0.09999999999999998,
74
+ 0.20000000000000007,
75
+ 0.5499999999999998,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.0,
80
+ 0.0,
81
+ 0.4,
82
+ 0.85,
83
+ 0.20000000000000007,
84
+ 0.20000000000000007,
85
+ 0.20000000000000007,
86
+ 0.0,
87
+ 0.0,
88
+ 0.6000000000000001,
89
+ 0.6000000000000001,
90
+ 0.050000000000000044,
91
+ 0.050000000000000044,
92
+ 0.09999999999999998,
93
+ 0.30000000000000004,
94
+ 0.0,
95
+ 0.44999999999999984,
96
+ 0.0,
97
+ 0.30000000000000004,
98
+ 0.050000000000000044,
99
+ 0.65,
100
+ 0.09999999999999998,
101
+ 0.09999999999999998,
102
+ 0.0,
103
+ 0.050000000000000044,
104
+ 0.0,
105
+ 0.050000000000000044,
106
+ 0.0,
107
+ 0.25,
108
+ 0.15000000000000002,
109
+ 0.0,
110
+ 0.85,
111
+ 0.0,
112
+ 0.050000000000000044,
113
+ 0.0,
114
+ 0.15000000000000002,
115
+ 0.5499999999999998,
116
+ 0.0,
117
+ 0.15000000000000002,
118
+ 0.0,
119
+ 1.0,
120
+ 0.050000000000000044,
121
+ 0.050000000000000044,
122
+ 0.0,
123
+ 0.0,
124
+ 0.050000000000000044,
125
+ 0.09999999999999998,
126
+ 0.4,
127
+ 0.20000000000000007,
128
+ 0.0,
129
+ 0.0,
130
+ 0.44999999999999984,
131
+ 0.050000000000000044,
132
+ 0.0,
133
+ 0.0,
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.0,
139
+ 0.15000000000000002,
140
+ 0.0,
141
+ 0.09999999999999998,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.5499999999999998,
147
+ 0.0,
148
+ 0.0,
149
+ 0.25,
150
+ 0.0,
151
+ 0.95,
152
+ 0.050000000000000044,
153
+ 0.050000000000000044,
154
+ 0.7,
155
+ 0.85,
156
+ 0.0,
157
+ 0.0,
158
+ 0.5499999999999998,
159
+ 0.5499999999999998,
160
+ 0.4,
161
+ 1.0,
162
+ 0.3500000000000001,
163
+ 0.0,
164
+ 0.4999999999999999,
165
+ 0.65,
166
+ 0.0
167
+ ],
168
+ "pass@5": [
169
+ 0.9918730650154799,
170
+ 0.0,
171
+ 0.9489164086687306,
172
+ 1.0,
173
+ 1.0,
174
+ 0.0,
175
+ 0.6008771929824561,
176
+ 1.0,
177
+ 1.0,
178
+ 0.9489164086687306,
179
+ 0.0,
180
+ 0.9963880288957688,
181
+ 1.0,
182
+ 0.9963880288957688,
183
+ 0.8708720330237358,
184
+ 0.9996130030959752,
185
+ 0.8708720330237358,
186
+ 0.9963880288957688,
187
+ 1.0,
188
+ 0.0,
189
+ 0.9918730650154799,
190
+ 0.9999355005159959,
191
+ 0.9837461300309598,
192
+ 1.0,
193
+ 0.0,
194
+ 1.0,
195
+ 0.25,
196
+ 1.0,
197
+ 1.0,
198
+ 1.0,
199
+ 0.9702012383900929,
200
+ 0.9963880288957688,
201
+ 0.0,
202
+ 0.25,
203
+ 0.9996130030959752,
204
+ 0.9702012383900929,
205
+ 0.0,
206
+ 0.25,
207
+ 0.0,
208
+ 0.0,
209
+ 0.9996130030959752,
210
+ 0.0,
211
+ 0.9918730650154799,
212
+ 0.9996130030959752,
213
+ 0.8708720330237358,
214
+ 1.0,
215
+ 0.9169891640866873,
216
+ 1.0,
217
+ 0.9169891640866873,
218
+ 0.0,
219
+ 1.0,
220
+ 1.0,
221
+ 0.9837461300309598,
222
+ 1.0,
223
+ 0.9702012383900929,
224
+ 0.9918730650154799,
225
+ 0.9963880288957688,
226
+ 0.9986455108359134,
227
+ 1.0,
228
+ 0.4473684210526315,
229
+ 0.9963880288957688,
230
+ 0.8063080495356036,
231
+ 0.8063080495356036,
232
+ 0.6008771929824561,
233
+ 0.9996130030959752,
234
+ 0.4473684210526315,
235
+ 0.9986455108359134,
236
+ 0.0,
237
+ 0.9702012383900929,
238
+ 0.8063080495356036,
239
+ 0.4473684210526315,
240
+ 0.7182662538699691,
241
+ 0.9918730650154799,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.0,
246
+ 0.0,
247
+ 0.9489164086687306,
248
+ 1.0,
249
+ 0.7182662538699691,
250
+ 0.7182662538699691,
251
+ 0.7182662538699691,
252
+ 0.0,
253
+ 0.0,
254
+ 0.9963880288957688,
255
+ 0.9963880288957688,
256
+ 0.25,
257
+ 0.25,
258
+ 0.4473684210526315,
259
+ 0.8708720330237358,
260
+ 0.0,
261
+ 0.9702012383900929,
262
+ 0.0,
263
+ 0.8708720330237358,
264
+ 0.25,
265
+ 0.9986455108359134,
266
+ 0.4473684210526315,
267
+ 0.4473684210526315,
268
+ 0.0,
269
+ 0.25,
270
+ 0.0,
271
+ 0.25,
272
+ 0.0,
273
+ 0.8063080495356036,
274
+ 0.6008771929824561,
275
+ 0.0,
276
+ 1.0,
277
+ 0.0,
278
+ 0.25,
279
+ 0.0,
280
+ 0.6008771929824561,
281
+ 0.9918730650154799,
282
+ 0.0,
283
+ 0.6008771929824561,
284
+ 0.0,
285
+ 1.0,
286
+ 0.25,
287
+ 0.25,
288
+ 0.0,
289
+ 0.0,
290
+ 0.25,
291
+ 0.4473684210526315,
292
+ 0.9489164086687306,
293
+ 0.7182662538699691,
294
+ 0.0,
295
+ 0.0,
296
+ 0.9702012383900929,
297
+ 0.25,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.0,
303
+ 0.0,
304
+ 0.0,
305
+ 0.6008771929824561,
306
+ 0.0,
307
+ 0.4473684210526315,
308
+ 0.0,
309
+ 0.0,
310
+ 0.0,
311
+ 0.0,
312
+ 0.9918730650154799,
313
+ 0.0,
314
+ 0.0,
315
+ 0.8063080495356036,
316
+ 0.0,
317
+ 1.0,
318
+ 0.25,
319
+ 0.25,
320
+ 0.9996130030959752,
321
+ 1.0,
322
+ 0.0,
323
+ 0.0,
324
+ 0.9918730650154799,
325
+ 0.9918730650154799,
326
+ 0.9489164086687306,
327
+ 1.0,
328
+ 0.9169891640866873,
329
+ 0.0,
330
+ 0.9837461300309598,
331
+ 0.9986455108359134,
332
+ 0.0
333
+ ],
334
+ "pass@10": [
335
+ 1.0,
336
+ 0.0,
337
+ 0.9996427720885925,
338
+ 1.0,
339
+ 1.0,
340
+ 0.0,
341
+ 0.8947368421052632,
342
+ 1.0,
343
+ 1.0,
344
+ 0.9996427720885925,
345
+ 0.0,
346
+ 1.0,
347
+ 1.0,
348
+ 1.0,
349
+ 0.9945820433436533,
350
+ 1.0,
351
+ 0.9945820433436533,
352
+ 1.0,
353
+ 1.0,
354
+ 0.0,
355
+ 1.0,
356
+ 1.0,
357
+ 0.9999945874558878,
358
+ 1.0,
359
+ 0.0,
360
+ 1.0,
361
+ 0.5,
362
+ 1.0,
363
+ 1.0,
364
+ 1.0,
365
+ 0.9999404620147654,
366
+ 1.0,
367
+ 0.0,
368
+ 0.5,
369
+ 1.0,
370
+ 0.9999404620147654,
371
+ 0.0,
372
+ 0.5,
373
+ 0.0,
374
+ 0.0,
375
+ 1.0,
376
+ 0.0,
377
+ 1.0,
378
+ 1.0,
379
+ 0.9945820433436533,
380
+ 1.0,
381
+ 0.9984520123839009,
382
+ 1.0,
383
+ 0.9984520123839009,
384
+ 0.0,
385
+ 1.0,
386
+ 1.0,
387
+ 0.9999945874558878,
388
+ 1.0,
389
+ 0.9999404620147654,
390
+ 1.0,
391
+ 1.0,
392
+ 1.0,
393
+ 1.0,
394
+ 0.763157894736842,
395
+ 1.0,
396
+ 0.9837461300309598,
397
+ 0.9837461300309598,
398
+ 0.8947368421052632,
399
+ 1.0,
400
+ 0.763157894736842,
401
+ 1.0,
402
+ 0.0,
403
+ 0.9999404620147654,
404
+ 0.9837461300309598,
405
+ 0.763157894736842,
406
+ 0.956656346749226,
407
+ 1.0,
408
+ 0.0,
409
+ 0.0,
410
+ 0.0,
411
+ 0.0,
412
+ 0.0,
413
+ 0.9996427720885925,
414
+ 1.0,
415
+ 0.956656346749226,
416
+ 0.956656346749226,
417
+ 0.956656346749226,
418
+ 0.0,
419
+ 0.0,
420
+ 1.0,
421
+ 1.0,
422
+ 0.5,
423
+ 0.5,
424
+ 0.763157894736842,
425
+ 0.9945820433436533,
426
+ 0.0,
427
+ 0.9999404620147654,
428
+ 0.0,
429
+ 0.9945820433436533,
430
+ 0.5,
431
+ 1.0,
432
+ 0.763157894736842,
433
+ 0.763157894736842,
434
+ 0.0,
435
+ 0.5,
436
+ 0.0,
437
+ 0.5,
438
+ 0.0,
439
+ 0.9837461300309598,
440
+ 0.8947368421052632,
441
+ 0.0,
442
+ 1.0,
443
+ 0.0,
444
+ 0.5,
445
+ 0.0,
446
+ 0.8947368421052632,
447
+ 1.0,
448
+ 0.0,
449
+ 0.8947368421052632,
450
+ 0.0,
451
+ 1.0,
452
+ 0.5,
453
+ 0.5,
454
+ 0.0,
455
+ 0.0,
456
+ 0.5,
457
+ 0.763157894736842,
458
+ 0.9996427720885925,
459
+ 0.956656346749226,
460
+ 0.0,
461
+ 0.0,
462
+ 0.9999404620147654,
463
+ 0.5,
464
+ 0.0,
465
+ 0.0,
466
+ 0.0,
467
+ 0.0,
468
+ 0.0,
469
+ 0.0,
470
+ 0.0,
471
+ 0.8947368421052632,
472
+ 0.0,
473
+ 0.763157894736842,
474
+ 0.0,
475
+ 0.0,
476
+ 0.0,
477
+ 0.0,
478
+ 1.0,
479
+ 0.0,
480
+ 0.0,
481
+ 0.9837461300309598,
482
+ 0.0,
483
+ 1.0,
484
+ 0.5,
485
+ 0.5,
486
+ 1.0,
487
+ 1.0,
488
+ 0.0,
489
+ 0.0,
490
+ 1.0,
491
+ 1.0,
492
+ 0.9996427720885925,
493
+ 1.0,
494
+ 0.9984520123839009,
495
+ 0.0,
496
+ 0.9999945874558878,
497
+ 1.0,
498
+ 0.0
499
+ ]
500
+ }
data/coding/humaneval/json/2.json ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pass@1": [
3
+ 0.44999999999999984,
4
+ 0.0,
5
+ 0.44999999999999984,
6
+ 1.0,
7
+ 0.95,
8
+ 0.0,
9
+ 0.25,
10
+ 1.0,
11
+ 1.0,
12
+ 0.25,
13
+ 0.0,
14
+ 0.7,
15
+ 1.0,
16
+ 0.4999999999999999,
17
+ 0.09999999999999998,
18
+ 0.75,
19
+ 0.6000000000000001,
20
+ 0.75,
21
+ 0.75,
22
+ 0.0,
23
+ 0.6000000000000001,
24
+ 0.8999999999999999,
25
+ 0.44999999999999984,
26
+ 0.75,
27
+ 0.09999999999999998,
28
+ 1.0,
29
+ 0.0,
30
+ 1.0,
31
+ 0.65,
32
+ 0.8999999999999999,
33
+ 0.65,
34
+ 0.65,
35
+ 0.0,
36
+ 0.0,
37
+ 0.6000000000000001,
38
+ 0.44999999999999984,
39
+ 0.25,
40
+ 0.15000000000000002,
41
+ 0.0,
42
+ 0.15000000000000002,
43
+ 0.7,
44
+ 0.09999999999999998,
45
+ 0.4999999999999999,
46
+ 0.95,
47
+ 0.25,
48
+ 1.0,
49
+ 0.4999999999999999,
50
+ 0.95,
51
+ 0.3500000000000001,
52
+ 0.0,
53
+ 1.0,
54
+ 0.85,
55
+ 0.65,
56
+ 0.8999999999999999,
57
+ 0.65,
58
+ 0.65,
59
+ 0.4999999999999999,
60
+ 0.44999999999999984,
61
+ 0.8999999999999999,
62
+ 0.4,
63
+ 0.25,
64
+ 0.30000000000000004,
65
+ 0.20000000000000007,
66
+ 0.25,
67
+ 0.7999999999999999,
68
+ 0.09999999999999998,
69
+ 0.75,
70
+ 0.0,
71
+ 0.44999999999999984,
72
+ 0.09999999999999998,
73
+ 0.09999999999999998,
74
+ 0.44999999999999984,
75
+ 0.5499999999999998,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.050000000000000044,
80
+ 0.0,
81
+ 0.4999999999999999,
82
+ 0.7,
83
+ 0.09999999999999998,
84
+ 0.44999999999999984,
85
+ 0.050000000000000044,
86
+ 0.0,
87
+ 0.0,
88
+ 0.30000000000000004,
89
+ 0.25,
90
+ 0.0,
91
+ 0.25,
92
+ 0.050000000000000044,
93
+ 0.25,
94
+ 0.0,
95
+ 0.6000000000000001,
96
+ 0.0,
97
+ 0.25,
98
+ 0.15000000000000002,
99
+ 0.4999999999999999,
100
+ 0.15000000000000002,
101
+ 0.25,
102
+ 0.0,
103
+ 0.20000000000000007,
104
+ 0.0,
105
+ 0.09999999999999998,
106
+ 0.0,
107
+ 0.30000000000000004,
108
+ 0.20000000000000007,
109
+ 0.0,
110
+ 1.0,
111
+ 0.050000000000000044,
112
+ 0.0,
113
+ 0.0,
114
+ 0.050000000000000044,
115
+ 0.65,
116
+ 0.050000000000000044,
117
+ 0.15000000000000002,
118
+ 0.0,
119
+ 0.85,
120
+ 0.050000000000000044,
121
+ 0.050000000000000044,
122
+ 0.0,
123
+ 0.0,
124
+ 0.09999999999999998,
125
+ 0.09999999999999998,
126
+ 0.3500000000000001,
127
+ 0.0,
128
+ 0.0,
129
+ 0.0,
130
+ 0.3500000000000001,
131
+ 0.09999999999999998,
132
+ 0.0,
133
+ 0.0,
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.050000000000000044,
138
+ 0.0,
139
+ 0.15000000000000002,
140
+ 0.0,
141
+ 0.20000000000000007,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.7,
147
+ 0.20000000000000007,
148
+ 0.0,
149
+ 0.050000000000000044,
150
+ 0.09999999999999998,
151
+ 0.85,
152
+ 0.0,
153
+ 0.0,
154
+ 0.4999999999999999,
155
+ 0.8999999999999999,
156
+ 0.15000000000000002,
157
+ 0.050000000000000044,
158
+ 0.6000000000000001,
159
+ 0.6000000000000001,
160
+ 0.44999999999999984,
161
+ 0.85,
162
+ 0.4,
163
+ 0.0,
164
+ 0.4999999999999999,
165
+ 0.09999999999999998,
166
+ 0.0
167
+ ],
168
+ "pass@5": [
169
+ 0.9702012383900929,
170
+ 0.0,
171
+ 0.9702012383900929,
172
+ 1.0,
173
+ 1.0,
174
+ 0.0,
175
+ 0.8063080495356036,
176
+ 1.0,
177
+ 1.0,
178
+ 0.8063080495356036,
179
+ 0.0,
180
+ 0.9996130030959752,
181
+ 1.0,
182
+ 0.9837461300309598,
183
+ 0.4473684210526315,
184
+ 0.9999355005159959,
185
+ 0.9963880288957688,
186
+ 0.9999355005159959,
187
+ 0.9999355005159959,
188
+ 0.0,
189
+ 0.9963880288957688,
190
+ 1.0,
191
+ 0.9702012383900929,
192
+ 0.9999355005159959,
193
+ 0.4473684210526315,
194
+ 1.0,
195
+ 0.0,
196
+ 1.0,
197
+ 0.9986455108359134,
198
+ 1.0,
199
+ 0.9986455108359134,
200
+ 0.9986455108359134,
201
+ 0.0,
202
+ 0.0,
203
+ 0.9963880288957688,
204
+ 0.9702012383900929,
205
+ 0.8063080495356036,
206
+ 0.6008771929824561,
207
+ 0.0,
208
+ 0.6008771929824561,
209
+ 0.9996130030959752,
210
+ 0.4473684210526315,
211
+ 0.9837461300309598,
212
+ 1.0,
213
+ 0.8063080495356036,
214
+ 1.0,
215
+ 0.9837461300309598,
216
+ 1.0,
217
+ 0.9169891640866873,
218
+ 0.0,
219
+ 1.0,
220
+ 1.0,
221
+ 0.9986455108359134,
222
+ 1.0,
223
+ 0.9986455108359134,
224
+ 0.9986455108359134,
225
+ 0.9837461300309598,
226
+ 0.9702012383900929,
227
+ 1.0,
228
+ 0.9489164086687306,
229
+ 0.8063080495356036,
230
+ 0.8708720330237358,
231
+ 0.7182662538699691,
232
+ 0.8063080495356036,
233
+ 1.0,
234
+ 0.4473684210526315,
235
+ 0.9999355005159959,
236
+ 0.0,
237
+ 0.9702012383900929,
238
+ 0.4473684210526315,
239
+ 0.4473684210526315,
240
+ 0.9702012383900929,
241
+ 0.9918730650154799,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.25,
246
+ 0.0,
247
+ 0.9837461300309598,
248
+ 0.9996130030959752,
249
+ 0.4473684210526315,
250
+ 0.9702012383900929,
251
+ 0.25,
252
+ 0.0,
253
+ 0.0,
254
+ 0.8708720330237358,
255
+ 0.8063080495356036,
256
+ 0.0,
257
+ 0.8063080495356036,
258
+ 0.25,
259
+ 0.8063080495356036,
260
+ 0.0,
261
+ 0.9963880288957688,
262
+ 0.0,
263
+ 0.8063080495356036,
264
+ 0.6008771929824561,
265
+ 0.9837461300309598,
266
+ 0.6008771929824561,
267
+ 0.8063080495356036,
268
+ 0.0,
269
+ 0.7182662538699691,
270
+ 0.0,
271
+ 0.4473684210526315,
272
+ 0.0,
273
+ 0.8708720330237358,
274
+ 0.7182662538699691,
275
+ 0.0,
276
+ 1.0,
277
+ 0.25,
278
+ 0.0,
279
+ 0.0,
280
+ 0.25,
281
+ 0.9986455108359134,
282
+ 0.25,
283
+ 0.6008771929824561,
284
+ 0.0,
285
+ 1.0,
286
+ 0.25,
287
+ 0.25,
288
+ 0.0,
289
+ 0.0,
290
+ 0.4473684210526315,
291
+ 0.4473684210526315,
292
+ 0.9169891640866873,
293
+ 0.0,
294
+ 0.0,
295
+ 0.0,
296
+ 0.9169891640866873,
297
+ 0.4473684210526315,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.0,
303
+ 0.25,
304
+ 0.0,
305
+ 0.6008771929824561,
306
+ 0.0,
307
+ 0.7182662538699691,
308
+ 0.0,
309
+ 0.0,
310
+ 0.0,
311
+ 0.0,
312
+ 0.9996130030959752,
313
+ 0.7182662538699691,
314
+ 0.0,
315
+ 0.25,
316
+ 0.4473684210526315,
317
+ 1.0,
318
+ 0.0,
319
+ 0.0,
320
+ 0.9837461300309598,
321
+ 1.0,
322
+ 0.6008771929824561,
323
+ 0.25,
324
+ 0.9963880288957688,
325
+ 0.9963880288957688,
326
+ 0.9702012383900929,
327
+ 1.0,
328
+ 0.9489164086687306,
329
+ 0.0,
330
+ 0.9837461300309598,
331
+ 0.4473684210526315,
332
+ 0.0
333
+ ],
334
+ "pass@10": [
335
+ 0.9999404620147654,
336
+ 0.0,
337
+ 0.9999404620147654,
338
+ 1.0,
339
+ 1.0,
340
+ 0.0,
341
+ 0.9837461300309598,
342
+ 1.0,
343
+ 1.0,
344
+ 0.9837461300309598,
345
+ 0.0,
346
+ 1.0,
347
+ 1.0,
348
+ 0.9999945874558878,
349
+ 0.763157894736842,
350
+ 1.0,
351
+ 1.0,
352
+ 1.0,
353
+ 1.0,
354
+ 0.0,
355
+ 1.0,
356
+ 1.0,
357
+ 0.9999404620147654,
358
+ 1.0,
359
+ 0.763157894736842,
360
+ 1.0,
361
+ 0.0,
362
+ 1.0,
363
+ 1.0,
364
+ 1.0,
365
+ 1.0,
366
+ 1.0,
367
+ 0.0,
368
+ 0.0,
369
+ 1.0,
370
+ 0.9999404620147654,
371
+ 0.9837461300309598,
372
+ 0.8947368421052632,
373
+ 0.0,
374
+ 0.8947368421052632,
375
+ 1.0,
376
+ 0.763157894736842,
377
+ 0.9999945874558878,
378
+ 1.0,
379
+ 0.9837461300309598,
380
+ 1.0,
381
+ 0.9999945874558878,
382
+ 1.0,
383
+ 0.9984520123839009,
384
+ 0.0,
385
+ 1.0,
386
+ 1.0,
387
+ 1.0,
388
+ 1.0,
389
+ 1.0,
390
+ 1.0,
391
+ 0.9999945874558878,
392
+ 0.9999404620147654,
393
+ 1.0,
394
+ 0.9996427720885925,
395
+ 0.9837461300309598,
396
+ 0.9945820433436533,
397
+ 0.956656346749226,
398
+ 0.9837461300309598,
399
+ 1.0,
400
+ 0.763157894736842,
401
+ 1.0,
402
+ 0.0,
403
+ 0.9999404620147654,
404
+ 0.763157894736842,
405
+ 0.763157894736842,
406
+ 0.9999404620147654,
407
+ 1.0,
408
+ 0.0,
409
+ 0.0,
410
+ 0.0,
411
+ 0.5,
412
+ 0.0,
413
+ 0.9999945874558878,
414
+ 1.0,
415
+ 0.763157894736842,
416
+ 0.9999404620147654,
417
+ 0.5,
418
+ 0.0,
419
+ 0.0,
420
+ 0.9945820433436533,
421
+ 0.9837461300309598,
422
+ 0.0,
423
+ 0.9837461300309598,
424
+ 0.5,
425
+ 0.9837461300309598,
426
+ 0.0,
427
+ 1.0,
428
+ 0.0,
429
+ 0.9837461300309598,
430
+ 0.8947368421052632,
431
+ 0.9999945874558878,
432
+ 0.8947368421052632,
433
+ 0.9837461300309598,
434
+ 0.0,
435
+ 0.956656346749226,
436
+ 0.0,
437
+ 0.763157894736842,
438
+ 0.0,
439
+ 0.9945820433436533,
440
+ 0.956656346749226,
441
+ 0.0,
442
+ 1.0,
443
+ 0.5,
444
+ 0.0,
445
+ 0.0,
446
+ 0.5,
447
+ 1.0,
448
+ 0.5,
449
+ 0.8947368421052632,
450
+ 0.0,
451
+ 1.0,
452
+ 0.5,
453
+ 0.5,
454
+ 0.0,
455
+ 0.0,
456
+ 0.763157894736842,
457
+ 0.763157894736842,
458
+ 0.9984520123839009,
459
+ 0.0,
460
+ 0.0,
461
+ 0.0,
462
+ 0.9984520123839009,
463
+ 0.763157894736842,
464
+ 0.0,
465
+ 0.0,
466
+ 0.0,
467
+ 0.0,
468
+ 0.0,
469
+ 0.5,
470
+ 0.0,
471
+ 0.8947368421052632,
472
+ 0.0,
473
+ 0.956656346749226,
474
+ 0.0,
475
+ 0.0,
476
+ 0.0,
477
+ 0.0,
478
+ 1.0,
479
+ 0.956656346749226,
480
+ 0.0,
481
+ 0.5,
482
+ 0.763157894736842,
483
+ 1.0,
484
+ 0.0,
485
+ 0.0,
486
+ 0.9999945874558878,
487
+ 1.0,
488
+ 0.8947368421052632,
489
+ 0.5,
490
+ 1.0,
491
+ 1.0,
492
+ 0.9999404620147654,
493
+ 1.0,
494
+ 0.9996427720885925,
495
+ 0.0,
496
+ 0.9999945874558878,
497
+ 0.763157894736842,
498
+ 0.0
499
+ ]
500
+ }
data/coding/humaneval/json/3.json ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pass@1": [
3
+ 0.44999999999999984,
4
+ 0.0,
5
+ 0.25,
6
+ 1.0,
7
+ 1.0,
8
+ 0.0,
9
+ 0.15000000000000002,
10
+ 0.95,
11
+ 1.0,
12
+ 0.25,
13
+ 0.0,
14
+ 0.7,
15
+ 1.0,
16
+ 0.4,
17
+ 0.050000000000000044,
18
+ 0.8999999999999999,
19
+ 0.4,
20
+ 0.85,
21
+ 0.7,
22
+ 0.0,
23
+ 0.6000000000000001,
24
+ 0.8999999999999999,
25
+ 0.3500000000000001,
26
+ 0.75,
27
+ 0.0,
28
+ 1.0,
29
+ 0.050000000000000044,
30
+ 0.95,
31
+ 0.85,
32
+ 0.95,
33
+ 0.75,
34
+ 0.7,
35
+ 0.0,
36
+ 0.050000000000000044,
37
+ 0.65,
38
+ 0.65,
39
+ 0.3500000000000001,
40
+ 0.09999999999999998,
41
+ 0.0,
42
+ 0.09999999999999998,
43
+ 0.65,
44
+ 0.050000000000000044,
45
+ 0.7999999999999999,
46
+ 1.0,
47
+ 0.050000000000000044,
48
+ 0.85,
49
+ 0.4999999999999999,
50
+ 0.7,
51
+ 0.44999999999999984,
52
+ 0.050000000000000044,
53
+ 1.0,
54
+ 0.85,
55
+ 0.7999999999999999,
56
+ 0.95,
57
+ 0.8999999999999999,
58
+ 0.8999999999999999,
59
+ 0.4999999999999999,
60
+ 0.25,
61
+ 0.75,
62
+ 0.65,
63
+ 0.4,
64
+ 0.3500000000000001,
65
+ 0.20000000000000007,
66
+ 0.44999999999999984,
67
+ 0.65,
68
+ 0.09999999999999998,
69
+ 0.7999999999999999,
70
+ 0.0,
71
+ 0.4,
72
+ 0.0,
73
+ 0.0,
74
+ 0.25,
75
+ 0.4,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.0,
80
+ 0.0,
81
+ 0.3500000000000001,
82
+ 0.7,
83
+ 0.09999999999999998,
84
+ 0.25,
85
+ 0.09999999999999998,
86
+ 0.0,
87
+ 0.0,
88
+ 0.3500000000000001,
89
+ 0.5499999999999998,
90
+ 0.050000000000000044,
91
+ 0.3500000000000001,
92
+ 0.09999999999999998,
93
+ 0.09999999999999998,
94
+ 0.0,
95
+ 0.75,
96
+ 0.0,
97
+ 0.20000000000000007,
98
+ 0.050000000000000044,
99
+ 0.25,
100
+ 0.09999999999999998,
101
+ 0.5499999999999998,
102
+ 0.050000000000000044,
103
+ 0.15000000000000002,
104
+ 0.0,
105
+ 0.09999999999999998,
106
+ 0.0,
107
+ 0.050000000000000044,
108
+ 0.15000000000000002,
109
+ 0.0,
110
+ 1.0,
111
+ 0.0,
112
+ 0.0,
113
+ 0.0,
114
+ 0.050000000000000044,
115
+ 0.4,
116
+ 0.0,
117
+ 0.25,
118
+ 0.0,
119
+ 0.95,
120
+ 0.20000000000000007,
121
+ 0.050000000000000044,
122
+ 0.0,
123
+ 0.0,
124
+ 0.09999999999999998,
125
+ 0.0,
126
+ 0.25,
127
+ 0.0,
128
+ 0.0,
129
+ 0.0,
130
+ 0.4,
131
+ 0.15000000000000002,
132
+ 0.0,
133
+ 0.0,
134
+ 0.050000000000000044,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.0,
139
+ 0.09999999999999998,
140
+ 0.0,
141
+ 0.050000000000000044,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.8999999999999999,
147
+ 0.050000000000000044,
148
+ 0.0,
149
+ 0.0,
150
+ 0.050000000000000044,
151
+ 0.8999999999999999,
152
+ 0.0,
153
+ 0.09999999999999998,
154
+ 0.3500000000000001,
155
+ 1.0,
156
+ 0.09999999999999998,
157
+ 0.25,
158
+ 0.65,
159
+ 0.95,
160
+ 0.09999999999999998,
161
+ 0.85,
162
+ 0.20000000000000007,
163
+ 0.0,
164
+ 0.6000000000000001,
165
+ 0.20000000000000007,
166
+ 0.0
167
+ ],
168
+ "pass@5": [
169
+ 0.9702012383900929,
170
+ 0.0,
171
+ 0.8063080495356036,
172
+ 1.0,
173
+ 1.0,
174
+ 0.0,
175
+ 0.6008771929824561,
176
+ 1.0,
177
+ 1.0,
178
+ 0.8063080495356036,
179
+ 0.0,
180
+ 0.9996130030959752,
181
+ 1.0,
182
+ 0.9489164086687306,
183
+ 0.25,
184
+ 1.0,
185
+ 0.9489164086687306,
186
+ 1.0,
187
+ 0.9996130030959752,
188
+ 0.0,
189
+ 0.9963880288957688,
190
+ 1.0,
191
+ 0.9169891640866873,
192
+ 0.9999355005159959,
193
+ 0.0,
194
+ 1.0,
195
+ 0.25,
196
+ 1.0,
197
+ 1.0,
198
+ 1.0,
199
+ 0.9999355005159959,
200
+ 0.9996130030959752,
201
+ 0.0,
202
+ 0.25,
203
+ 0.9986455108359134,
204
+ 0.9986455108359134,
205
+ 0.9169891640866873,
206
+ 0.4473684210526315,
207
+ 0.0,
208
+ 0.4473684210526315,
209
+ 0.9986455108359134,
210
+ 0.25,
211
+ 1.0,
212
+ 1.0,
213
+ 0.25,
214
+ 1.0,
215
+ 0.9837461300309598,
216
+ 0.9996130030959752,
217
+ 0.9702012383900929,
218
+ 0.25,
219
+ 1.0,
220
+ 1.0,
221
+ 1.0,
222
+ 1.0,
223
+ 1.0,
224
+ 1.0,
225
+ 0.9837461300309598,
226
+ 0.8063080495356036,
227
+ 0.9999355005159959,
228
+ 0.9986455108359134,
229
+ 0.9489164086687306,
230
+ 0.9169891640866873,
231
+ 0.7182662538699691,
232
+ 0.9702012383900929,
233
+ 0.9986455108359134,
234
+ 0.4473684210526315,
235
+ 1.0,
236
+ 0.0,
237
+ 0.9489164086687306,
238
+ 0.0,
239
+ 0.0,
240
+ 0.8063080495356036,
241
+ 0.9489164086687306,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.0,
246
+ 0.0,
247
+ 0.9169891640866873,
248
+ 0.9996130030959752,
249
+ 0.4473684210526315,
250
+ 0.8063080495356036,
251
+ 0.4473684210526315,
252
+ 0.0,
253
+ 0.0,
254
+ 0.9169891640866873,
255
+ 0.9918730650154799,
256
+ 0.25,
257
+ 0.9169891640866873,
258
+ 0.4473684210526315,
259
+ 0.4473684210526315,
260
+ 0.0,
261
+ 0.9999355005159959,
262
+ 0.0,
263
+ 0.7182662538699691,
264
+ 0.25,
265
+ 0.8063080495356036,
266
+ 0.4473684210526315,
267
+ 0.9918730650154799,
268
+ 0.25,
269
+ 0.6008771929824561,
270
+ 0.0,
271
+ 0.4473684210526315,
272
+ 0.0,
273
+ 0.25,
274
+ 0.6008771929824561,
275
+ 0.0,
276
+ 1.0,
277
+ 0.0,
278
+ 0.0,
279
+ 0.0,
280
+ 0.25,
281
+ 0.9489164086687306,
282
+ 0.0,
283
+ 0.8063080495356036,
284
+ 0.0,
285
+ 1.0,
286
+ 0.7182662538699691,
287
+ 0.25,
288
+ 0.0,
289
+ 0.0,
290
+ 0.4473684210526315,
291
+ 0.0,
292
+ 0.8063080495356036,
293
+ 0.0,
294
+ 0.0,
295
+ 0.0,
296
+ 0.9489164086687306,
297
+ 0.6008771929824561,
298
+ 0.0,
299
+ 0.0,
300
+ 0.25,
301
+ 0.0,
302
+ 0.0,
303
+ 0.0,
304
+ 0.0,
305
+ 0.4473684210526315,
306
+ 0.0,
307
+ 0.25,
308
+ 0.0,
309
+ 0.0,
310
+ 0.0,
311
+ 0.0,
312
+ 1.0,
313
+ 0.25,
314
+ 0.0,
315
+ 0.0,
316
+ 0.25,
317
+ 1.0,
318
+ 0.0,
319
+ 0.4473684210526315,
320
+ 0.9169891640866873,
321
+ 1.0,
322
+ 0.4473684210526315,
323
+ 0.8063080495356036,
324
+ 0.9986455108359134,
325
+ 1.0,
326
+ 0.4473684210526315,
327
+ 1.0,
328
+ 0.7182662538699691,
329
+ 0.0,
330
+ 0.9963880288957688,
331
+ 0.7182662538699691,
332
+ 0.0
333
+ ],
334
+ "pass@10": [
335
+ 0.9999404620147654,
336
+ 0.0,
337
+ 0.9837461300309598,
338
+ 1.0,
339
+ 1.0,
340
+ 0.0,
341
+ 0.8947368421052632,
342
+ 1.0,
343
+ 1.0,
344
+ 0.9837461300309598,
345
+ 0.0,
346
+ 1.0,
347
+ 1.0,
348
+ 0.9996427720885925,
349
+ 0.5,
350
+ 1.0,
351
+ 0.9996427720885925,
352
+ 1.0,
353
+ 1.0,
354
+ 0.0,
355
+ 1.0,
356
+ 1.0,
357
+ 0.9984520123839009,
358
+ 1.0,
359
+ 0.0,
360
+ 1.0,
361
+ 0.5,
362
+ 1.0,
363
+ 1.0,
364
+ 1.0,
365
+ 1.0,
366
+ 1.0,
367
+ 0.0,
368
+ 0.5,
369
+ 1.0,
370
+ 1.0,
371
+ 0.9984520123839009,
372
+ 0.763157894736842,
373
+ 0.0,
374
+ 0.763157894736842,
375
+ 1.0,
376
+ 0.5,
377
+ 1.0,
378
+ 1.0,
379
+ 0.5,
380
+ 1.0,
381
+ 0.9999945874558878,
382
+ 1.0,
383
+ 0.9999404620147654,
384
+ 0.5,
385
+ 1.0,
386
+ 1.0,
387
+ 1.0,
388
+ 1.0,
389
+ 1.0,
390
+ 1.0,
391
+ 0.9999945874558878,
392
+ 0.9837461300309598,
393
+ 1.0,
394
+ 1.0,
395
+ 0.9996427720885925,
396
+ 0.9984520123839009,
397
+ 0.956656346749226,
398
+ 0.9999404620147654,
399
+ 1.0,
400
+ 0.763157894736842,
401
+ 1.0,
402
+ 0.0,
403
+ 0.9996427720885925,
404
+ 0.0,
405
+ 0.0,
406
+ 0.9837461300309598,
407
+ 0.9996427720885925,
408
+ 0.0,
409
+ 0.0,
410
+ 0.0,
411
+ 0.0,
412
+ 0.0,
413
+ 0.9984520123839009,
414
+ 1.0,
415
+ 0.763157894736842,
416
+ 0.9837461300309598,
417
+ 0.763157894736842,
418
+ 0.0,
419
+ 0.0,
420
+ 0.9984520123839009,
421
+ 1.0,
422
+ 0.5,
423
+ 0.9984520123839009,
424
+ 0.763157894736842,
425
+ 0.763157894736842,
426
+ 0.0,
427
+ 1.0,
428
+ 0.0,
429
+ 0.956656346749226,
430
+ 0.5,
431
+ 0.9837461300309598,
432
+ 0.763157894736842,
433
+ 1.0,
434
+ 0.5,
435
+ 0.8947368421052632,
436
+ 0.0,
437
+ 0.763157894736842,
438
+ 0.0,
439
+ 0.5,
440
+ 0.8947368421052632,
441
+ 0.0,
442
+ 1.0,
443
+ 0.0,
444
+ 0.0,
445
+ 0.0,
446
+ 0.5,
447
+ 0.9996427720885925,
448
+ 0.0,
449
+ 0.9837461300309598,
450
+ 0.0,
451
+ 1.0,
452
+ 0.956656346749226,
453
+ 0.5,
454
+ 0.0,
455
+ 0.0,
456
+ 0.763157894736842,
457
+ 0.0,
458
+ 0.9837461300309598,
459
+ 0.0,
460
+ 0.0,
461
+ 0.0,
462
+ 0.9996427720885925,
463
+ 0.8947368421052632,
464
+ 0.0,
465
+ 0.0,
466
+ 0.5,
467
+ 0.0,
468
+ 0.0,
469
+ 0.0,
470
+ 0.0,
471
+ 0.763157894736842,
472
+ 0.0,
473
+ 0.5,
474
+ 0.0,
475
+ 0.0,
476
+ 0.0,
477
+ 0.0,
478
+ 1.0,
479
+ 0.5,
480
+ 0.0,
481
+ 0.0,
482
+ 0.5,
483
+ 1.0,
484
+ 0.0,
485
+ 0.763157894736842,
486
+ 0.9984520123839009,
487
+ 1.0,
488
+ 0.763157894736842,
489
+ 0.9837461300309598,
490
+ 1.0,
491
+ 1.0,
492
+ 0.763157894736842,
493
+ 1.0,
494
+ 0.956656346749226,
495
+ 0.0,
496
+ 1.0,
497
+ 0.956656346749226,
498
+ 0.0
499
+ ]
500
+ }
data/coding/humaneval/json/4.json ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pass@1": [
3
+ 0.0,
4
+ 0.4,
5
+ 0.4999999999999999,
6
+ 1.0,
7
+ 0.95,
8
+ 0.0,
9
+ 0.3500000000000001,
10
+ 1.0,
11
+ 0.95,
12
+ 0.44999999999999984,
13
+ 0.0,
14
+ 0.6000000000000001,
15
+ 1.0,
16
+ 0.3500000000000001,
17
+ 0.15000000000000002,
18
+ 0.65,
19
+ 0.25,
20
+ 0.65,
21
+ 0.7999999999999999,
22
+ 0.0,
23
+ 0.65,
24
+ 0.7999999999999999,
25
+ 0.7,
26
+ 0.85,
27
+ 0.050000000000000044,
28
+ 0.95,
29
+ 0.050000000000000044,
30
+ 0.85,
31
+ 0.7,
32
+ 0.8999999999999999,
33
+ 0.75,
34
+ 0.85,
35
+ 0.0,
36
+ 0.0,
37
+ 0.7999999999999999,
38
+ 0.30000000000000004,
39
+ 0.6000000000000001,
40
+ 0.15000000000000002,
41
+ 0.0,
42
+ 0.30000000000000004,
43
+ 0.85,
44
+ 0.0,
45
+ 0.75,
46
+ 0.85,
47
+ 0.30000000000000004,
48
+ 0.8999999999999999,
49
+ 0.44999999999999984,
50
+ 0.75,
51
+ 0.4,
52
+ 0.0,
53
+ 1.0,
54
+ 0.85,
55
+ 0.5499999999999998,
56
+ 0.7999999999999999,
57
+ 0.85,
58
+ 0.7999999999999999,
59
+ 0.4999999999999999,
60
+ 0.20000000000000007,
61
+ 0.75,
62
+ 0.4999999999999999,
63
+ 0.5499999999999998,
64
+ 0.050000000000000044,
65
+ 0.09999999999999998,
66
+ 0.20000000000000007,
67
+ 0.7,
68
+ 0.050000000000000044,
69
+ 0.75,
70
+ 0.0,
71
+ 0.30000000000000004,
72
+ 0.0,
73
+ 0.0,
74
+ 0.4999999999999999,
75
+ 0.3500000000000001,
76
+ 0.0,
77
+ 0.0,
78
+ 0.050000000000000044,
79
+ 0.0,
80
+ 0.09999999999999998,
81
+ 0.3500000000000001,
82
+ 0.65,
83
+ 0.09999999999999998,
84
+ 0.3500000000000001,
85
+ 0.15000000000000002,
86
+ 0.0,
87
+ 0.0,
88
+ 0.4,
89
+ 0.5499999999999998,
90
+ 0.0,
91
+ 0.050000000000000044,
92
+ 0.20000000000000007,
93
+ 0.15000000000000002,
94
+ 0.0,
95
+ 0.4,
96
+ 0.0,
97
+ 0.15000000000000002,
98
+ 0.050000000000000044,
99
+ 0.44999999999999984,
100
+ 0.09999999999999998,
101
+ 0.25,
102
+ 0.0,
103
+ 0.050000000000000044,
104
+ 0.0,
105
+ 0.15000000000000002,
106
+ 0.0,
107
+ 0.20000000000000007,
108
+ 0.25,
109
+ 0.0,
110
+ 0.95,
111
+ 0.0,
112
+ 0.050000000000000044,
113
+ 0.0,
114
+ 0.09999999999999998,
115
+ 0.30000000000000004,
116
+ 0.050000000000000044,
117
+ 0.09999999999999998,
118
+ 0.0,
119
+ 0.85,
120
+ 0.3500000000000001,
121
+ 0.050000000000000044,
122
+ 0.0,
123
+ 0.0,
124
+ 0.15000000000000002,
125
+ 0.050000000000000044,
126
+ 0.3500000000000001,
127
+ 0.0,
128
+ 0.0,
129
+ 0.0,
130
+ 0.30000000000000004,
131
+ 0.20000000000000007,
132
+ 0.0,
133
+ 0.0,
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.050000000000000044,
139
+ 0.30000000000000004,
140
+ 0.0,
141
+ 0.09999999999999998,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.4999999999999999,
147
+ 0.050000000000000044,
148
+ 0.0,
149
+ 0.25,
150
+ 0.050000000000000044,
151
+ 0.85,
152
+ 0.0,
153
+ 0.0,
154
+ 0.4,
155
+ 0.85,
156
+ 0.25,
157
+ 0.15000000000000002,
158
+ 0.65,
159
+ 0.6000000000000001,
160
+ 0.25,
161
+ 0.7,
162
+ 0.050000000000000044,
163
+ 0.0,
164
+ 0.4999999999999999,
165
+ 0.3500000000000001,
166
+ 0.0
167
+ ],
168
+ "pass@5": [
169
+ 0.0,
170
+ 0.9489164086687306,
171
+ 0.9837461300309598,
172
+ 1.0,
173
+ 1.0,
174
+ 0.0,
175
+ 0.9169891640866873,
176
+ 1.0,
177
+ 1.0,
178
+ 0.9702012383900929,
179
+ 0.0,
180
+ 0.9963880288957688,
181
+ 1.0,
182
+ 0.9169891640866873,
183
+ 0.6008771929824561,
184
+ 0.9986455108359134,
185
+ 0.8063080495356036,
186
+ 0.9986455108359134,
187
+ 1.0,
188
+ 0.0,
189
+ 0.9986455108359134,
190
+ 1.0,
191
+ 0.9996130030959752,
192
+ 1.0,
193
+ 0.25,
194
+ 1.0,
195
+ 0.25,
196
+ 1.0,
197
+ 0.9996130030959752,
198
+ 1.0,
199
+ 0.9999355005159959,
200
+ 1.0,
201
+ 0.0,
202
+ 0.0,
203
+ 1.0,
204
+ 0.8708720330237358,
205
+ 0.9963880288957688,
206
+ 0.6008771929824561,
207
+ 0.0,
208
+ 0.8708720330237358,
209
+ 1.0,
210
+ 0.0,
211
+ 0.9999355005159959,
212
+ 1.0,
213
+ 0.8708720330237358,
214
+ 1.0,
215
+ 0.9702012383900929,
216
+ 0.9999355005159959,
217
+ 0.9489164086687306,
218
+ 0.0,
219
+ 1.0,
220
+ 1.0,
221
+ 0.9918730650154799,
222
+ 1.0,
223
+ 1.0,
224
+ 1.0,
225
+ 0.9837461300309598,
226
+ 0.7182662538699691,
227
+ 0.9999355005159959,
228
+ 0.9837461300309598,
229
+ 0.9918730650154799,
230
+ 0.25,
231
+ 0.4473684210526315,
232
+ 0.7182662538699691,
233
+ 0.9996130030959752,
234
+ 0.25,
235
+ 0.9999355005159959,
236
+ 0.0,
237
+ 0.8708720330237358,
238
+ 0.0,
239
+ 0.0,
240
+ 0.9837461300309598,
241
+ 0.9169891640866873,
242
+ 0.0,
243
+ 0.0,
244
+ 0.25,
245
+ 0.0,
246
+ 0.4473684210526315,
247
+ 0.9169891640866873,
248
+ 0.9986455108359134,
249
+ 0.4473684210526315,
250
+ 0.9169891640866873,
251
+ 0.6008771929824561,
252
+ 0.0,
253
+ 0.0,
254
+ 0.9489164086687306,
255
+ 0.9918730650154799,
256
+ 0.0,
257
+ 0.25,
258
+ 0.7182662538699691,
259
+ 0.6008771929824561,
260
+ 0.0,
261
+ 0.9489164086687306,
262
+ 0.0,
263
+ 0.6008771929824561,
264
+ 0.25,
265
+ 0.9702012383900929,
266
+ 0.4473684210526315,
267
+ 0.8063080495356036,
268
+ 0.0,
269
+ 0.25,
270
+ 0.0,
271
+ 0.6008771929824561,
272
+ 0.0,
273
+ 0.7182662538699691,
274
+ 0.8063080495356036,
275
+ 0.0,
276
+ 1.0,
277
+ 0.0,
278
+ 0.25,
279
+ 0.0,
280
+ 0.4473684210526315,
281
+ 0.8708720330237358,
282
+ 0.25,
283
+ 0.4473684210526315,
284
+ 0.0,
285
+ 1.0,
286
+ 0.9169891640866873,
287
+ 0.25,
288
+ 0.0,
289
+ 0.0,
290
+ 0.6008771929824561,
291
+ 0.25,
292
+ 0.9169891640866873,
293
+ 0.0,
294
+ 0.0,
295
+ 0.0,
296
+ 0.8708720330237358,
297
+ 0.7182662538699691,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.0,
303
+ 0.0,
304
+ 0.25,
305
+ 0.8708720330237358,
306
+ 0.0,
307
+ 0.4473684210526315,
308
+ 0.0,
309
+ 0.0,
310
+ 0.0,
311
+ 0.0,
312
+ 0.9837461300309598,
313
+ 0.25,
314
+ 0.0,
315
+ 0.8063080495356036,
316
+ 0.25,
317
+ 1.0,
318
+ 0.0,
319
+ 0.0,
320
+ 0.9489164086687306,
321
+ 1.0,
322
+ 0.8063080495356036,
323
+ 0.6008771929824561,
324
+ 0.9986455108359134,
325
+ 0.9963880288957688,
326
+ 0.8063080495356036,
327
+ 0.9996130030959752,
328
+ 0.25,
329
+ 0.0,
330
+ 0.9837461300309598,
331
+ 0.9169891640866873,
332
+ 0.0
333
+ ],
334
+ "pass@10": [
335
+ 0.0,
336
+ 0.9996427720885925,
337
+ 0.9999945874558878,
338
+ 1.0,
339
+ 1.0,
340
+ 0.0,
341
+ 0.9984520123839009,
342
+ 1.0,
343
+ 1.0,
344
+ 0.9999404620147654,
345
+ 0.0,
346
+ 1.0,
347
+ 1.0,
348
+ 0.9984520123839009,
349
+ 0.8947368421052632,
350
+ 1.0,
351
+ 0.9837461300309598,
352
+ 1.0,
353
+ 1.0,
354
+ 0.0,
355
+ 1.0,
356
+ 1.0,
357
+ 1.0,
358
+ 1.0,
359
+ 0.5,
360
+ 1.0,
361
+ 0.5,
362
+ 1.0,
363
+ 1.0,
364
+ 1.0,
365
+ 1.0,
366
+ 1.0,
367
+ 0.0,
368
+ 0.0,
369
+ 1.0,
370
+ 0.9945820433436533,
371
+ 1.0,
372
+ 0.8947368421052632,
373
+ 0.0,
374
+ 0.9945820433436533,
375
+ 1.0,
376
+ 0.0,
377
+ 1.0,
378
+ 1.0,
379
+ 0.9945820433436533,
380
+ 1.0,
381
+ 0.9999404620147654,
382
+ 1.0,
383
+ 0.9996427720885925,
384
+ 0.0,
385
+ 1.0,
386
+ 1.0,
387
+ 1.0,
388
+ 1.0,
389
+ 1.0,
390
+ 1.0,
391
+ 0.9999945874558878,
392
+ 0.956656346749226,
393
+ 1.0,
394
+ 0.9999945874558878,
395
+ 1.0,
396
+ 0.5,
397
+ 0.763157894736842,
398
+ 0.956656346749226,
399
+ 1.0,
400
+ 0.5,
401
+ 1.0,
402
+ 0.0,
403
+ 0.9945820433436533,
404
+ 0.0,
405
+ 0.0,
406
+ 0.9999945874558878,
407
+ 0.9984520123839009,
408
+ 0.0,
409
+ 0.0,
410
+ 0.5,
411
+ 0.0,
412
+ 0.763157894736842,
413
+ 0.9984520123839009,
414
+ 1.0,
415
+ 0.763157894736842,
416
+ 0.9984520123839009,
417
+ 0.8947368421052632,
418
+ 0.0,
419
+ 0.0,
420
+ 0.9996427720885925,
421
+ 1.0,
422
+ 0.0,
423
+ 0.5,
424
+ 0.956656346749226,
425
+ 0.8947368421052632,
426
+ 0.0,
427
+ 0.9996427720885925,
428
+ 0.0,
429
+ 0.8947368421052632,
430
+ 0.5,
431
+ 0.9999404620147654,
432
+ 0.763157894736842,
433
+ 0.9837461300309598,
434
+ 0.0,
435
+ 0.5,
436
+ 0.0,
437
+ 0.8947368421052632,
438
+ 0.0,
439
+ 0.956656346749226,
440
+ 0.9837461300309598,
441
+ 0.0,
442
+ 1.0,
443
+ 0.0,
444
+ 0.5,
445
+ 0.0,
446
+ 0.763157894736842,
447
+ 0.9945820433436533,
448
+ 0.5,
449
+ 0.763157894736842,
450
+ 0.0,
451
+ 1.0,
452
+ 0.9984520123839009,
453
+ 0.5,
454
+ 0.0,
455
+ 0.0,
456
+ 0.8947368421052632,
457
+ 0.5,
458
+ 0.9984520123839009,
459
+ 0.0,
460
+ 0.0,
461
+ 0.0,
462
+ 0.9945820433436533,
463
+ 0.956656346749226,
464
+ 0.0,
465
+ 0.0,
466
+ 0.0,
467
+ 0.0,
468
+ 0.0,
469
+ 0.0,
470
+ 0.5,
471
+ 0.9945820433436533,
472
+ 0.0,
473
+ 0.763157894736842,
474
+ 0.0,
475
+ 0.0,
476
+ 0.0,
477
+ 0.0,
478
+ 0.9999945874558878,
479
+ 0.5,
480
+ 0.0,
481
+ 0.9837461300309598,
482
+ 0.5,
483
+ 1.0,
484
+ 0.0,
485
+ 0.0,
486
+ 0.9996427720885925,
487
+ 1.0,
488
+ 0.9837461300309598,
489
+ 0.8947368421052632,
490
+ 1.0,
491
+ 1.0,
492
+ 0.9837461300309598,
493
+ 1.0,
494
+ 0.5,
495
+ 0.0,
496
+ 0.9999945874558878,
497
+ 0.9984520123839009,
498
+ 0.0
499
+ ]
500
+ }
data/coding/humaneval/json/5.json ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "pass@1": [
3
+ 0.5499999999999998,
4
+ 0.0,
5
+ 0.44999999999999984,
6
+ 1.0,
7
+ 1.0,
8
+ 0.0,
9
+ 0.15000000000000002,
10
+ 0.95,
11
+ 1.0,
12
+ 0.25,
13
+ 0.0,
14
+ 0.7,
15
+ 1.0,
16
+ 0.65,
17
+ 0.20000000000000007,
18
+ 0.3500000000000001,
19
+ 0.15000000000000002,
20
+ 0.85,
21
+ 0.7999999999999999,
22
+ 0.0,
23
+ 0.7,
24
+ 0.85,
25
+ 0.6000000000000001,
26
+ 0.85,
27
+ 0.050000000000000044,
28
+ 1.0,
29
+ 0.0,
30
+ 1.0,
31
+ 0.7999999999999999,
32
+ 0.95,
33
+ 0.7999999999999999,
34
+ 0.8999999999999999,
35
+ 0.0,
36
+ 0.09999999999999998,
37
+ 0.85,
38
+ 0.5499999999999998,
39
+ 0.20000000000000007,
40
+ 0.050000000000000044,
41
+ 0.0,
42
+ 0.050000000000000044,
43
+ 0.75,
44
+ 0.0,
45
+ 0.6000000000000001,
46
+ 0.95,
47
+ 0.25,
48
+ 0.8999999999999999,
49
+ 0.4999999999999999,
50
+ 0.7,
51
+ 0.4,
52
+ 0.0,
53
+ 1.0,
54
+ 0.7999999999999999,
55
+ 0.6000000000000001,
56
+ 0.65,
57
+ 0.8999999999999999,
58
+ 0.65,
59
+ 0.44999999999999984,
60
+ 0.20000000000000007,
61
+ 0.95,
62
+ 0.5499999999999998,
63
+ 0.44999999999999984,
64
+ 0.4999999999999999,
65
+ 0.09999999999999998,
66
+ 0.15000000000000002,
67
+ 0.65,
68
+ 0.09999999999999998,
69
+ 0.5499999999999998,
70
+ 0.0,
71
+ 0.4,
72
+ 0.0,
73
+ 0.09999999999999998,
74
+ 0.44999999999999984,
75
+ 0.7,
76
+ 0.0,
77
+ 0.0,
78
+ 0.0,
79
+ 0.050000000000000044,
80
+ 0.09999999999999998,
81
+ 0.4,
82
+ 0.7,
83
+ 0.20000000000000007,
84
+ 0.25,
85
+ 0.15000000000000002,
86
+ 0.0,
87
+ 0.0,
88
+ 0.5499999999999998,
89
+ 0.4,
90
+ 0.0,
91
+ 0.050000000000000044,
92
+ 0.0,
93
+ 0.3500000000000001,
94
+ 0.0,
95
+ 0.6000000000000001,
96
+ 0.0,
97
+ 0.4,
98
+ 0.050000000000000044,
99
+ 0.6000000000000001,
100
+ 0.30000000000000004,
101
+ 0.25,
102
+ 0.050000000000000044,
103
+ 0.0,
104
+ 0.0,
105
+ 0.050000000000000044,
106
+ 0.0,
107
+ 0.30000000000000004,
108
+ 0.09999999999999998,
109
+ 0.0,
110
+ 0.95,
111
+ 0.09999999999999998,
112
+ 0.0,
113
+ 0.0,
114
+ 0.15000000000000002,
115
+ 0.3500000000000001,
116
+ 0.0,
117
+ 0.09999999999999998,
118
+ 0.0,
119
+ 0.85,
120
+ 0.15000000000000002,
121
+ 0.0,
122
+ 0.0,
123
+ 0.0,
124
+ 0.0,
125
+ 0.09999999999999998,
126
+ 0.25,
127
+ 0.09999999999999998,
128
+ 0.0,
129
+ 0.0,
130
+ 0.15000000000000002,
131
+ 0.15000000000000002,
132
+ 0.0,
133
+ 0.0,
134
+ 0.0,
135
+ 0.0,
136
+ 0.0,
137
+ 0.0,
138
+ 0.0,
139
+ 0.30000000000000004,
140
+ 0.050000000000000044,
141
+ 0.09999999999999998,
142
+ 0.0,
143
+ 0.0,
144
+ 0.0,
145
+ 0.0,
146
+ 0.65,
147
+ 0.0,
148
+ 0.0,
149
+ 0.09999999999999998,
150
+ 0.0,
151
+ 1.0,
152
+ 0.0,
153
+ 0.050000000000000044,
154
+ 0.4999999999999999,
155
+ 0.75,
156
+ 0.15000000000000002,
157
+ 0.0,
158
+ 0.75,
159
+ 0.7,
160
+ 0.4999999999999999,
161
+ 0.7,
162
+ 0.3500000000000001,
163
+ 0.0,
164
+ 0.5499999999999998,
165
+ 0.44999999999999984,
166
+ 0.0
167
+ ],
168
+ "pass@5": [
169
+ 0.9918730650154799,
170
+ 0.0,
171
+ 0.9702012383900929,
172
+ 1.0,
173
+ 1.0,
174
+ 0.0,
175
+ 0.6008771929824561,
176
+ 1.0,
177
+ 1.0,
178
+ 0.8063080495356036,
179
+ 0.0,
180
+ 0.9996130030959752,
181
+ 1.0,
182
+ 0.9986455108359134,
183
+ 0.7182662538699691,
184
+ 0.9169891640866873,
185
+ 0.6008771929824561,
186
+ 1.0,
187
+ 1.0,
188
+ 0.0,
189
+ 0.9996130030959752,
190
+ 1.0,
191
+ 0.9963880288957688,
192
+ 1.0,
193
+ 0.25,
194
+ 1.0,
195
+ 0.0,
196
+ 1.0,
197
+ 1.0,
198
+ 1.0,
199
+ 1.0,
200
+ 1.0,
201
+ 0.0,
202
+ 0.4473684210526315,
203
+ 1.0,
204
+ 0.9918730650154799,
205
+ 0.7182662538699691,
206
+ 0.25,
207
+ 0.0,
208
+ 0.25,
209
+ 0.9999355005159959,
210
+ 0.0,
211
+ 0.9963880288957688,
212
+ 1.0,
213
+ 0.8063080495356036,
214
+ 1.0,
215
+ 0.9837461300309598,
216
+ 0.9996130030959752,
217
+ 0.9489164086687306,
218
+ 0.0,
219
+ 1.0,
220
+ 1.0,
221
+ 0.9963880288957688,
222
+ 0.9986455108359134,
223
+ 1.0,
224
+ 0.9986455108359134,
225
+ 0.9702012383900929,
226
+ 0.7182662538699691,
227
+ 1.0,
228
+ 0.9918730650154799,
229
+ 0.9702012383900929,
230
+ 0.9837461300309598,
231
+ 0.4473684210526315,
232
+ 0.6008771929824561,
233
+ 0.9986455108359134,
234
+ 0.4473684210526315,
235
+ 0.9918730650154799,
236
+ 0.0,
237
+ 0.9489164086687306,
238
+ 0.0,
239
+ 0.4473684210526315,
240
+ 0.9702012383900929,
241
+ 0.9996130030959752,
242
+ 0.0,
243
+ 0.0,
244
+ 0.0,
245
+ 0.25,
246
+ 0.4473684210526315,
247
+ 0.9489164086687306,
248
+ 0.9996130030959752,
249
+ 0.7182662538699691,
250
+ 0.8063080495356036,
251
+ 0.6008771929824561,
252
+ 0.0,
253
+ 0.0,
254
+ 0.9918730650154799,
255
+ 0.9489164086687306,
256
+ 0.0,
257
+ 0.25,
258
+ 0.0,
259
+ 0.9169891640866873,
260
+ 0.0,
261
+ 0.9963880288957688,
262
+ 0.0,
263
+ 0.9489164086687306,
264
+ 0.25,
265
+ 0.9963880288957688,
266
+ 0.8708720330237358,
267
+ 0.8063080495356036,
268
+ 0.25,
269
+ 0.0,
270
+ 0.0,
271
+ 0.25,
272
+ 0.0,
273
+ 0.8708720330237358,
274
+ 0.4473684210526315,
275
+ 0.0,
276
+ 1.0,
277
+ 0.4473684210526315,
278
+ 0.0,
279
+ 0.0,
280
+ 0.6008771929824561,
281
+ 0.9169891640866873,
282
+ 0.0,
283
+ 0.4473684210526315,
284
+ 0.0,
285
+ 1.0,
286
+ 0.6008771929824561,
287
+ 0.0,
288
+ 0.0,
289
+ 0.0,
290
+ 0.0,
291
+ 0.4473684210526315,
292
+ 0.8063080495356036,
293
+ 0.4473684210526315,
294
+ 0.0,
295
+ 0.0,
296
+ 0.6008771929824561,
297
+ 0.6008771929824561,
298
+ 0.0,
299
+ 0.0,
300
+ 0.0,
301
+ 0.0,
302
+ 0.0,
303
+ 0.0,
304
+ 0.0,
305
+ 0.8708720330237358,
306
+ 0.25,
307
+ 0.4473684210526315,
308
+ 0.0,
309
+ 0.0,
310
+ 0.0,
311
+ 0.0,
312
+ 0.9986455108359134,
313
+ 0.0,
314
+ 0.0,
315
+ 0.4473684210526315,
316
+ 0.0,
317
+ 1.0,
318
+ 0.0,
319
+ 0.25,
320
+ 0.9837461300309598,
321
+ 0.9999355005159959,
322
+ 0.6008771929824561,
323
+ 0.0,
324
+ 0.9999355005159959,
325
+ 0.9996130030959752,
326
+ 0.9837461300309598,
327
+ 0.9996130030959752,
328
+ 0.9169891640866873,
329
+ 0.0,
330
+ 0.9918730650154799,
331
+ 0.9702012383900929,
332
+ 0.0
333
+ ],
334
+ "pass@10": [
335
+ 1.0,
336
+ 0.0,
337
+ 0.9999404620147654,
338
+ 1.0,
339
+ 1.0,
340
+ 0.0,
341
+ 0.8947368421052632,
342
+ 1.0,
343
+ 1.0,
344
+ 0.9837461300309598,
345
+ 0.0,
346
+ 1.0,
347
+ 1.0,
348
+ 1.0,
349
+ 0.956656346749226,
350
+ 0.9984520123839009,
351
+ 0.8947368421052632,
352
+ 1.0,
353
+ 1.0,
354
+ 0.0,
355
+ 1.0,
356
+ 1.0,
357
+ 1.0,
358
+ 1.0,
359
+ 0.5,
360
+ 1.0,
361
+ 0.0,
362
+ 1.0,
363
+ 1.0,
364
+ 1.0,
365
+ 1.0,
366
+ 1.0,
367
+ 0.0,
368
+ 0.763157894736842,
369
+ 1.0,
370
+ 1.0,
371
+ 0.956656346749226,
372
+ 0.5,
373
+ 0.0,
374
+ 0.5,
375
+ 1.0,
376
+ 0.0,
377
+ 1.0,
378
+ 1.0,
379
+ 0.9837461300309598,
380
+ 1.0,
381
+ 0.9999945874558878,
382
+ 1.0,
383
+ 0.9996427720885925,
384
+ 0.0,
385
+ 1.0,
386
+ 1.0,
387
+ 1.0,
388
+ 1.0,
389
+ 1.0,
390
+ 1.0,
391
+ 0.9999404620147654,
392
+ 0.956656346749226,
393
+ 1.0,
394
+ 1.0,
395
+ 0.9999404620147654,
396
+ 0.9999945874558878,
397
+ 0.763157894736842,
398
+ 0.8947368421052632,
399
+ 1.0,
400
+ 0.763157894736842,
401
+ 1.0,
402
+ 0.0,
403
+ 0.9996427720885925,
404
+ 0.0,
405
+ 0.763157894736842,
406
+ 0.9999404620147654,
407
+ 1.0,
408
+ 0.0,
409
+ 0.0,
410
+ 0.0,
411
+ 0.5,
412
+ 0.763157894736842,
413
+ 0.9996427720885925,
414
+ 1.0,
415
+ 0.956656346749226,
416
+ 0.9837461300309598,
417
+ 0.8947368421052632,
418
+ 0.0,
419
+ 0.0,
420
+ 1.0,
421
+ 0.9996427720885925,
422
+ 0.0,
423
+ 0.5,
424
+ 0.0,
425
+ 0.9984520123839009,
426
+ 0.0,
427
+ 1.0,
428
+ 0.0,
429
+ 0.9996427720885925,
430
+ 0.5,
431
+ 1.0,
432
+ 0.9945820433436533,
433
+ 0.9837461300309598,
434
+ 0.5,
435
+ 0.0,
436
+ 0.0,
437
+ 0.5,
438
+ 0.0,
439
+ 0.9945820433436533,
440
+ 0.763157894736842,
441
+ 0.0,
442
+ 1.0,
443
+ 0.763157894736842,
444
+ 0.0,
445
+ 0.0,
446
+ 0.8947368421052632,
447
+ 0.9984520123839009,
448
+ 0.0,
449
+ 0.763157894736842,
450
+ 0.0,
451
+ 1.0,
452
+ 0.8947368421052632,
453
+ 0.0,
454
+ 0.0,
455
+ 0.0,
456
+ 0.0,
457
+ 0.763157894736842,
458
+ 0.9837461300309598,
459
+ 0.763157894736842,
460
+ 0.0,
461
+ 0.0,
462
+ 0.8947368421052632,
463
+ 0.8947368421052632,
464
+ 0.0,
465
+ 0.0,
466
+ 0.0,
467
+ 0.0,
468
+ 0.0,
469
+ 0.0,
470
+ 0.0,
471
+ 0.9945820433436533,
472
+ 0.5,
473
+ 0.763157894736842,
474
+ 0.0,
475
+ 0.0,
476
+ 0.0,
477
+ 0.0,
478
+ 1.0,
479
+ 0.0,
480
+ 0.0,
481
+ 0.763157894736842,
482
+ 0.0,
483
+ 1.0,
484
+ 0.0,
485
+ 0.5,
486
+ 0.9999945874558878,
487
+ 1.0,
488
+ 0.8947368421052632,
489
+ 0.0,
490
+ 1.0,
491
+ 1.0,
492
+ 0.9999945874558878,
493
+ 1.0,
494
+ 0.9984520123839009,
495
+ 0.0,
496
+ 1.0,
497
+ 0.9999404620147654,
498
+ 0.0
499
+ ]
500
+ }
data/coding/humaneval/weight/1.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18d706f3197339ab51955e1cf61e3ebe8cabf84f3b5fce482635dd0032d2e721
3
+ size 32347240
data/coding/humaneval/weight/2.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7ca1bdbbd139164306e9cd49655723f58b302f07f57787026ef98a9e10a4bde3
3
+ size 32474912
data/coding/humaneval/weight/3.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c8fc6178d22709be8c48815e8b2919577703b27be932585e2ac6570e5c35097
3
+ size 32544745
data/coding/humaneval/weight/4.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0548656a686a416a55f6bafd9ed8bf32f3e2ebd9711f01771aa7cc8332502ae
3
+ size 32476662
data/coding/humaneval/weight/5.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00790ec759283677dd37f10d87a06928b289bd7279692aa58454c2f2822042fb
3
+ size 32512092
data/common/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/common/arc_c/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/common/arc_c/csv/1.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/csv/2.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/csv/3.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/csv/4.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/csv/5.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/json/1.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/json/2.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/json/3.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/json/4.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/json/5.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/arc_c/weight/1.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cc3fdeca167554611d03755ba597c1a33c7080fb834bff6b754013b4c76430a
3
+ size 6615373
data/common/arc_c/weight/2.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcf652b0fdda7882828bb5312034d688714452ed3e3beda1a4fe77aa074d5460
3
+ size 6630928
data/common/arc_c/weight/3.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:444a61e25d9401a0d3d1d0f230da076abb60af920989c291a15b1c6c347c7bdb
3
+ size 6632919
data/common/arc_c/weight/4.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a03f657e4bb9e4780181ce0e1f66ca40efe192f93afc706d10a432b15faf737
3
+ size 6626990
data/common/arc_c/weight/5.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59f5077aa86c011c18cbedd9e169e8928f4b22f2702a4d39c7c2d4ef4702b641
3
+ size 6634878
data/common/obqa/.DS_Store ADDED
Binary file (6.15 kB). View file
 
data/common/obqa/csv/1.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/csv/2.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/csv/3.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/csv/4.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/csv/5.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/json/1.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/json/2.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/json/3.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/json/4.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/json/5.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
data/common/obqa/weight/1.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb893c2a5da175b56842d8262487100c8a42676e5bf79b22b610615e6038a57f
3
+ size 6746654
data/common/obqa/weight/2.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bbba2c3e51588a6504e2c478c266024f9d5b488adc862f24cbf6f91a35d10ac
3
+ size 6746143
data/common/obqa/weight/3.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1631136724c043d7a67daf94127c06339688f2f39c4445316083297b9bd195b4
3
+ size 6735127
data/common/obqa/weight/4.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e8b3c97a723dcdd1fee6f6c03832a9934ac50fc389a240fb2da58a2b306358d
3
+ size 6733919