File size: 10,911 Bytes
848c6b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
{
  "code_vault_docs": 18694,
  "japanese_coding_suite": {
    "passed": 16,
    "total": 16,
    "accuracy_pct": 100,
    "cases": [
      {
        "category": "動的計画法/反復",
        "question": "フィボナッチ数列の第n項を返すPython関数を書いて",
        "verified": true,
        "tests_passed": 4,
        "tests_total": 4,
        "source": "PrismMind-Verified-Algo",
        "code": "def fibonacci(n: int) -> int:\n    if n < 0:\n        raise ValueError(\"n must be non-negative\")\n    a, b = 0, 1\n    for _ in range(n):\n        a, b = b, a + b\n    return a",
        "latency_ms": 187.8063
      },
      {
        "category": "数論",
        "question": "与えられた整数が素数かどうか判定するPython関数を実装して",
        "verified": true,
        "tests_passed": 4,
        "tests_total": 4,
        "source": "PrismMind-Verified-Algo",
        "code": "def is_prime(n: int) -> bool:\n    if n < 2:\n        return False\n    if n % 2 == 0:\n        return n == 2\n    d = 3\n    while d * d <= n:\n        if n % d == 0:\n            return False\n        d += 2\n    return True",
        "latency_ms": 116.533
      },
      {
        "category": "数論",
        "question": "整数を素因数分解してリストで返すPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def prime_factors(n: int) -> list[int]:\n    factors = []\n    d = 2\n    while d * d <= n:\n        while n % d == 0:\n            factors.append(d)\n            n //= d\n        d += 1 if d == 2 else 2\n    if n > 1:\n        factors.append(n)\n    return factors",
        "latency_ms": 121.6569
      },
      {
        "category": "文字列",
        "question": "文字列が回文かどうか判定するPython関数を書いて",
        "verified": true,
        "tests_passed": 3,
        "tests_total": 3,
        "source": "PrismMind-Verified-Algo",
        "code": "def is_palindrome(s: str) -> bool:\n    cleaned = \"\".join(ch.lower() for ch in s if ch.isalnum())\n    return cleaned == cleaned[::-1]",
        "latency_ms": 126.2367
      },
      {
        "category": "スタック",
        "question": "括弧の対応が正しいか判定するPython関数を作って",
        "verified": true,
        "tests_passed": 4,
        "tests_total": 4,
        "source": "PrismMind-Verified-Algo",
        "code": "def is_valid_brackets(s: str) -> bool:\n    pairs = {')': '(', ']': '[', '}': '{', '」': '「', ')': '('}\n    stack = []\n    for ch in s:\n        if ch in pairs.values():\n            stack.append(ch)\n        elif ch in pairs:\n            if not stack or stack.pop() != pairs[ch]:\n                return False\n    return not stack",
        "latency_ms": 115.9873
      },
      {
        "category": "探索",
        "question": "ソート済み配列から二分探索を行うPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def binary_search(arr: list[int], target: int) -> int:\n    lo, hi = 0, len(arr) - 1\n    while lo <= hi:\n        mid = (lo + hi) // 2\n        if arr[mid] == target:\n            return mid\n        elif arr[mid] < target:\n            lo = mid + 1\n        else:\n            hi = mid - 1\n    return -1",
        "latency_ms": 121.1641
      },
      {
        "category": "ソート",
        "question": "配列をクイックソートするPython関数を実装して",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def quicksort(arr: list) -> list:\n    if len(arr) <= 1:\n        return list(arr)\n    pivot = arr[len(arr) // 2]\n    left = [x for x in arr if x < pivot]\n    mid = [x for x in arr if x == pivot]\n    right = [x for x in arr if x > pivot]\n    return quicksort(left) + mid + quicksort(right)",
        "latency_ms": 120.653
      },
      {
        "category": "2ポインタ",
        "question": "ソート済みの2つの配列をマージするPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def merge_sorted(a: list, b: list) -> list:\n    res = []\n    i = j = 0\n    while i < len(a) and j < len(b):\n        if a[i] <= b[j]:\n            res.append(a[i]); i += 1\n        else:\n            res.append(b[j]); j += 1\n    res.extend(a[i:])\n    res.extend(b[j:])\n    return res",
        "latency_ms": 119.2883
      },
      {
        "category": "ハッシュ集合",
        "question": "リストの重複を順序を保って削除するPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def remove_duplicates(items: list) -> list:\n    seen = set()\n    out = []\n    for x in items:\n        if x not in seen:\n            seen.add(x)\n            out.append(x)\n    return out",
        "latency_ms": 122.038
      },
      {
        "category": "文字列",
        "question": "2つの文字列がアナグラムかどうか判定するPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "from collections import Counter\n\ndef is_anagram(a: str, b: str) -> bool:\n    ca = Counter(ch.lower() for ch in a if ch.isalnum())\n    cb = Counter(ch.lower() for ch in b if ch.isalnum())\n    return ca == cb",
        "latency_ms": 124.9456
      },
      {
        "category": "数論",
        "question": "2つの整数の最大公約数を求めるPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def gcd(a: int, b: int) -> int:\n    a, b = abs(a), abs(b)\n    while b:\n        a, b = b, a % b\n    return a",
        "latency_ms": 118.1081
      },
      {
        "category": "数論",
        "question": "非負整数の階乗を計算するPython関数を書いて",
        "verified": true,
        "tests_passed": 3,
        "tests_total": 3,
        "source": "PrismMind-Verified-Algo",
        "code": "def factorial(n: int) -> int:\n    if n < 0:\n        raise ValueError(\"n must be non-negative\")\n    res = 1\n    for k in range(2, n + 1):\n        res *= k\n    return res",
        "latency_ms": 118.6706
      },
      {
        "category": "行列",
        "question": "2次元行列を転置するPython関数を書いて",
        "verified": true,
        "tests_passed": 1,
        "tests_total": 1,
        "source": "PrismMind-Verified-Algo",
        "code": "def transpose(matrix: list[list]) -> list[list]:\n    if not matrix:\n        return []\n    return [list(row) for row in zip(*matrix)]",
        "latency_ms": 116.245
      },
      {
        "category": "ハッシュマップ",
        "question": "配列の中から合計がターゲットになる2つの要素のインデックスを返すTwo SumのPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def two_sum(nums: list[int], target: int) -> tuple[int, int] | None:\n    seen = {}\n    for i, x in enumerate(nums):\n        need = target - x\n        if need in seen:\n            return (seen[need], i)\n        seen[x] = i\n    return None",
        "latency_ms": 131.6688
      },
      {
        "category": "集計",
        "question": "文字列中の各文字の出現回数を辞書で返すPython関数を書いて",
        "verified": true,
        "tests_passed": 1,
        "tests_total": 1,
        "source": "PrismMind-Verified-Algo",
        "code": "from collections import Counter\n\ndef char_frequency(s: str) -> dict[str, int]:\n    return dict(Counter(s))",
        "latency_ms": 120.4019
      },
      {
        "category": "文字列",
        "question": "文字列を反転して返すPython関数を書いて",
        "verified": true,
        "tests_passed": 2,
        "tests_total": 2,
        "source": "PrismMind-Verified-Algo",
        "code": "def reverse_string(s: str) -> str:\n    return s[::-1]",
        "latency_ms": 116.2763
      }
    ]
  },
  "mbpp_heldout_test": {
    "passed": 22,
    "total": 100,
    "pass_at_10_pct": 22,
    "solved_examples": [
      {
        "task_id": 17,
        "prompt": "Write a function to find the perimeter of a square.",
        "source": "mbpp",
        "code": "def square_perimeter(a):\r\n  perimeter=4*a\r\n  return perimeter"
      },
      {
        "task_id": 19,
        "prompt": "Write a function to find whether a given array of integers contains any duplicate element.",
        "source": "codeinst122k",
        "code": "def test_duplicate(arr): \n # Create a new array to store the elements \n result = [] \n\n # Iterate over the given array \n for i in range(len(arr)): \n  # If element is already present in the result array, the element is duplicate \n  if arr[i] in result: \n   return True \n  else: \n   # If the element is not present, add it to the result array \n   result.append(arr[i]) \n\n # If all elements are unique, return False \n return False"
      },
      {
        "task_id": 20,
        "prompt": "Write a function to check if the given number is woodball or not.",
        "source": "codeinst122k",
        "code": "def is_woodall(n):\n    # check if 2 or greater \n    if n >= 2:\n        # check for factors \n        for i in range(2, int(n**0.5) + 1):\n            if n % i == 0:\n                # number is not prime \n                return False\n        # number is prime \n        return True\n    # number is not prime \n    return False"
      },
      {
        "task_id": 24,
        "prompt": "Write a function to convert the given binary number to its decimal equivalent.",
        "source": "codealpaca",
        "code": "def binary_to_decimal(number):\n    result = 0\n    power = 0\n    for digit in str(number)[::-1]:\n        if digit == '1':\n            result += 2 ** power\n        power += 1\n    return result"
      },
      {
        "task_id": 28,
        "prompt": "Write a python function to find binomial co-efficient.",
        "source": "mbpp",
        "code": "def binomial_Coeff(n,k): \r\n    C = [0] * (k + 1); \r\n    C[0] = 1; # nC0 is 1 \r\n    for i in range(1,n + 1):  \r\n        for j in range(min(i, k),0,-1): \r\n            C[j] = C[j] + C[j - 1]; \r\n    return C[k]; \r\ndef sum_Of_product(n): \r\n    return binomial_Coeff(2 * n,n - 1);"
      }
    ]
  }
}