Jintao Huang commited on
Commit
b1919aa
1 Parent(s): 998e263

first commit

Browse files
.gitattributes CHANGED
@@ -1,35 +1,34 @@
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
 
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
9
  *.joblib filter=lfs diff=lfs merge=lfs -text
10
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
  *.model filter=lfs diff=lfs merge=lfs -text
13
  *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
  *.onnx filter=lfs diff=lfs merge=lfs -text
17
  *.ot filter=lfs diff=lfs merge=lfs -text
18
  *.parquet filter=lfs diff=lfs merge=lfs -text
19
  *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
  *.pt filter=lfs diff=lfs merge=lfs -text
23
  *.pth filter=lfs diff=lfs merge=lfs -text
24
  *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
  *.xz filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
  *.bz2 filter=lfs diff=lfs merge=lfs -text
 
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
9
  *.joblib filter=lfs diff=lfs merge=lfs -text
10
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
 
11
  *.model filter=lfs diff=lfs merge=lfs -text
12
  *.msgpack filter=lfs diff=lfs merge=lfs -text
 
 
13
  *.onnx filter=lfs diff=lfs merge=lfs -text
14
  *.ot filter=lfs diff=lfs merge=lfs -text
15
  *.parquet filter=lfs diff=lfs merge=lfs -text
16
  *.pb filter=lfs diff=lfs merge=lfs -text
 
 
17
  *.pt filter=lfs diff=lfs merge=lfs -text
18
  *.pth filter=lfs diff=lfs merge=lfs -text
19
  *.rar filter=lfs diff=lfs merge=lfs -text
 
20
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
22
  *.tflite filter=lfs diff=lfs merge=lfs -text
23
  *.tgz filter=lfs diff=lfs merge=lfs -text
 
24
  *.xz filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *.tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ *.db* filter=lfs diff=lfs merge=lfs -text
29
+ *.ark* filter=lfs diff=lfs merge=lfs -text
30
+ **/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
31
+ **/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
32
+ **/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
33
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
34
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tasks:
3
+
4
+ - text-generation
5
+
6
+ tags:
7
+ - transformer
8
+ - Codefuse
9
+ - CodeLlama
10
+
11
+ studios:
12
+ - codefuse-ai/TestGPT-7B-demo
13
+
14
+ ---
15
+ ### 模型介绍(Introduction)
16
+ TestGPT-7B,是蚂蚁研发的测试域大模型。该模型以CodeLlama-7B为基座,进行了测试领域下游任务的微调,包含多语言测试用例生成、测试用例Assert补全。
17
+ TestGPT-7B, developed by Ant Group, is a large-scale model designed for software quality domains. Built upon the foundation of CodeLlama-7B, this model has undergone fine-tuning for downstream tasks, including multi-language test case generation and test case assertion completion.
18
+
19
+ - 多语言测试用例生成(Multi-language test case generation)
20
+
21
+ 测试用例生成一直以来都是学术界和工业界非常关注的领域,近年来不断有新产品或工具孵化出来,如EvoSuite、Randoop、SmartUnit等。然而传统的用例生成存在其难以解决的痛点问题,基于大模型的测试用例生成在测试用例可读性、测试场景完整度、多语言支持方面都优于传统用例生成工具。
22
+ TestGPT-7B中重点支持了多语言测试用例生成,在我们本次开源的版本中首先包含了Java、Python、Javascript的测试用例生成能力,下一版本中逐步开放Go、C++等语言。
23
+ Test case generation has always been a highly regarded field in both academia and industry. In recent years, many products or tools have emerged, such as EvoSuite, Randoop, SmartUnit, etc. However, traditional test case generation tools face challenges that are very difficult to overcome. Test case generation based on large models is superior to traditional test case generation tools in terms of test case readability, test scenario completeness, and multi-language support.
24
+ In TestGPT-7B, there is a strong focus on supporting test case generation for multiple languages. In this open-source version, we primarily include test case generation capabilities for Java, Python, and Javascript. In the next version, we will introduce support for languages like Go and C++.
25
+
26
+ - 测试用例Assert补全(Test case assertion completion)
27
+
28
+ 对当前测试用例现状的分析与探查时,我们发现代码仓库中存在一定比例的存量测试用例中未包含Assert。没有Assert的测试用例虽然能够在回归过程中执行通过,却无法发现问题。因此我们拓展了测试用例Assert自动补全这一场景。通过该模型能力,结合一定的工程化配套,可以实现对全库测试用例的批量自动补全,智能提升项目质量水位。
29
+ Based on the analysis of the current state of test cases, we have found that there is a certain proportion of existing test cases that do not include Assert statements. Test cases without Assert statements may pass during regression phase but are unable to detect any bugs. Therefore, we have expanded the scenario of automatic completion of Assert statements in test cases. With the capabilities of this model and some engineering support, we can achieve automatic completion of test cases across the entire code repository, intelligently improving the quality of the project.
30
+ 后续我们会持续迭代模型能力:1)不断加入更多令人激动的测试域应用场景,如领域知识问答、测试场景分析等;2)以7B为基础,逐步扩展至13B、34B模型。欢迎关注!
31
+ In the future, we will continue to iterate on the model capabilities. 1) We will continuously contribute more exciting Software Quality Related applications, such as test scenario analysis. 2) Building on the foundation of 7B, we will gradually expand to 13B and 34B models. Stay tuned for updates!
32
+
33
+ ### 依赖项(Requirements)
34
+
35
+ - python>=3.8
36
+ - pytorch>=2.0.0
37
+ - CUDA 11.4
38
+ - transformers==4.33.2
39
+
40
+ ### 评测表现(Testcase Evaluation)
41
+
42
+ - TestGPT-7B测试用例生成(Multi-language test case generation)
43
+
44
+ 针对模型支持的三种语言:Java、Python、Javascript,Pass@1评测结果如下:
45
+ Currently, the model supports test case generation for three languages: Java, Python, and JavaScript. The evaluation results for Pass@1 are as follows:
46
+
47
+ | Model | Java pass@1 | Java Average number of test scenarios | Python pass@1 | Python Average number of test scenarios | Javascript pass@1 | Javascript Average number of test scenarios |
48
+ | --- | --- | --- | --- | --- | --- | --- |
49
+ | TestGPT-7B | 48.6% | 4.37 | 35.67% | 3.56 | 36% | 2.76 |
50
+ | CodeLlama-13B-Instruct | 40.54% | 1.08 | 30.57% | 1.65 | 31.7% | 3.13 |
51
+ | Qwen-14B-Chat | 10.81% | 2.78 | 15.9% | 1.32 | 9.15% | 4.22 |
52
+ | Baichuan2-13B-Chat | 13.5% | 2.24 | 12.7% | 2.12 | 6.1% | 3.31 |
53
+
54
+ 注:由于当前已开源的Base模型(如CodeLlama-13B/Qwen-14B/Baichuan2-13B等)不具备测试用例生成能力,因此在评测结果对比时,我们都选择了官方对齐后的chat模型(如CodeLlama-13B-Instruct/Qwen-14B-Chat/Baichuan2-13B-Chat)
55
+ Note: Since the currently open-sourced Base models (such as CodeLlama-13B/Qwen-14B/Baichuan2-13B) do not have the capability to generate test cases, we have chosen the official aligned chat models (such as CodeLlama-13B-Instruct/Qwen-14B-Chat/Baichuan2-13B-Chat) for comparison in the evaluation results.
56
+
57
+ - TestGPT-7B测试用例Assert补全(Test case assertion completion)
58
+
59
+ 目前模型支持Java用例的Assert补全,Pass@1评测结果如下:
60
+ Currently, the model supports assertion completion for Java test cases. The evaluation results for Pass@1 are as follows:
61
+
62
+ | Model | pass@1 | Percentage of strong validation |
63
+ | --- | --- | --- |
64
+ | TestGPT-7B | 71.1% | 100% |
65
+
66
+ 与此同时,我们也开源了测试用例生成、测试用例Assert补全的评测集,以方便进行模型效果对比与复现。评测集可在eval_data文件夹下找到。
67
+ Meanwhile, we have also open-sourced the evaluation dataset for test case generation and test case assertion completion, facilitating model performance comparison and reproduction. The evaluation dataset can be found in the eval_data folder.
68
+
69
+ ### 快速使用(QuickStart)
70
+ 下面我们展示使用TestGPT-7B模型,进行测试用例生成、测试用例Assert补全的示例:
71
+ Below are examples of test case generation and test case assertion completion using the TestGPT-7B model:
72
+ ```python
73
+ from modelscope import AutoModelForCausalLM, AutoTokenizer, snapshot_download, AutoConfig
74
+ import torch
75
+
76
+ HUMAN_ROLE_START_TAG = "<s>human\n"
77
+ BOT_ROLE_START_TAG = "<s>bot\n"
78
+
79
+ if __name__ == '__main__':
80
+ # 模型地址, 可以替换为本地模型地址
81
+ model_dir = snapshot_download('codefuse-ai/TestGPT-7B', revision = 'v1.0.0')
82
+
83
+ # 加载tokenizer
84
+ tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True, use_fast=False, legacy=False)
85
+
86
+ eos_token = '</s>'
87
+ pad_token = '<unk>'
88
+
89
+ try:
90
+ tokenizer.eos_token = eos_token
91
+ tokenizer.eos_token_id = tokenizer.convert_tokens_to_ids(eos_token)
92
+ except:
93
+ print(tokenizer.eos_token, tokenizer.eos_token_id)
94
+
95
+ try:
96
+ tokenizer.pad_token = pad_token
97
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids(pad_token)
98
+ except:
99
+ print(tokenizer.pad_token, tokenizer.pad_token_id)
100
+
101
+ tokenizer.padding_side = "left"
102
+ print(f"tokenizer's eos_token: {tokenizer.eos_token}, pad_token: {tokenizer.pad_token}")
103
+ print(f"tokenizer's eos_token_id: {tokenizer.eos_token_id}, pad_token_id: {tokenizer.pad_token_id}")
104
+
105
+ # 配置
106
+ config, unused_kwargs = AutoConfig.from_pretrained(
107
+ model_dir,
108
+ use_flash_attn=True,
109
+ use_xformers=True,
110
+ trust_remote_code=True,
111
+ return_unused_kwargs=True)
112
+
113
+ # 加载模型
114
+ model = AutoModelForCausalLM.from_pretrained(
115
+ model_dir,
116
+ config=config,
117
+ device_map="auto",
118
+ torch_dtype=torch.bfloat16,
119
+ trust_remote_code=True,
120
+ use_safetensors=False,
121
+ ).eval()
122
+
123
+ # 推理生成测试用例
124
+ # 被测代码prompt,分为用例生成和assert补全
125
+ # 用例生成格式
126
+ prompt = '为以下Python代码生成单元测试\n' \
127
+ '```Python\ndef add(lst):\n return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n```\n'
128
+
129
+ # assert补全格式,目前仅支持java语言
130
+ # prompt = '下面是被测代码\n' \
131
+ # '```java\n' \
132
+ # 'public class BooleanUtils {\n ' \
133
+ # 'public static boolean and(final boolean... array) {\n ' \
134
+ # 'ObjectUtils.requireNonEmpty(array, "array");\n ' \
135
+ # 'for (final boolean element : array) {\n ' \
136
+ # 'if (!element) {\n return false;\n }\n }\n ' \
137
+ # 'return true;\n }\n}\n```\n' \
138
+ # '下面代码是针对上面被测代码生成的用例,请补全用例,生成assert校验\n' \
139
+ # '```java\n' \
140
+ # '@Test\npublic void testAnd_withAllTrueInputs() {\n ' \
141
+ # 'boolean[] input = new boolean[] {true, true, true};\n ' \
142
+ # 'boolean result = BooleanUtils.and(input);\n}\n\n@Test\npublic void testAnd_withOneFalseInput() {\n ' \
143
+ # 'boolean[] input = new boolean[] {true, false, true};\n ' \
144
+ # 'boolean result = BooleanUtils.and(input);\n}\n' \
145
+ # '```\n'
146
+
147
+ # 输入格式化处理
148
+ prompt = f"{HUMAN_ROLE_START_TAG}{prompt}{BOT_ROLE_START_TAG}"
149
+ inputs = tokenizer(prompt, return_tensors='pt', padding=True, add_special_tokens=False).to("cuda")
150
+
151
+ # 推理
152
+ outputs = model.generate(
153
+ inputs=inputs["input_ids"],
154
+ max_new_tokens=2048,
155
+ top_p=0.95,
156
+ temperature=0.2,
157
+ do_sample=True,
158
+ eos_token_id=tokenizer.eos_token_id,
159
+ pad_token_id=tokenizer.pad_token_id,
160
+ num_return_sequences=1,
161
+ )
162
+
163
+ # 结果处理
164
+ outputs_len = len(outputs)
165
+ print(f"output len is: {outputs_len}")
166
+ for index in range(0, outputs_len):
167
+ print(f"generate index: {index}")
168
+ gen_text = tokenizer.decode(outputs[index], skip_special_tokens=True)
169
+ print(gen_text)
170
+ print("===================")
171
+
172
+ ```
173
+
config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/mnt/user/unittest/CodeLlama-7b-hf",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "bos_token_id": 1,
7
+ "eos_token": "</s>",
8
+ "eos_token_id": 2,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 4096,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 11008,
13
+ "max_position_embeddings": 16384,
14
+ "model_type": "llama",
15
+ "num_attention_heads": 32,
16
+ "num_hidden_layers": 32,
17
+ "num_key_value_heads": 32,
18
+ "pad_token": "<unk>",
19
+ "pad_token_id": 0,
20
+ "pretraining_tp": 1,
21
+ "rms_norm_eps": 1e-05,
22
+ "rope_scaling": null,
23
+ "rope_theta": 1000000,
24
+ "tie_word_embeddings": false,
25
+ "torch_dtype": "bfloat16",
26
+ "transformers_version": "4.33.2",
27
+ "use_cache": true,
28
+ "vocab_size": 32016
29
+ }
eval_data/java_eval.jsonl ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"task_id": "Java/0", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class Validate {\n public static void inclusiveBetween(final double start, final double end, final double value, final String message) {\n // TODO when breaking BC, consider returning value\n if (value < start || value > end) {\n throw new IllegalArgumentException(message);\n }\n }\n}\n```\n"}
2
+ {"task_id": "Java/1", "prompt": "为以下代码写单测,请不要说明:\n```\npublic final class Range<T> implements Serializable {\n private final Comparator<T> comparator;\n private final T maximum;\n private final T minimum;\n\n public static <T> Range<T> between(T fromInclusive, T toInclusive, Comparator<T> comparator) {\n return new Range(fromInclusive, toInclusive, comparator);\n }\n\n private Range(T element1, T element2, Comparator<T> comp) {\n if (element1 != null && element2 != null) {\n if (comp == null) {\n this.comparator = Range.ComparableComparator.INSTANCE;\n } else {\n this.comparator = comp;\n }\n\n if (this.comparator.compare(element1, element2) < 1) {\n this.minimum = element1;\n this.maximum = element2;\n } else {\n this.minimum = element2;\n this.maximum = element1;\n }\n\n } else {\n throw new IllegalArgumentException(\"Elements in a range must not be null: element1=\" + element1 + \", element2=\" + element2);\n }\n }\n\n public boolean contains(final T element) {\n if (element == null) {\n return false;\n }\n return comparator.compare(element, minimum) > -1 && comparator.compare(element, maximum) < 1;\n }\n}\n```\n"}
3
+ {"task_id": "Java/2", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ArrayUtils {\n public static final int INDEX_NOT_FOUND = -1;\n public static int lastIndexOf(final Object[] array, final Object objectToFind, int startIndex) {\n if (array == null || startIndex < 0) {\n return INDEX_NOT_FOUND;\n }\n if (startIndex >= array.length) {\n startIndex = array.length - 1;\n }\n if (objectToFind == null) {\n for (int i = startIndex; i >= 0; i--) {\n if (array[i] == null) {\n return i;\n }\n }\n } else if (array.getClass().getComponentType().isInstance(objectToFind)) {\n for (int i = startIndex; i >= 0; i--) {\n if (objectToFind.equals(array[i])) {\n return i;\n }\n }\n }\n return INDEX_NOT_FOUND;\n }\n}\n```\n"}
4
+ {"task_id": "Java/3", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class Validate {\n public static <T> void inclusiveBetween(final T start, final T end, final Comparable<T> value) {\n // TODO when breaking BC, consider returning value\n if (value.compareTo(start) < 0 || value.compareTo(end) > 0) {\n throw new IllegalArgumentException(String.format(DEFAULT_INCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));\n }\n }\n}\n```\n"}
5
+ {"task_id": "Java/4", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class UnicodeUnescaper {\n @Override\n public int translate(final CharSequence input, final int index, final Writer out) throws IOException {\n if (input.charAt(index) == '\\\\' && index + 1 < input.length() && input.charAt(index + 1) == 'u') {\n // consume optional additional 'u' chars\n int i = 2;\n while (index + i < input.length() && input.charAt(index + i) == 'u') {\n i++;\n }\n\n if (index + i < input.length() && input.charAt(index + i) == '+') {\n i++;\n }\n\n if (index + i + 4 <= input.length()) {\n // Get 4 hex digits\n final CharSequence unicode = input.subSequence(index + i, index + i + 4);\n\n try {\n final int value = Integer.parseInt(unicode.toString(), 16);\n out.write((char) value);\n } catch (final NumberFormatException nfe) {\n throw new IllegalArgumentException(\"Unable to parse unicode value: \" + unicode, nfe);\n }\n return i + 4;\n }\n throw new IllegalArgumentException(\"Less than 4 hex digits in unicode value: '\" + input.subSequence(index, input.length())\n + \"' due to end of CharSequence\");\n }\n return 0;\n }\n}\n```\n"}
6
+ {"task_id": "Java/5", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ObjectUtils {\n public static <T> T requireNonNull(T obj, String message) {\n if (obj == null)\n throw new NullPointerException(message);\n return obj;\n }\n public static <T> T requireNonEmpty(final T obj, final String message) {\n // check for null first to give the most precise exception.\n Objects.requireNonNull(obj, message);\n if (isEmpty(obj)) {\n throw new IllegalArgumentException(message);\n }\n return obj;\n }\n}\npublic class BooleanUtils {\n public static boolean and(final boolean... array) {\n ObjectUtils.requireNonEmpty(array, \"array\");\n for (final boolean element : array) {\n if (!element) {\n return false;\n }\n }\n return true;\n }\n}\n```\n"}
7
+ {"task_id": "Java/6", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class Range {\n private final Comparator<T> comparator;\n private final T maximum;\n private final T minimum;\n\n public static <T> Range<T> between(T fromInclusive, T toInclusive, Comparator<T> comparator) {\n return new Range(fromInclusive, toInclusive, comparator);\n }\n\n private Range(T element1, T element2, Comparator<T> comp) {\n if (element1 != null && element2 != null) {\n if (comp == null) {\n this.comparator = Range.ComparableComparator.INSTANCE;\n } else {\n this.comparator = comp;\n }\n\n if (this.comparator.compare(element1, element2) < 1) {\n this.minimum = element1;\n this.maximum = element2;\n } else {\n this.minimum = element2;\n this.maximum = element1;\n }\n\n } else {\n throw new IllegalArgumentException(\"Elements in a range must not be null: element1=\" + element1 + \", element2=\" + element2);\n }\n }\n\n public boolean isAfter(final T element) {\n if (element == null) {\n return false;\n }\n return comparator.compare(element, minimum) < 0;\n }\n public boolean isBefore(final T element) {\n if (element == null) {\n return false;\n }\n return comparator.compare(element, maximum) > 0;\n }\n\n public int elementCompareTo(final T element) {\n // Comparable API says throw NPE on null\n Objects.requireNonNull(element, \"element\");\n if (isAfter(element)) {\n return -1;\n }\n if (isBefore(element)) {\n return 1;\n }\n return 0;\n }\n}\n```\n"}
8
+ {"task_id": "Java/7", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class CompareToBuilder {\n private int comparison;\n public int toComparison() {\n return comparison;\n }\n public CompareToBuilder append(final double[] lhs, final double[] rhs) {\n if (comparison != 0) {\n return this;\n }\n if (lhs == rhs) {\n return this;\n }\n if (lhs == null) {\n comparison = -1;\n return this;\n }\n if (rhs == null) {\n comparison = 1;\n return this;\n }\n if (lhs.length != rhs.length) {\n comparison = lhs.length < rhs.length ? -1 : 1;\n return this;\n }\n for (int i = 0; i < lhs.length && comparison == 0; i++) {\n append(lhs[i], rhs[i]);\n }\n return this;\n }\n}\n```\n"}
9
+ {"task_id": "Java/8", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class NumberUtils {\n public static boolean withDecimalsParsing(final String str, final int beginIdx) {\n int decimalPoints = 0;\n for (int i = beginIdx; i < str.length(); i++) {\n final boolean isDecimalPoint = str.charAt(i) == '.';\n if (isDecimalPoint) {\n decimalPoints++;\n }\n if (decimalPoints > 1) {\n return false;\n }\n if (!isDecimalPoint && !Character.isDigit(str.charAt(i))) {\n return false;\n }\n }\n return true;\n }\n}\n```\n"}
10
+ {"task_id": "Java/9", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class TypeUtils {\n private static boolean equals(final WildcardType wildcardType, final Type type) {\n if (type instanceof WildcardType) {\n final WildcardType other = (WildcardType) type;\n return equals(getImplicitLowerBounds(wildcardType), getImplicitLowerBounds(other))\n && equals(getImplicitUpperBounds(wildcardType), getImplicitUpperBounds(other));\n }\n return false;\n }\n\n public static boolean equals(final Type type1, final Type type2) {\n if (Objects.equals(type1, type2)) {\n return true;\n }\n if (type1 instanceof ParameterizedType) {\n return equals((ParameterizedType) type1, type2);\n }\n if (type1 instanceof GenericArrayType) {\n return equals((GenericArrayType) type1, type2);\n }\n if (type1 instanceof WildcardType) {\n return equals((WildcardType) type1, type2);\n }\n return false;\n }\n}\n```\n"}
11
+ {"task_id": "Java/10", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class UnicodeUnpairedSurrogateRemover {\n @Override\n public boolean translate(final int codePoint, final Writer out) throws IOException {\n // true: It's a surrogate. Write nothing and say we've translated.\n return codePoint >= Character.MIN_SURROGATE && codePoint <= Character.MAX_SURROGATE;\n // It's not a surrogate. Don't translate it.\n }\n}\n```\n"}
12
+ {"task_id": "Java/11", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class StringUtils {\n public static String getDigits(final String str) {\n if (isEmpty(str)) {\n return str;\n }\n final int sz = str.length();\n final StringBuilder strDigits = new StringBuilder(sz);\n for (int i = 0; i < sz; i++) {\n final char tempChar = str.charAt(i);\n if (Character.isDigit(tempChar)) {\n strDigits.append(tempChar);\n }\n }\n return strDigits.toString();\n }\n}\n```\n"}
13
+ {"task_id": "Java/12", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class StringUtils {\n public static void convertRemainingAccentCharacters(final StringBuilder decomposed) {\n for (int i = 0; i < decomposed.length(); i++) {\n if (decomposed.charAt(i) == '\\u0141') {\n decomposed.setCharAt(i, 'L');\n } else if (decomposed.charAt(i) == '\\u0142') {\n decomposed.setCharAt(i, 'l');\n }\n }\n }\n}\n```\n"}
14
+ {"task_id": "Java/13", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class TimedSemaphore {\n private final ScheduledExecutorService executorService;\n private final long period;\n\n /** The time unit for the period. */\n private final TimeUnit unit;\n\n /** A flag whether the executor service was created by this object. */\n private final boolean ownExecutor;\n\n private boolean shutdown;\n\n public TimedSemaphore(final ScheduledExecutorService service, final long timePeriod,\n final TimeUnit timeUnit, final int limit) {\n Validate.inclusiveBetween(1, Long.MAX_VALUE, timePeriod, \"Time period must be greater than 0!\");\n\n period = timePeriod;\n unit = timeUnit;\n\n if (service != null) {\n executorService = service;\n ownExecutor = false;\n } else {\n final ScheduledThreadPoolExecutor s = new ScheduledThreadPoolExecutor(\n THREAD_POOL_SIZE);\n s.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);\n s.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);\n executorService = s;\n ownExecutor = true;\n }\n\n setLimit(limit);\n }\n public synchronized void shutdown() {\n if (!shutdown) {\n\n if (ownExecutor) {\n // if the executor was created by this instance, it has\n // to be shutdown\n getExecutorService().shutdownNow();\n }\n if (task != null) {\n task.cancel(false);\n }\n\n shutdown = true;\n }\n }\n}\n```\n"}
15
+ {"task_id": "Java/14", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ObjectUtils {\n public static boolean isEmpty(final Object object) {\n if (object == null) {\n return true;\n }\n if (object instanceof CharSequence) {\n return ((CharSequence) object).length() == 0;\n }\n if (isArray(object)) {\n return Array.getLength(object) == 0;\n }\n if (object instanceof Collection<?>) {\n return ((Collection<?>) object).isEmpty();\n }\n if (object instanceof Map<?, ?>) {\n return ((Map<?, ?>) object).isEmpty();\n }\n if (object instanceof Optional<?>) {\n // TODO Java 11 Use Optional#isEmpty()\n return !((Optional<?>) object).isPresent();\n }\n return false;\n }\n}\n```\n"}
16
+ {"task_id": "Java/16", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class StringUtils {\n public static String leftPad(final String str, final int size, String padStr) {\n if (str == null) {\n return null;\n }\n if (isEmpty(padStr)) {\n padStr = SPACE;\n }\n final int padLen = padStr.length();\n final int strLen = str.length();\n final int pads = size - strLen;\n if (pads <= 0) {\n return str; // returns original String when possible\n }\n if (padLen == 1 && pads <= PAD_LIMIT) {\n return leftPad(str, size, padStr.charAt(0));\n }\n\n if (pads == padLen) {\n return padStr.concat(str);\n }\n if (pads < padLen) {\n return padStr.substring(0, pads).concat(str);\n }\n final char[] padding = new char[pads];\n final char[] padChars = padStr.toCharArray();\n for (int i = 0; i < pads; i++) {\n padding[i] = padChars[i % padLen];\n }\n return new String(padding).concat(str);\n }\n\n public static String rightPad(final String str, final int size, String padStr) {\n if (str == null) {\n return null;\n }\n if (isEmpty(padStr)) {\n padStr = SPACE;\n }\n final int padLen = padStr.length();\n final int strLen = str.length();\n final int pads = size - strLen;\n if (pads <= 0) {\n return str; // returns original String when possible\n }\n if (padLen == 1 && pads <= PAD_LIMIT) {\n return rightPad(str, size, padStr.charAt(0));\n }\n\n if (pads == padLen) {\n return str.concat(padStr);\n }\n if (pads < padLen) {\n return str.concat(padStr.substring(0, pads));\n }\n final char[] padding = new char[pads];\n final char[] padChars = padStr.toCharArray();\n for (int i = 0; i < pads; i++) {\n padding[i] = padChars[i % padLen];\n }\n return str.concat(new String(padding));\n }\n\n public static String center(String str, final int size, String padStr) {\n if (str == null || size <= 0) {\n return str;\n }\n if (isEmpty(padStr)) {\n padStr = SPACE;\n }\n final int strLen = str.length();\n final int pads = size - strLen;\n if (pads <= 0) {\n return str;\n }\n str = leftPad(str, strLen + pads / 2, padStr);\n str = rightPad(str, size, padStr);\n return str;\n }\n}\n```\n"}
17
+ {"task_id": "Java/17", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class WordUtils {\n public static boolean containsAllWords(final CharSequence word, final CharSequence... words) {\n if (StringUtils.isEmpty(word) || ArrayUtils.isEmpty(words)) {\n return false;\n }\n for (final CharSequence w : words) {\n if (StringUtils.isBlank(w)) {\n return false;\n }\n final Pattern p = Pattern.compile(\".*\\\\b\" + w + \"\\\\b.*\");\n if (!p.matcher(word).matches()) {\n return false;\n }\n }\n return true;\n }\n}\n```\n"}
18
+ {"task_id": "Java/18", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class RandomStringUtils {\n public static String random(int count, int start, int end, final boolean letters, final boolean numbers,\n final char[] chars, final Random random) {\n if (count == 0) {\n return StringUtils.EMPTY;\n }\n if (count < 0) {\n throw new IllegalArgumentException(\"Requested random string length \" + count + \" is less than 0.\");\n }\n if (chars != null && chars.length == 0) {\n throw new IllegalArgumentException(\"The chars array must not be empty\");\n }\n\n if (start == 0 && end == 0) {\n if (chars != null) {\n end = chars.length;\n } else if (!letters && !numbers) {\n end = Character.MAX_CODE_POINT;\n } else {\n end = 'z' + 1;\n start = ' ';\n }\n } else if (end <= start) {\n throw new IllegalArgumentException(\"Parameter end (\" + end + \") must be greater than start (\" + start + \")\");\n }\n\n final int zero_digit_ascii = 48;\n final int first_letter_ascii = 65;\n\n if (chars == null && (numbers && end <= zero_digit_ascii\n || letters && end <= first_letter_ascii)) {\n throw new IllegalArgumentException(\"Parameter end (\" + end + \") must be greater then (\" + zero_digit_ascii + \") for generating digits \" +\n \"or greater then (\" + first_letter_ascii + \") for generating letters.\");\n }\n\n final StringBuilder builder = new StringBuilder(count);\n final int gap = end - start;\n\n while (count-- != 0) {\n final int codePoint;\n if (chars == null) {\n codePoint = random.nextInt(gap) + start;\n\n switch (Character.getType(codePoint)) {\n case Character.UNASSIGNED:\n case Character.PRIVATE_USE:\n case Character.SURROGATE:\n count++;\n continue;\n }\n\n } else {\n codePoint = chars[random.nextInt(gap) + start];\n }\n\n final int numberOfChars = Character.charCount(codePoint);\n if (count == 0 && numberOfChars > 1) {\n count++;\n continue;\n }\n\n if (letters && Character.isLetter(codePoint)\n || numbers && Character.isDigit(codePoint)\n || !letters && !numbers) {\n builder.appendCodePoint(codePoint);\n\n if (numberOfChars == 2) {\n count--;\n }\n\n } else {\n count++;\n }\n }\n return builder.toString();\n }\n}\n```\n"}
19
+ {"task_id": "Java/19", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ClassUtils {\n public static String getPackageName(String className) {\n if (StringUtils.isEmpty(className)) {\n return StringUtils.EMPTY;\n }\n\n // Strip array encoding\n while (className.charAt(0) == '[') {\n className = className.substring(1);\n }\n // Strip Object type encoding\n if (className.charAt(0) == 'L' && className.charAt(className.length() - 1) == ';') {\n className = className.substring(1);\n }\n\n final int i = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);\n if (i == -1) {\n return StringUtils.EMPTY;\n }\n return className.substring(0, i);\n }\n}\n```\n"}
20
+ {"task_id": "Java/21", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class StringUtils {\n public static final int INDEX_NOT_FOUND = -1;\n public static int indexOfIgnoreCase(final CharSequence str, final CharSequence searchStr, int startPos) {\n if (str == null || searchStr == null) {\n return INDEX_NOT_FOUND;\n }\n if (startPos < 0) {\n startPos = 0;\n }\n final int endLimit = str.length() - searchStr.length() + 1;\n if (startPos > endLimit) {\n return INDEX_NOT_FOUND;\n }\n if (searchStr.length() == 0) {\n return startPos;\n }\n for (int i = startPos; i < endLimit; i++) {\n if (CharSequenceUtils.regionMatches(str, true, i, searchStr, 0, searchStr.length())) {\n return i;\n }\n }\n return INDEX_NOT_FOUND;\n }\n}\n```\n"}
21
+ {"task_id": "Java/22", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class MutableFloat {\n private float value;\n\n public MutableFloat() {\n }\n\n public MutableFloat(final float value) {\n this.value = value;\n }\n\n @Override\n public Float getValue() {\n return Float.valueOf(this.value);\n }\n\n public float getAndDecrement() {\n final float last = value;\n value--;\n return last;\n }\n}\n```\n"}
22
+ {"task_id": "Java/24", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class StringUtils {\n public static boolean contains(final CharSequence seq, final int searchChar) {\n if (isEmpty(seq)) {\n return false;\n }\n return CharSequenceUtils.indexOf(seq, searchChar, 0) >= 0;\n }\n}\n```\n"}
23
+ {"task_id": "Java/25", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class CharSequenceUtils {\n static int lastIndexOf(final CharSequence cs, final CharSequence searchChar, int start) {\n if (searchChar == null || cs == null) {\n return NOT_FOUND;\n }\n if (searchChar instanceof String) {\n if (cs instanceof String) {\n return ((String) cs).lastIndexOf((String) searchChar, start);\n }\n if (cs instanceof StringBuilder) {\n return ((StringBuilder) cs).lastIndexOf((String) searchChar, start);\n }\n if (cs instanceof StringBuffer) {\n return ((StringBuffer) cs).lastIndexOf((String) searchChar, start);\n }\n }\n\n final int len1 = cs.length();\n final int len2 = searchChar.length();\n\n if (start > len1) {\n start = len1;\n }\n\n if (start < 0 || len2 > len1) {\n return NOT_FOUND;\n }\n\n if (len2 == 0) {\n return start;\n }\n\n if (len2 <= TO_STRING_LIMIT) {\n if (cs instanceof String) {\n return ((String) cs).lastIndexOf(searchChar.toString(), start);\n }\n if (cs instanceof StringBuilder) {\n return ((StringBuilder) cs).lastIndexOf(searchChar.toString(), start);\n }\n if (cs instanceof StringBuffer) {\n return ((StringBuffer) cs).lastIndexOf(searchChar.toString(), start);\n }\n }\n\n if (start + len2 > len1) {\n start = len1 - len2;\n }\n\n final char char0 = searchChar.charAt(0);\n\n int i = start;\n while (true) {\n while (cs.charAt(i) != char0) {\n i--;\n if (i < 0) {\n return NOT_FOUND;\n }\n }\n if (checkLaterThan1(cs, searchChar, len2, i)) {\n return i;\n }\n i--;\n if (i < 0) {\n return NOT_FOUND;\n }\n }\n }\n}\n```\n"}
24
+ {"task_id": "Java/26", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class FastTimeZone {\n private static final Pattern GMT_PATTERN = Pattern.compile(\"^(?:(?i)GMT)?([+-])?(\\\\d\\\\d?)?(:?(\\\\d\\\\d?))?$\");\n\n private static final TimeZone GREENWICH = new GmtTimeZone(false, 0, 0);\n\n public static TimeZone getGmtTimeZone() {\n return GREENWICH;\n }\n\n public static TimeZone getGmtTimeZone(final String pattern) {\n if (\"Z\".equals(pattern) || \"UTC\".equals(pattern)) {\n return GREENWICH;\n }\n\n final Matcher m = GMT_PATTERN.matcher(pattern);\n if (m.matches()) {\n final int hours = parseInt(m.group(2));\n final int minutes = parseInt(m.group(4));\n if (hours == 0 && minutes == 0) {\n return GREENWICH;\n }\n return new GmtTimeZone(parseSign(m.group(1)), hours, minutes);\n }\n return null;\n }\n}\n```\n"}
25
+ {"task_id": "Java/27", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class Conversion {\n public static byte binaryToByte(final boolean[] src, final int srcPos, final byte dstInit, final int dstPos,\n final int nBools) {\n if (src.length == 0 && srcPos == 0 || 0 == nBools) {\n return dstInit;\n }\n if (nBools - 1 + dstPos >= 8) {\n throw new IllegalArgumentException(\"nBools-1+dstPos is greater or equal to than 8\");\n }\n byte out = dstInit;\n for (int i = 0; i < nBools; i++) {\n final int shift = i + dstPos;\n final int bits = (src[i + srcPos] ? 1 : 0) << shift;\n final int mask = 0x1 << shift;\n out = (byte) ((out & ~mask) | bits);\n }\n return out;\n }\n}\n```\n"}
26
+ {"task_id": "Java/28", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class StrBuilder {\n public void getChars(final int startIndex, final int endIndex, final char[] destination, final int destinationIndex) {\n if (startIndex < 0) {\n throw new StringIndexOutOfBoundsException(startIndex);\n }\n if (endIndex < 0 || endIndex > length()) {\n throw new StringIndexOutOfBoundsException(endIndex);\n }\n if (startIndex > endIndex) {\n throw new StringIndexOutOfBoundsException(\"end < start\");\n }\n System.arraycopy(buffer, startIndex, destination, destinationIndex, endIndex - startIndex);\n }\n}\n```\n"}
27
+ {"task_id": "Java/29", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class Conversion {\n public static char binaryToHexDigitMsb0_4bits(final boolean[] src, final int srcPos) {\n if (src.length > 8) {\n throw new IllegalArgumentException(\"src.length>8: src.length=\" + src.length);\n }\n if (src.length - srcPos < 4) {\n throw new IllegalArgumentException(\"src.length-srcPos<4: src.length=\" + src.length + \", srcPos=\" + srcPos);\n }\n if (src[srcPos + 3]) {\n if (src[srcPos + 2]) {\n if (src[srcPos + 1]) {\n return src[srcPos] ? 'f' : '7';\n }\n return src[srcPos] ? 'b' : '3';\n }\n if (src[srcPos + 1]) {\n return src[srcPos] ? 'd' : '5';\n }\n return src[srcPos] ? '9' : '1';\n }\n if (src[srcPos + 2]) {\n if (src[srcPos + 1]) {\n return src[srcPos] ? 'e' : '6';\n }\n return src[srcPos] ? 'a' : '2';\n }\n if (src[srcPos + 1]) {\n return src[srcPos] ? 'c' : '4';\n }\n return src[srcPos] ? '8' : '0';\n }\n}\n```\n"}
28
+ {"task_id": "Java/30", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ArrayUtils {\n public static void reverse(final double[] array, final int startIndexInclusive, final int endIndexExclusive) {\n if (array == null) {\n return;\n }\n int i = Math.max(startIndexInclusive, 0);\n int j = Math.min(array.length, endIndexExclusive) - 1;\n double tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n public static void reverse(final double[] array) {\n if (array != null) {\n reverse(array, 0, array.length);\n }\n }\n}\n```\n"}
29
+ {"task_id": "Java/31", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class CompareToBuilder {\n private int comparison;\n public int toComparison() {\n return comparison;\n }\n public CompareToBuilder appendSuper(final int superCompareTo) {\n if (comparison != 0) {\n return this;\n }\n comparison = superCompareTo;\n return this;\n }\n}\n```\n"}
30
+ {"task_id": "Java/32", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ArrayUtils {\n public static int getLength(final Object array) {\n return array != null ? Array.getLength(array) : 0;\n }\n\n public static boolean isSorted(final float[] array) {\n if (getLength(array) < 2) {\n return true;\n }\n\n float previous = array[0];\n final int n = array.length;\n for (int i = 1; i < n; i++) {\n final float current = array[i];\n if (Float.compare(previous, current) > 0) {\n return false;\n }\n\n previous = current;\n }\n return true;\n }\n}\n```\n"}
31
+ {"task_id": "Java/33", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ExceptionUtils {\n private static final String[] CAUSE_METHOD_NAMES = {\n \"getCause\",\n \"getNextException\",\n \"getTargetException\",\n \"getException\",\n \"getSourceException\",\n \"getRootCause\",\n \"getCausedByException\",\n \"getNested\",\n \"getLinkedException\",\n \"getNestedException\",\n \"getLinkedCause\",\n \"getThrowable\",\n };\n\n public static Throwable getCause(final Throwable throwable, String[] methodNames) {\n if (throwable == null) {\n return null;\n }\n if (methodNames == null) {\n final Throwable cause = throwable.getCause();\n if (cause != null) {\n return cause;\n }\n methodNames = CAUSE_METHOD_NAMES;\n }\n return Stream.of(methodNames).map(m -> getCauseUsingMethodName(throwable, m)).filter(Objects::nonNull).findFirst().orElse(null);\n }\n}\n```\n"}
32
+ {"task_id": "Java/34", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class ArrayUtils {\n public static void reverse(final int[] array, final int startIndexInclusive, final int endIndexExclusive) {\n if (array == null) {\n return;\n }\n int i = Math.max(startIndexInclusive, 0);\n int j = Math.min(array.length, endIndexExclusive) - 1;\n int tmp;\n while (j > i) {\n tmp = array[j];\n array[j] = array[i];\n array[i] = tmp;\n j--;\n i++;\n }\n }\n\n public static void reverse(final int[] array) {\n if (array != null) {\n reverse(array, 0, array.length);\n }\n }\n}\n```\n"}
33
+ {"task_id": "Java/35", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class EnumUtils {\n public static <E extends Enum<E>> E getFirstEnumIgnoreCase(final Class<E> enumClass, final String enumName, final Function<E, String> stringFunction,\n final E defaultEnum) {\n if (enumName == null || !enumClass.isEnum()) {\n return defaultEnum;\n }\n return Stream.of(enumClass.getEnumConstants()).filter(e -> enumName.equalsIgnoreCase(stringFunction.apply(e))).findFirst().orElse(defaultEnum);\n }\n}\n```\n"}
34
+ {"task_id": "Java/36", "prompt": "为以下代码写单测,请不要说明:\n```\npublic class Conversion {\n public static int hexDigitToInt(final char hexDigit) {\n final int digit = Character.digit(hexDigit, 16);\n if (digit < 0) {\n throw new IllegalArgumentException(\"Cannot interpret '\" + hexDigit + \"' as a hexadecimal digit\");\n }\n return digit;\n }\n}\n```\n"}
35
+ {"task_id": "Java/37", "prompt":"为以下代码写单测,请不要说明:\n```\npublic abstract class ToStringStyle implements Serializable {\n public String arrayEnd = \"}\";\n public void setArrayEnd(String arrayEnd) {\n if (arrayEnd == null) {\n arrayEnd = StringUtils.EMPTY;\n }\n this.arrayEnd = arrayEnd;\n }\n}\n```"}
36
+ {"task_id": "Java/38", "prompt":"为以下代码写单测,请不要说明:\n```\npublic abstract class ToStringStyle implements Serializable {\n public void append(final StringBuffer buffer, final String fieldName, final char[] array, final Boolean fullDetail) {\n appendFieldStart(buffer, fieldName);\n\n if (array == null) {\n appendNullText(buffer, fieldName);\n\n } else if (isFullDetail(fullDetail)) {\n appendDetail(buffer, fieldName, array);\n\n } else {\n appendSummary(buffer, fieldName, array);\n }\n\n appendFieldEnd(buffer, fieldName);\n }\n}\n```"}
37
+ {"task_id": "Java/39", "prompt":"为以下代码写单测,请不要说明:\n```\npublic abstract class ToStringStyle implements Serializable {\n public void appendToString(final StringBuffer buffer, final String toString) {\n if (toString != null) {\n final int pos1 = toString.indexOf(contentStart) + contentStart.length();\n final int pos2 = toString.lastIndexOf(contentEnd);\n if (pos1 != pos2 && pos1 >= 0 && pos2 >= 0) {\n if (fieldSeparatorAtStart) {\n removeLastFieldSeparator(buffer);\n }\n buffer.append(toString, pos1, pos2);\n appendFieldSeparator(buffer);\n }\n }\n }\n}\n```"}
eval_data/javascript_eval.jsonl ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"task_id": "JavaScript/0", "prompt": "为以下代码写单测:\n```\nfunction hasCloseElements(numbers, threshold) {\n for (let i = 0; i < numbers.length; i++) {\n for (let j = 0; j < numbers.length; j++) {\n if (i != j) {\n let distance = Math.abs(numbers[i] - numbers[j]);\n if (distance < threshold) {\n return true;\n }\n }\n }\n }\n return false;\n}\n```\n"}
2
+ {"task_id": "JavaScript/1", "prompt": "为以下代码写单测:\n```\nfunction separateParenGroups(paren_string) {\n var result = [];\n var current_string = [];\n var current_depth = 0;\n\n for (const c of paren_string) {\n if (c == '(') {\n current_depth += 1;\n current_string.push(c);\n } else if (c == ')') {\n current_depth -= 1;\n current_string.push(c);\n if (current_depth == 0) {\n result.push(current_string.join(''));\n current_string = [];\n }\n }\n }\n\n return result;\n}\n```\n"}
3
+ {"task_id": "JavaScript/2", "prompt": "为以下代码写单测:\n```\nfunction truncateNumber(number) {\n return number % 1.0;\n}\n```\n"}
4
+ {"task_id": "JavaScript/3", "prompt": "为以下代码写单测:\n```\nfunction belowZero(operations) {\n var balance = 0;\n for (const op of operations) {\n balance += op;\n if (balance < 0) {\n return true;\n }\n }\n return false;\n}\n```\n"}
5
+ {"task_id": "JavaScript/4", "prompt": "为以下代码写单测:\n```\nfunction meanAbsoluteDeviation(numbers) {\n var mean = numbers.reduce((prev, item) => {\n return prev + item;\n }, 0) / numbers.length;\n return numbers.reduce((prev, item) => {\n return prev + Math.abs(item - mean);\n }, 0) / numbers.length;\n\n}\n```\n"}
6
+ {"task_id": "JavaScript/5", "prompt": "为以下代码写单测:\n```\nfunction intersperse(numbers, delimeter) {\n if (!Array.isArray(numbers) || numbers.length == 0)\n return [];\n var result = [];\n for (const n of numbers) {\n result.push(n, delimeter);\n }\n result.pop();\n return result;\n}\n```\n"}
7
+ {"task_id": "JavaScript/6", "prompt": "为以下代码写单测:\n```\nfunction parseNestedParens(paren_string) {\n var parseParenGroup = function (s) {\n let depth = 0, max_depth = 0;\n for (const c of s) {\n if (c == '(') {\n depth += 1;\n max_depth = Math.max(max_depth, depth);\n } else {\n depth -= 1;\n }\n }\n return max_depth;\n }\n return paren_string.split(' ')\n .filter(x => x != '')\n .map(x => parseParenGroup(x));\n}\n```\n"}
8
+ {"task_id": "JavaScript/7", "prompt": "为以下代码写单测:\n```\nfunction filterBySubstring(strings, substring) {\n return strings.filter(x => x.indexOf(substring) != -1);\n}\n```\n"}
9
+ {"task_id": "JavaScript/8", "prompt": "为以下代码写单测:\n```\nfunction sumProduct(numbers, int) {\n var sum_value = 0, prod_value = 1;\n for (const n of numbers) {\n sum_value += n;\n prod_value *= n;\n }\n return [sum_value, prod_value];\n}\n```\n"}
10
+ {"task_id": "JavaScript/9", "prompt": "为以下代码写单测:\n```\nfunction rollingMax(numbers) {\n var running_max, result = [];\n for (const n of numbers) {\n if (running_max == undefined)\n running_max = n;\n else\n running_max = Math.max(running_max, n);\n result.push(running_max);\n }\n return result;\n}\n```\n"}
11
+ {"task_id": "JavaScript/10", "prompt": "为以下代码写单测:\n```\nfunction isPalindrome(string) {\n if (string == '')\n return '';\n var beginning_of_suffix = 0;\n while (!isPalindrome(string.slice(beginning_of_suffix)))\n beginning_of_suffix += 1;\n return string + string.slice(0, beginning_of_suffix).split('').reverse().join('');\n}\n```\n"}
12
+ {"task_id": "JavaScript/11", "prompt": "为以下代码写单测:\n```\nfunction stringXor(a, b) {\n var xor = function (i, j) {\n if (i == j)\n return '0';\n else\n return '1';\n }\n return a.split('').map((item, index) => xor(item, b[index])).join('');\n}\n```\n"}
13
+ {"task_id": "JavaScript/12", "prompt": "为以下代码写单测:\n```\nfunction longest(strings) {\n if (!Array.isArray(strings) || strings.length == 0)\n return null;\n var maxlen = Math.max(...strings.map(x => x.length));\n for (const s of strings) {\n if (s.length == maxlen) {\n return s;\n }\n }\n}\n```\n"}
14
+ {"task_id": "JavaScript/13", "prompt": "为以下代码写单测:\n```\nfunction greatestCommonDivisor(a, b) {\n while (b != 0) {\n let temp = a;\n a = b;\n b = temp % b;\n }\n return a;\n}\n```\n"}
15
+ {"task_id": "JavaScript/14", "prompt": "为以下代码写单测:\n```\nfunction allPrefixes(string) {\n var result = [];\n for (let i = 0; i < string.length; i++) {\n result.push(string.slice(0, i+1));\n }\n return result;\n}\n```\n"}
16
+ {"task_id": "JavaScript/15", "prompt": "为以下代码写单测:\n```\nfunction stringSequence(n) {\n return [...Array(n).keys(), n].join(' ')\n}\n```\n"}
17
+ {"task_id": "JavaScript/16", "prompt": "为以下代码写单测:\n```\nfunction countDistinctCharacters(string) {\n return (new Set(string.toLowerCase())).size;\n\n}\n```\n"}
18
+ {"task_id": "JavaScript/17", "prompt": "为以下代码写单测:\n```\nfunction parseMusic(music_string) {\n const note_map = {'o': 4, 'o|': 2, '.|': 1};\n return music_string.split(' ').filter(x => x != '').map(x => note_map[x]);\n}\n```\n"}
19
+ {"task_id": "JavaScript/18", "prompt": "为以下代码写单测:\n```\nfunction howManyTimes(string, substring) {\n var times = 0;\n for (let i = 0; i < string.length - substring.length + 1; i++) {\n if (string.slice(i, i+substring.length) == substring) {\n times += 1;\n }\n }\n return times;\n}\n```\n"}
20
+ {"task_id": "JavaScript/19", "prompt": "为以下代码写单测:\n```\nfunction sortNumbers(numbers) {\n const value_map = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n };\n return numbers.split(' ')\n .filter(x => x != '')\n .sort((a, b) => value_map[a] - value_map[b])\n .join(' ');\n}\n```\n"}
21
+ {"task_id": "JavaScript/20", "prompt": "为以下代码写单测:\n```\nfunction findClosestElements(numbers) {\n var closest_pair, distance;\n for (let i = 0; i < numbers.length; i++)\n for (let j = 0; j < numbers.length; j++)\n if (i != j) {\n let a = numbers[i], b = numbers[j];\n if (distance == null) {\n distance = Math.abs(a - b);\n closest_pair = [Math.min(a, b), Math.max(a, b)];\n } else {\n let new_distance = Math.abs(a - b);\n if (new_distance < distance) {\n distance = new_distance;\n closest_pair = [Math.min(a, b), Math.max(a, b)];\n }\n }\n }\n return closest_pair;\n}\n```\n"}
22
+ {"task_id": "JavaScript/21", "prompt": "为以下代码写单测:\n```\nfunction rescaleToUnit(numbers) {\n var min_number = Math.min(...numbers);\n var max_number = Math.max(...numbers);\n return numbers.map(x => (x - min_number) / (max_number - min_number));\n}\n```\n"}
23
+ {"task_id": "JavaScript/22", "prompt": "为以下代码写单测:\n```\nfunction filterIntegers(values) {\n return values.filter(x => Number.isInteger(x));\n}\n```\n"}
24
+ {"task_id": "JavaScript/23", "prompt": "为以下代码写单测:\n```\nfunction strlen(string) {\n return string.length;\n}\n```\n"}
25
+ {"task_id": "JavaScript/24", "prompt": "为以下代码写单测:\n```\nfunction largestDivisor(n) {\n for (let i = n - 1; i >= 0; i--)\n if (n % i == 0)\n return i;\n}\n```\n"}
26
+ {"task_id": "JavaScript/25", "prompt": "为以下代码写单测:\n```\nfunction factorize(n) {\n var fact = [], i = 2;\n while (i <= Math.sqrt(n) + 1) {\n if (n % i == 0) {\n fact.push(i);\n n = n / i;\n } else {\n i += 1;\n }\n }\n\n if (n > 1)\n fact.push(n);\n return fact;\n}\n```\n"}
27
+ {"task_id": "JavaScript/26", "prompt": "为以下代码写单测:\n```\nfunction removeDuplicates(numbers) {\n var dict = new Object();\n for (const num of numbers) {\n if (num in dict) {\n dict[num] += 1;\n } else {\n dict[num] = 1;\n }\n }\n return numbers.filter(x => dict[x] <= 1);\n}\n```\n"}
28
+ {"task_id": "JavaScript/27", "prompt": "为以下代码写单测:\n```\nfunction flipCase(string) {\n return string.split('')\n .map(x => (x.toUpperCase() == x ? x.toLowerCase() : x.toUpperCase()))\n .join('');\n}\n```\n"}
29
+ {"task_id": "JavaScript/28", "prompt": "为以下代码写单测:\n```\nfunction concatenate(strings) {\n return strings.join('');\n}\n```\n"}
30
+ {"task_id": "JavaScript/29", "prompt": "为以下代码写单测:\n```\nfunction filterByPrefix(strings, prefix) {\n return strings.filter(x => x.startsWith(prefix));\n}\n```\n"}
31
+ {"task_id": "JavaScript/30", "prompt": "为以下代码写单测:\n```\nfunction getPositive(l) {\n return l.filter(e => e > 0);\n}\n```\n"}
32
+ {"task_id": "JavaScript/31", "prompt": "为以下代码写单测:\n```\nfunction isPrime(n) {\n if (n < 2)\n return false;\n for (let k = 2; k < n - 1; k++)\n if (n % k == 0)\n return false;\n return true;\n}\n```\n"}
33
+ {"task_id": "JavaScript/32", "prompt": "为以下代码写单测:\n```\nfunction poly(xs, x) {\n var begin = -1.0, end = 1.0;\n while (poly(xs, begin) * poly(xs, end) > 0) {\n begin *= 2.0;\n end *= 2.0;\n }\n while (end - begin > 1e-10) {\n let center = (begin + end) / 2.0;\n if (poly(xs, center) * poly(xs, begin) > 0)\n begin = center;\n else\n end = center;\n }\n return begin;\n}\n```\n"}
34
+ {"task_id": "JavaScript/33", "prompt": "为以下代码写单测:\n```\nfunction sortThird(l) {\n var three = l.filter((item, index) => index % 3 == 0);\n three.sort((a, b) => (a - b));\n return l.map((item, index) => (index % 3 == 0 ? three[index / 3] : item));\n}\n```\n"}
35
+ {"task_id": "JavaScript/34", "prompt": "为以下代码写单测:\n```\nfunction unique(l) {\n return Array.from(new Set(l)).sort((a, b) => (a - b));\n}\n```\n"}
36
+ {"task_id": "JavaScript/35", "prompt": "为以下代码写单���:\n```\nfunction maxElement(l) {\n return Math.max(...l);\n}\n```\n"}
37
+ {"task_id": "JavaScript/36", "prompt": "为以下代码写单测:\n```\nfunction fizzBuzz(n) {\n var ns = [], ans = 0;\n for (let i = 0; i < n; i++)\n if (i % 11 == 0 || i % 13 == 0)\n ns.push(i);\n var s = ns.map(x => x.toString()).join('');\n for (const c of s)\n ans += (c == '7');\n return ans;\n}\n```\n"}
38
+ {"task_id": "JavaScript/37", "prompt": "为以下代码写单测:\n```\nfunction sortEven(l) {\n var even = l.filter((item, index) => index % 2 == 0);\n even.sort((a, b) => (a - b));\n return l.map((item, index) => (index % 2 == 0 ? even[index / 2] : item));\n}\n```\n"}
39
+ {"task_id": "JavaScript/38", "prompt": "为以下代码写单测:\n```\nfunction encodeCyclic(s) {\n return encodeCyclic(encodeCyclic(s));\n}\n```\n"}
40
+ {"task_id": "JavaScript/39", "prompt": "为以下代码写单测:\n```\nfunction primeFib(n) {\n var isPrime = function (p) {\n if (p < 2)\n return false;\n for (let k = 2; k < Math.min(Math.floor(Math.sqrt(p)) + 1, p - 1); k++) {\n if (p % k == 0)\n return false;\n }\n return true;\n }\n\n var f = [0, 1];\n while (true) {\n f.push(f.at(-1) + f.at(-2));\n if (isPrime(f.at(-1)))\n n -= 1;\n if (n == 0)\n return f.at(-1);\n }\n}\n```\n"}
41
+ {"task_id": "JavaScript/40", "prompt": "为以下代码写单测:\n```\nfunction triplesSumToZero(l) {\n for (let i = 0; i < l.length; i++)\n for (let j = i + 1; j < l.length; j++)\n for (let k = j + 1; k < l.length; k++)\n if (l[i] + l[j] + l[k] == 0)\n return true;\n return false;\n}\n```\n"}
42
+ {"task_id": "JavaScript/41", "prompt": "为以下代码写单测:\n```\nfunction carRaceCollision(n) {\n return Math.pow(n, 2);\n}\n```\n"}
43
+ {"task_id": "JavaScript/42", "prompt": "为以下代码写单测:\n```\nfunction incrList(l) {\n return l.map(e => e + 1);\n}\n```\n"}
44
+ {"task_id": "JavaScript/43", "prompt": "为以下代码写单测:\n```\nfunction pairsSumToZero(l) {\n for (let i = 0; i < l.length; i++)\n for (let j = i + 1; j < l.length; j++)\n if (l[i] + l[j] == 0)\n return true;\n return false;\n}\n```\n"}
45
+ {"task_id": "JavaScript/44", "prompt": "为以下代码写单测:\n```\nfunction changeBase(x, base) {\n var ret = \"\";\n while (x > 0) {\n ret = (x % base).toString() + ret;\n x = Math.floor(x / base);\n }\n return ret;\n}\n```\n"}
46
+ {"task_id": "JavaScript/45", "prompt": "为以下代码写单测:\n```\nfunction triangleArea(a, h) {\n return a * h / 2.0;\n}\n```\n"}
47
+ {"task_id": "JavaScript/46", "prompt": "为以下代码写单测:\n```\nfunction fib4(n) {\n var results = [0, 0, 2, 0];\n if (n < 4)\n return results[n];\n for (let i = 4; i < n + 1; i++) {\n results.push(results.at(-1) + results.at(-2) +\n results.at(-3) + results.at(-4));\n results.shift();\n }\n return results.pop();\n}\n```\n"}
48
+ {"task_id": "JavaScript/47", "prompt": "为以下代码写单测:\n```\nfunction median(l) {\n l.sort((a, b) => a - b);\n var len = l.length;\n if (l.length % 2 == 1)\n return l[Math.floor(len / 2)];\n else\n return (l[len / 2 - 1] + l[len / 2]) / 2.0;\n}\n```\n"}
49
+ {"task_id": "JavaScript/48", "prompt": "为以下代码写单测:\n```\nfunction isPalindrome(text) {\n for (let i = 0; i < text.length; i++)\n if (text[i] != text.at(-i-1))\n return false;\n return true;\n}\n```\n"}
50
+ {"task_id": "JavaScript/49", "prompt": "为以下代码写单测:\n```\nfunction modp(n, p) {\n var ret = 1;\n for (let i = 0; i < n; i++)\n ret = (2 * ret) % p;\n return ret;\n}\n```\n"}
51
+ {"task_id": "JavaScript/50", "prompt": "为以下代码写单测:\n```\nfunction encodeShift(s) {\n return s.split(\"\").map(ch => String.fromCharCode(\n ((ch.charCodeAt(0) - 5 + 26 - \"a\".charCodeAt(0)) % 26) + \"a\".charCodeAt(0)\n )).join(\"\");\n}\n```\n"}
52
+ {"task_id": "JavaScript/51", "prompt": "为以下代码写单测:\n```\nfunction removeVowels(text) {\n return text.split(\"\")\n .filter(s => ![\"a\", \"e\", \"i\", \"o\", \"u\"]\n .includes(s.toLowerCase())\n )\n .join(\"\")\n}\n```\n"}
53
+ {"task_id": "JavaScript/52", "prompt": "为以下代码写单测:\n```\nfunction belowThreshold(l, t) {\n for (const e of l)\n if (e >= t)\n return false;\n return true;\n}\n```\n"}
54
+ {"task_id": "JavaScript/53", "prompt": "为以下代码写单测:\n```\nfunction add(x, y) {\n return x + y;\n}\n```\n"}
55
+ {"task_id": "JavaScript/54", "prompt": "为以下代码写单测:\n```\nfunction sameChars(s0, s1) {\n return JSON.stringify([...new Set(s0)].sort()) === JSON.stringify([...new Set(s1)].sort());\n}\n```\n"}
56
+ {"task_id": "JavaScript/55", "prompt": "为以下代码写单测:\n```\nfunction fib(n) {\n if (n == 0)\n return 0;\n if (n == 1)\n return 1;\n return fib(n - 1) + fib(n - 2);\n}\n```\n"}
57
+ {"task_id": "JavaScript/56", "prompt": "为以下代码写单测:\n```\nfunction correctBracketing(brackets) {\n var depth = 0;\n for (const b of brackets) {\n if (b == \"<\")\n depth += 1;\n else\n depth -= 1;\n if (depth < 0)\n return false;\n }\n return depth == 0;\n}\n```\n"}
58
+ {"task_id": "JavaScript/57", "prompt": "为以下代码写单测:\n```\nfunction monotonic(l) {\n var sort1 = [...l].sort((a, b) => a - b);\n var sort2 = [...l].sort((a, b) => b - a);\n if (JSON.stringify(l) === JSON.stringify(sort1) ||\n JSON.stringify(l) === JSON.stringify(sort2))\n return true;\n return false;\n}\n```\n"}
59
+ {"task_id": "JavaScript/58", "prompt": "为以下代码写单测:\n```\nfunction common(l1, l2) {\n var ret = new Set();\n for (const e1 of l1)\n for (const e2 of l2)\n if (e1 == e2)\n ret.add(e1);\n return [...ret].sort();\n}\n```\n"}
60
+ {"task_id": "JavaScript/59", "prompt": "为以下代码写单测:\n```\nfunction largestPrimeFactor(n) {\n var isPrime = function (k) {\n if (k < 2)\n return false;\n for (let i = 2; i < k - 1; i++)\n if (k % i == 0)\n return false;\n return true;\n }\n\n var largest = 1;\n for (let j = 2; j < n + 1; j++)\n if (n % j == 0 && isPrime(j))\n largest = Math.max(largest, j);\n return largest;\n}\n```\n"}
61
+ {"task_id": "JavaScript/60", "prompt": "为以下代码写单测:\n```\nfunction sumToN(n) {\n return n * (n + 1) / 2;\n}\n```\n"}
62
+ {"task_id": "JavaScript/61", "prompt": "为以下代码写单测:\n```\nfunction correctBracketing(brackets) {\n var depth = 0;\n for (const b of brackets) {\n if (b == \"(\")\n depth += 1;\n else\n depth -= 1;\n if (depth < 0)\n return false;\n }\n return depth == 0;\n}\n```\n"}
63
+ {"task_id": "JavaScript/62", "prompt": "为以下代码写单测:\n```\nfunction derivative(xs) {\n return xs.map((x, i) => x * i).slice(1);\n}\n```\n"}
64
+ {"task_id": "JavaScript/63", "prompt": "为以下代码写单测:\n```\nfunction fibfib(n) {\n if (n == 0 || n == 1)\n return 0;\n if (n == 2)\n return 1;\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3);\n}\n```\n"}
65
+ {"task_id": "JavaScript/64", "prompt": "为以下代码写单测:\n```\nfunction vowelsCount(s) {\n var vowels = \"aeiouAEIOU\";\n var n_vowels = s.split('').reduce((prev, item) => {\n return prev + (vowels.includes(item));\n }, 0);\n if (s.at(-1) == 'y' || s.at(-1) == 'Y')\n n_vowels += 1;\n return n_vowels;\n}\n```\n"}
66
+ {"task_id": "JavaScript/65", "prompt": "为以下代码写单测:\n```\nfunction circularShift(x, shift) {\n s = x.toString();\n if (shift > s.length)\n return s.split('').reverse().join('');\n else\n return s.slice(-shift) + s.slice(0, -shift);\n}\n```\n"}
67
+ {"task_id": "JavaScript/66", "prompt": "为以下代码写单测:\n```\nfunction digitSum(s) {\n if (s == '') return 0;\n return s.split('').reduce((prev, char) => {\n let ord_char = char.charCodeAt(0)\n return prev + (ord_char > 64 && ord_char < 91 ? ord_char : 0);\n }, 0);\n}\n```\n"}
68
+ {"task_id": "JavaScript/67", "prompt": "为以下代码写单测:\n```\nfunction fruitDistribution(s, n) {\n var lis = [];\n for (const i of s.split(\" \"))\n if (!isNaN(i))\n lis.push(Number(i))\n return n - lis.reduce(((prev, item) => prev + item), 0);\n}\n```\n"}
69
+ {"task_id": "JavaScript/68", "prompt": "为以下代码写单测:\n```\nfunction pluck(arr) {\n if (arr.length == 0) return [];\n var evens = arr.filter(x => x % 2 == 0);\n if (evens.length == 0) return [];\n return [Math.min(...evens), arr.indexOf(Math.min(...evens))];\n}\n```\n"}
70
+ {"task_id": "JavaScript/69", "prompt": "为以下代码写单测:\n```\nfunction search(lst) {\n var frq = new Array(Math.max(...lst) + 1).fill(0);\n for (const i of lst)\n frq[i] += 1;\n var ans = -1;\n for (let i = 1; i < frq.length; i++)\n if (frq[i] >= i)\n ans = i;\n return ans;\n}\n```\n"}
71
+ {"task_id": "JavaScript/70", "prompt": "为以下代码写单测:\n```\nfunction strangeSortList(lst) {\n var res = [], sw = true;\n while (lst.length) {\n res.push(sw ? Math.min(...lst) : Math.max(...lst));\n lst.splice(lst.indexOf(res.at(-1)), 1);\n sw = !sw;\n }\n return res;\n}\n```\n"}
72
+ {"task_id": "JavaScript/71", "prompt": "为以下代码写单测:\n```\nfunction triangleArea(a, b, c) {\n if (a + b <= c || a + c <= b || b + c <= a)\n return -1;\n var s = (a + b + c) / 2;\n var area = Math.pow(s * (s - a) * (s - b) * (s - c), 0.5);\n area = area.toFixed(2);\n return area;\n}\n```\n"}
73
+ {"task_id": "JavaScript/72", "prompt": "为以下代码写单测:\n```\nfunction willItFly(q, w) {\n if (q.reduce(((prev, item) => prev + item), 0) > w)\n return false;\n var i = 0, j = q.length - 1;\n while (i < j) {\n if (q[i] != q[j])\n return false;\n i++;\n j--;\n }\n return true;\n}\n```\n"}
74
+ {"task_id": "JavaScript/73", "prompt": "为以下代码写单测:\n```\nfunction smallestChange(arr) {\n var ans = 0;\n for (let i = 0; i < Math.floor(arr.length / 2); i++)\n if (arr[i] != arr.at(-i - 1))\n ans++;\n return ans;\n}\n```\n"}
75
+ {"task_id": "JavaScript/74", "prompt": "为以下代码写单测:\n```\nfunction totalMatch(lst1, lst2) {\n var l1 = lst1.reduce(((prev, item) => prev + item.length), 0);\n var l2 = lst2.reduce(((prev, item) => prev + item.length), 0);\n if (l1 <= l2)\n return lst1;\n else\n return lst2;\n}\n```\n"}
76
+ {"task_id": "JavaScript/75", "prompt": "为以下代码写单测:\n```\nfunction isMultiplyPrime(a) {\n var isPrime = function (n) {\n for (let j = 2; j < n; j++)\n if (n % j == 0)\n return false;\n return true;\n }\n\n for (let i = 2; i < 101; i++) {\n if (!isPrime(i)) continue;\n for (let j = 2; j < 101; j++) {\n if (!isPrime(j)) continue;\n for (let k = 2; k < 101; k++) {\n if (!isPrime(k)) continue;\n if (i*j*k == a)\n return true;\n }\n }\n }\n return false;\n}\n```\n"}
77
+ {"task_id": "JavaScript/76", "prompt": "为以下代码写单测:\n```\nfunction isSimplePower(x, n) {\n if (n == 1)\n return (x == 1);\n var power = 1;\n while (power < x)\n power = power * n;\n return (power == x);\n}\n```\n"}
78
+ {"task_id": "JavaScript/77", "prompt": "为以下代码写单测:\n```\nfunction iscube(a) {\n a = Math.abs(a);\n return (Math.pow(Math.round(Math.pow(a, 1.0 / 3.0)), 3) == a);\n}\n```\n"}
79
+ {"task_id": "JavaScript/78", "prompt": "为以下代码写单测:\n```\nfunction hexKey(num) {\n var primes = \"2357BD\",\n total = 0;\n for (let i = 0; i < num.length; i++)\n if (primes.includes(num[i]))\n total++;\n return total;\n}\n```\n"}
80
+ {"task_id": "JavaScript/79", "prompt": "为以下代码写单测:\n```\nfunction decimalToBinary(decimal) {\n return \"db\" + decimal.toString(2) + \"db\";\n}\n```\n"}
81
+ {"task_id": "JavaScript/80", "prompt": "为以下代码写单测:\n```\nfunction isHappy(s) {\n if (s.length < 3)\n return false;\n for (let i = 0; i < s.length - 2; i++)\n if (s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2])\n return false;\n return true;\n}\n```\n"}
82
+ {"task_id": "JavaScript/81", "prompt": "为以下代码写单测:\n```\nfunction numericalLetterGrade(grades) {\n let letter_grade = []\n for (let i = 0, len = grades.length; i < len; i++) {\n let gpa = grades[i]\n if (gpa == 4.0) {\n letter_grade.push('A+')\n } else if (gpa > 3.7) {\n letter_grade.push('A')\n } else if (gpa > 3.3) {\n letter_grade.push('A-')\n } else if (gpa > 3.0) {\n letter_grade.push('B+')\n } else if (gpa > 2.7) {\n letter_grade.push('B')\n } else if (gpa > 2.3) {\n letter_grade.push('B-')\n } else if (gpa > 2.0) {\n letter_grade.push('C+')\n } else if (gpa > 1.7) {\n letter_grade.push('C')\n } else if (gpa > 1.3) {\n letter_grade.push('C-')\n } else if (gpa > 1.0) {\n letter_grade.push('D+')\n } else if (gpa > 0.7) {\n letter_grade.push('D')\n } else if (gpa > 0.0) {\n letter_grade.push('D-')\n } else {\n letter_grade.push('E')\n }\n }\n return letter_grade\n}\n```\n"}
83
+ {"task_id": "JavaScript/82", "prompt": "为以下代码写单测:\n```\nfunction primeLength(string) {\n let len = string.length\n if (len == 1 || len == 0) { return false }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { return false }\n }\n return true\n}\n```\n"}
84
+ {"task_id": "JavaScript/83", "prompt": "为以下代码写单测:\n```\nfunction startsOneEnds(n) {\n if (n == 1) { return 1 }\n let t = 18\n for (let i = 2; i < n; i++) {\n t = t * 10\n }\n return t\n}\n```\n"}
85
+ {"task_id": "JavaScript/84", "prompt": "为以下代码写单测:\n```\nfunction solve(N) {\n let t = 0\n while (N > 0) {\n t += N % 10\n N = (N - N % 10) / 10\n }\n return t.toString(2)\n}\n```\n"}
86
+ {"task_id": "JavaScript/85", "prompt": "为以下代码写单测:\n```\nfunction add(lst) {\n let t = 0\n for (let i = 1; i < lst.length; i += 2) {\n if (lst[i] % 2 == 0) {\n t += lst[i]\n }\n }\n return t\n}\n```\n"}
87
+ {"task_id": "JavaScript/86", "prompt": "为以下代码写单测:\n```\nfunction antiShuffle(s) {\n let arr = s.split(/\\s/)\n for (let i = 0; i < arr.length; i++) {\n for (let j = 0; j < arr[i].length; j++) {\n let ind = j\n for (let k = j + 1; k < arr[i].length; k++) {\n if (arr[i][k].charCodeAt() < arr[i][ind].charCodeAt()) {\n ind = k\n }\n }\n if (ind > j) {\n arr[i] = arr[i].slice(0, j) + arr[i][ind] + arr[i].slice(j + 1, ind) + arr[i][j] + arr[i].slice(ind + 1, arr[i].length)\n }\n }\n }\n let t = ''\n for (let i = 0; i < arr.length; i++) {\n if (i > 0) {\n t = t + ' '\n }\n t = t + arr[i]\n }\n return t\n}\n```\n"}
88
+ {"task_id": "JavaScript/87", "prompt": "为以下代码写单测:\n```\nfunction getRow(lst, x) {\n let t = []\n for (let i = 0; i < lst.length; i++) {\n for (let j = lst[i].length - 1; j >= 0; j--) {\n if (lst[i][j] == x) {\n t.push((i, j))\n }\n }\n }\n return t\n}\n```\n"}
89
+ {"task_id": "JavaScript/88", "prompt": "为以下代码写单测:\n```\nfunction sortArray(array) {\n let arr = array\n let tot = arr[0] + arr[arr.length-1]\n for (let j = 0; j < arr.length; j++) {\n let ind = j\n for (let k = j + 1; k < arr.length; k++) {\n if ((tot % 2 == 1 && arr[k] < arr[ind]) || (tot % 2 == 0 && arr[k] > arr[ind])) {\n ind = k\n }\n }\n let tmp = arr[j]\n arr[j] = arr[ind]\n arr[ind] = tmp\n }\n return arr\n}\n```\n"}
90
+ {"task_id": "JavaScript/89", "prompt": "为以下代码写单测:\n```\nfunction encrypt(s) {\n let t = ''\n for (let i = 0; i < s.length; i++) {\n let p = s[i].charCodeAt() + 4\n if (p > 122) { p -= 26 }\n t += String.fromCharCode(p)\n }\n return t\n}\n```\n"}
91
+ {"task_id": "JavaScript/90", "prompt": "为以下代码写单测:\n```\nfunction nextSmallest(lst) {\n let arr = lst\n for (let j = 0; j < arr.length; j++) {\n let ind = j\n for (let k = j + 1; k < arr.length; k++) {\n if (arr[k] < arr[ind]) {\n ind = k\n }\n }\n let tmp = arr[j]\n arr[j] = arr[ind]\n arr[ind] = tmp\n }\n let smallest = arr[0]\n let pt = 1\n while(pt<arr.length){\n if(arr[pt]>smallest){\n return arr[pt]\n }\n pt++\n }\n return null\n}\n```\n"}
92
+ {"task_id": "JavaScript/91", "prompt": "为以下代码写单测:\n```\nfunction isBored(S) {\n let t = 0\n if (S[0] == 'I' && S[1] == ' ') { t = 1 }\n for (let i = 0; i < S.length; i++) {\n if (S[i] == '.' || S[i] == '!' || S[i] == '?') {\n if (S[i + 1] == ' ' && S[i + 2] == 'I' && S[i + 3] == ' ') {\n t++\n }\n }\n }\n return t\n}\n```\n"}
93
+ {"task_id": "JavaScript/92", "prompt": "为以下代码写单测:\n```\nfunction anyInt(x, y, z) {\n if (x % 1 === 0 && y % 1 === 0 && z % 1 === 0 && (x + y === z || x + z === y || x === y + z)) {\n return true\n }\n return false\n}\n```\n"}
94
+ {"task_id": "JavaScript/93", "prompt": "为以下代码写单测:\n```\nfunction encode(message) {\n let t = ''\n for (let i = 0; i < message.length; i++) {\n let p = message[i].charCodeAt()\n if (p > 96) { p -= 32 }\n else if (p!=32 && p < 96) { p += 32 }\n if (p == 65 || p == 97 || p == 69 || p == 101 || p == 73 || p == 105 || p == 79 || p == 111 || p == 85 || p == 117) { p += 2 }\n t += String.fromCharCode(p)\n }\n return t\n}\n```\n"}
95
+ {"task_id": "JavaScript/94", "prompt": "为以下代码写单测:\n```\nfunction skjkasdkd(lst) {\n let t = 0\n for (let i = 0; i < lst.length; i++) {\n let p = 1\n for (let j = 2; j * j <= lst[i]; j++) {\n if (lst[i] % j == 0) { p = 0; break }\n }\n if (p == 1 && lst[i] > t) { t = lst[i] }\n }\n let k = 0\n while (t != 0) {\n k += t % 10\n t = (t - t % 10) / 10\n }\n return k\n}\n```\n"}
96
+ {"task_id": "JavaScript/95", "prompt": "为以下代码写单测:\n```\nfunction checkDictCase(dict) {\n let c = 0\n let lo = 1\n let hi = 1\n for (let key in dict) {\n c++\n for (let i = 0; i < key.length; i++) {\n if (key[i].charCodeAt() < 65 || key[i].charCodeAt() > 90) { hi = 0 }\n if (key[i].charCodeAt() < 97 || key[i].charCodeAt() > 122) { lo = 0 }\n }\n }\n if ((lo == 0 && hi == 0) || c == 0) { return false }\n return true\n}\n```\n"}
97
+ {"task_id": "JavaScript/96", "prompt": "为以下代码写单测:\n```\nfunction countUpTo(n) {\n let t = []\n for (let i = 2; i < n; i++) {\n let p = 1\n for (let j = 2; j * j <= i; j++) {\n if (i % j == 0) { p = 0; break }\n }\n if (p == 1) { t.push(i) }\n }\n return t\n}\n```\n"}
98
+ {"task_id": "JavaScript/97", "prompt": "为以下代码写单测:\n```\nfunction multiply(a, b) {\n if (a < 0) { a = -a }\n if (b < 0) { b = -b }\n return (a % 10) * (b % 10)\n}\n```\n"}
99
+ {"task_id": "JavaScript/98", "prompt": "为以下代码写单测:\n```\nfunction countUpper(s) {\n let p = 0\n for (let i = 0; i < s.length; i += 2) {\n if (s[i] == 'A' || s[i] == 'E' || s[i] == 'I' || s[i] == 'O' || s[i] == 'U') { p++ }\n }\n return p\n}\n```\n"}
100
+ {"task_id": "JavaScript/99", "prompt": "为以下代码写单测:\n```\nfunction closestInteger(value) {\n value = Number(value)\n let t = value % 1\n if (t < 0.5 && t > -0.5) { value -= t }\n else { value += t }\n return value\n}\n```\n"}
101
+ {"task_id": "JavaScript/100", "prompt": "为以下代码写单测:\n```\nfunction makeAPile(n) {\n let t = []\n for (let i = n; i < n * 3; i += 2) {\n t.push(i)\n }\n return t\n}\n```\n"}
102
+ {"task_id": "JavaScript/101", "prompt": "为以下代码写单测:\n```\nfunction wordsString(s) {\n let t = ''\n let p = []\n let k = 0\n for (let i = 0; i < s.length; i++) {\n if (s[i] == ' ' || s[i] == ',') {\n if (k == 0) {\n k = 1;\n p.push(t);\n t = '';\n }\n }\n else {\n k = 0;\n t += s[i]\n }\n }\n if (t != '') {\n p.push(t);\n }\n return p\n}\n```\n"}
103
+ {"task_id": "JavaScript/102", "prompt": "为以下代码写单测:\n```\nfunction chooseNum(x, y) {\n for (let i = y; i >= x; i--) {\n if (i % 2 == 0) {return i }\n }\n return -1\n}\n```\n"}
104
+ {"task_id": "JavaScript/103", "prompt": "为以下代码写单测:\n```\nfunction roundedAvg(n, m) {\n if (n > m) { return -1 }\n let k = (n + m) / 2\n if (k % 1 != 0) { k = (n + m + 1) / 2 }\n return '0b' + k.toString(2)\n}\n```\n"}
105
+ {"task_id": "JavaScript/104", "prompt": "为以下代码写单测:\n```\nfunction uniqueDigits(x) {\n let p = []\n for (let i = 0; i < x.length; i++) {\n let h = x[i]\n let boo = 1\n while (h > 0) {\n let r = h % 10\n if (r % 2 == 0) {\n boo = 0;\n break;\n }\n h = (h - r) / 10\n }\n if (boo) {\n p.push(x[i])\n }\n }\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] < p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n return p\n}\n```\n"}
106
+ {"task_id": "JavaScript/105", "prompt": "为以下代码写单测:\n```\nfunction byLength(arr) {\n p = []\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] > 0 && arr[i] < 10) { p.push(arr[i]) }\n }\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] > p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n let l = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']\n let t = []\n for (let j = 0; j < p.length; j++) {\n t.push(l[p[j]-1])\n }\n return t\n}\n```\n"}
107
+ {"task_id": "JavaScript/106", "prompt": "为以下代码写单测:\n```\nfunction f(n) {\n let f = 1\n let p = 0\n let k = []\n for (let i = 1; i <= n; i++) {\n p += i;\n f *= i;\n if (i % 2 == 0) { k.push(f) }\n else { k.push(p) }\n }\n return k\n}\n```\n"}
108
+ {"task_id": "JavaScript/107", "prompt": "为以下代码写单测:\n```\nfunction evenOddPalindrome(n) {\n let e = 0\n let o = 0\n for (let i = 1; i <= n; i++) {\n let k = i.toString()\n let p = 1\n for (let j = 0; j < k.length; j++) {\n if (k[j] != k[k.length - j - 1]) {\n p = 0;\n break;\n }\n }\n if (p == 1) {\n if (k % 2 == 0) { e++ }\n else { o++ }\n }\n }\n return (e, o)\n}\n```\n"}
109
+ {"task_id": "JavaScript/108", "prompt": "为以下代码写单测:\n```\nfunction countNums(arr) {\n let p = 0\n for (let i = 0; i < arr.length; i++) {\n let h = arr[i]\n if (h > 0) {\n p++;\n continue;\n }\n let k = 0\n h = -h\n while (h >= 10) {\n k += h % 10;\n h = (h - h % 10) / 10;\n }\n k -= h;\n if (k > 0) { p++ }\n }\n return p\n}\n```\n"}
110
+ {"task_id": "JavaScript/109", "prompt": "为以下代码写单测:\n```\nfunction moveOneBall(arr) {\n if (arr.length == 0) { return true }\n let k = 0\n let len = arr.length\n for (let i = 0; i < len; i++) {\n let t = 1;\n for (let j = 1; j < len; j++) {\n if (arr[j] < arr[j - 1]) {\n t = 0;\n break;\n }\n }\n if (t == 1) {\n k = 1;\n break;\n }\n arr.push(arr[0]);\n arr.shift()\n }\n if (k == 1) { return true }\n return false\n}\n```\n"}
111
+ {"task_id": "JavaScript/110", "prompt": "为以下代码写单测:\n```\nfunction exchange(lst1, lst2) {\n let k = lst1.length\n let t = 0\n for (let i = 0; i < lst1.length; i++) {\n if (lst1[i] % 2 == 0) { t++ }\n }\n for (let i = 0; i < lst2.length; i++) {\n if (lst2[i] % 2 == 0) { t++ }\n }\n if (t >= k) { return 'YES' }\n return 'NO'\n}\n```\n"}
112
+ {"task_id": "JavaScript/111", "prompt": "为以下代码写单测:\n```\nfunction histogram(test) {\n let d = {}\n let t = test.split(/\\s/)\n if (test == '') { t = [] }\n for (m in t) {\n if (t[m] in d) {\n d[t[m]]++\n }\n else {\n d[t[m]] = 1\n }\n }\n s = Object.keys(d).sort(function (a, b) { return - d[a] + d[b]; });\n if (s.length == 0) { return {} }\n let g = d[s[0]]\n let l = {}\n for (let ss=0; ss<s.length; ss++) {\n if (d[s[ss]] == g) {\n l[s[ss]] = d[s[ss]]\n }\n }\n return l\n}\n```\n"}
113
+ {"task_id": "JavaScript/112", "prompt": "为以下代码写单测:\n```\nfunction reverseDelete(s, c) {\n let t = ''\n for (let i = 0; i < s.length; i++) {\n let y = 1\n for (let j = 0; j < c.length; j++) {\n if (s[i] == c[j]) {\n y = 0\n }\n }\n if (y == 1) {\n t += s[i]\n }\n }\n let z = 1\n for (let i = 0; i < t.length; i++) {\n if (t[i] != t[t.length - i - 1]) {\n z = 0\n }\n }\n if (z == 0) {\n return (z, false)\n }\n return (z, true)\n}\n```\n"}
114
+ {"task_id": "JavaScript/113", "prompt": "为以下代码写单测:\n```\nfunction oddCount(lst) {\n let d = []\n for (let i = 0; i < lst.length; i++) {\n let p = 0;\n let h = lst[i].length\n for (let j = 0; j < h; j++) {\n if (lst[i][j].charCodeAt() % 2 == 1) { p++ }\n }\n p = p.toString()\n d.push('the number of odd elements ' + p + 'n the str' + p + 'ng ' + p + ' of the ' + p + 'nput.')\n }\n return d\n}\n```\n"}
115
+ {"task_id": "JavaScript/114", "prompt": "为以下代码写单测:\n```\nfunction minSubArraySum(nums) {\n let min = nums[0]\n for (let i = 0; i < nums.length; i++) {\n for (let j = i + 1; j <= nums.length; j++) {\n let s = 0;\n for (let k = i; k < j; k++) {\n s += nums[k]\n }\n if (s < min) { min = s }\n }\n }\n return min\n}\n```\n"}
116
+ {"task_id": "JavaScript/115", "prompt": "为以下代码写单测:\n```\nfunction maxFill(grid, capacity) {\n let p = 0\n for (let i = 0; i < grid.length; i++) {\n let m = 0\n for (let j = 0; j < grid[i].length; j++) {\n if (grid[i][j] == 1) { m++ }\n }\n while (m > 0) {\n m -= capacity;\n p++;\n }\n }\n return p\n}\n```\n"}
117
+ {"task_id": "JavaScript/116", "prompt": "为以下代码写单测:\n```\nfunction sortArray(arr) {\n let p = arr\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n let w1 = p[ind].toString(2)\n let f1 = 0\n for (let u = 0; u < w1.length; u++) {\n if (w1[u] == '1') { f1++ }\n }\n let w2 = p[k].toString(2)\n let f2 = 0\n for (let u = 0; u < w2.length; u++) {\n if (w2[u] == '1') { f2++ }\n }\n if (f2 < f1 || (f1 == f2 && p[k] < p[ind])) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n return p\n}\n```\n"}
118
+ {"task_id": "JavaScript/117", "prompt": "为以下代码写单测:\n```\nfunction selectWords(s, n) {\n let t = s.split(/\\s/)\n if (s == '') { return [] }\n let k = []\n for (let i = 0; i < t.length; i++) {\n let l = 0\n for (let j = 0; j < t[i].length; j++) {\n if (t[i][j] != 'a' && t[i][j] != 'e' && t[i][j] != 'i' && t[i][j] != 'o' && t[i][j] != 'u' && t[i][j] != 'A' &&\n t[i][j] != 'U' && t[i][j] != 'O' && t[i][j] != 'I' && t[i][j] != 'E') {\n l++\n }\n }\n if (l == n) { k.push(t[i]) }\n }\n return k\n}\n```\n"}
119
+ {"task_id": "JavaScript/118", "prompt": "为以下代码写单测:\n```\nfunction getClosestVowel(word) {\n for (let i = word.length - 2; i > 0; i--) {\n if (\n !(word[i] != 'a' && word[i] != 'e' && word[i] != 'i' && word[i] != 'o' && word[i] != 'u' && word[i] != 'A' &&\n word[i] != 'U' && word[i] != 'O' && word[i] != 'I' && word[i] != 'E')\n &&\n (word[i + 1] != 'a' && word[i + 1] != 'e' && word[i + 1] != 'i' && word[i + 1] != 'o' && word[i + 1] != 'u' && word[i + 1] != 'A' &&\n word[i + 1] != 'U' && word[i + 1] != 'O' && word[i + 1] != 'I' && word[i + 1] != 'E')\n &&\n (word[i - 1] != 'a' && word[i - 1] != 'e' && word[i - 1] != 'i' && word[i - 1] != 'o' && word[i - 1] != 'u' && word[i - 1] != 'A' &&\n word[i - 1] != 'U' && word[i - 1] != 'O' && word[i - 1] != 'I' && word[i - 1] != 'E')\n ) {\n return word[i]\n }\n }\n return ''\n}\n```\n"}
120
+ {"task_id": "JavaScript/119", "prompt": "为以下代码写单测:\n```\nfunction matchParens(lst) {\n let w1 = lst[0] + lst[1]\n let y = 0\n let u = 1\n for (let i = 0; i < w1.length; i++) {\n if (w1[i] == '(') { y++ }\n else { y-- }\n if (y < 0) {\n u = 0;\n break;\n }\n }\n if (u == 1 && y == 0) { return 'Yes' }\n w1 = lst[1] + lst[0]\n y = 0\n u = 1\n for (let i = 0; i < w1.length; i++) {\n if (w1[i] == '(') { y++ }\n else { y-- }\n if (y < 0) {\n u = 0;\n break;\n }\n }\n if (u == 1 && y == 0) { return 'Yes' }\n return 'No'\n}\n```\n"}
121
+ {"task_id": "JavaScript/120", "prompt": "为以下代码写单测:\n```\nfunction maximum(arr, k) {\n let p = arr\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] < p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n if (k == 0) { return [] }\n return p.slice(-k)\n}\n```\n"}
122
+ {"task_id": "JavaScript/121", "prompt": "为以下代码写单测:\n```\nfunction solution(lst) {\n let p = 0\n for (let i = 0; i < lst.length; i += 2) {\n if (lst[i] % 2 == 1) {\n p += lst[i]\n }\n }\n return p\n}\n```\n"}
123
+ {"task_id": "JavaScript/122", "prompt": "为以下代码写单测:\n```\nfunction addElements(arr, k) {\n let p = 0\n for (let i = 0; i < k; i++) {\n if (arr[i] < 100 && arr[i] > -100) { p += arr[i] }\n }\n return p\n}\n```\n"}
124
+ {"task_id": "JavaScript/123", "prompt": "为以下代码写单测:\n```\nfunction getOddCollatz(n) {\n let p = []\n let t = n\n while (1) {\n let u = 0\n for (let i = 0; i < p.length; i++) {\n if (t == p[i]) {\n u = 1\n break;\n }\n }\n if (u == 1) { break }\n if (t % 2 == 1) { p.push(t); t = 3 * t + 1 }\n else { t = t / 2 }\n }\n for (let j = 0; j < p.length; j++) {\n let ind = j\n for (let k = j + 1; k < p.length; k++) {\n if (p[k] < p[ind]) {\n ind = k\n }\n }\n if (ind > j) {\n let tmp = p[j]\n p[j] = p[ind]\n p[ind] = tmp\n }\n }\n return p\n}\n```\n"}
125
+ {"task_id": "JavaScript/124", "prompt": "为以下代码写单测:\n```\nfunction validDate(date) {\n let t = date.split(/-/)\n if (t.length != 3) { return false }\n if (t[0] < 1 || t[0] > 12 || t[1] < 1) { return false }\n if (t[0] == 2 && t[1] > 29) { return false }\n if ((t[0] == 1 || t[0] == 3 || t[0] == 5 || t[0] == 7 || t[0] == 8 || t[0] == 10 || t[0] == 12) && t[1] > 31) { return false }\n if ((t[0] == 4 || t[0] == 6 || t[0] == 9 || t[0] == 11) && t[1] > 30) { return false }\n return true\n}\n```\n"}
126
+ {"task_id": "JavaScript/125", "prompt": "为以下代码写单测:\n```\nfunction splitWords(txt) {\n let t = txt.split(/\\s/)\n if (t.length > 1) {\n return t\n } else {\n t = txt.split(/,/)\n if (t.length > 1) {\n return t\n } else {\n let p = 0\n for (let i = 0; i < txt.length; i++) {\n let m = txt[i].charCodeAt()\n if (m >= 97 && m <= 122 && m % 2 == 0) {\n p++\n }\n }\n return p\n }\n }\n}\n```\n"}
127
+ {"task_id": "JavaScript/126", "prompt": "为以下代码写单测:\n```\nfunction isSorted(lst) {\n if (lst.length == 0) { return true }\n let dup = 1\n let pre = lst[0]\n for (let i = 1; i < lst.length; i++) {\n if (lst[i] < pre) { return false }\n if (lst[i] == pre) {\n dup += 1;\n if (dup == 3) { return false }\n } else {\n pre = lst[i]\n dup = 1\n }\n }\n return true\n}\n```\n"}
128
+ {"task_id": "JavaScript/127", "prompt": "为以下代码写单测:\n```\nfunction intersection(interval1, interval2) {\n let lo = interval1[0]\n if (interval2[0] > lo) { lo = interval2[0] }\n let hi = interval1[1]\n if (interval2[1] < hi) { hi = interval2[1] }\n let len = 0\n if (hi > lo) { len = hi - lo }\n if (len == 1 || len == 0) { return 'NO' }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { return 'NO' }\n }\n return 'YES'\n}\n```\n"}
129
+ {"task_id": "JavaScript/128", "prompt": "为以下代码写单测:\n```\nfunction prodSigns(arr) {\n if (arr.length == 0) { return null }\n let n = 1\n let s = 0\n for (let i = 0; i < arr.length; i++) {\n s += arr[i]\n if (arr[i] == 0) { return 0 }\n if (arr[i] < 0) { n = -n; s -= 2 * arr[i] }\n }\n return s * n\n}\n```\n"}
130
+ {"task_id": "JavaScript/129", "prompt": "为以下代码写单测:\n```\nfunction minPath(grid, k) {\n let m = 0\n let n = 0\n for (let i = 0; i < grid.length; i++) {\n for (let j = 0; j < grid.length; j++) {\n if (grid[i][j] == 1) {\n m = i;\n n = j;\n break;\n }\n }\n }\n let min = grid.length * grid.length\n if (m > 0 && grid[m - 1][n] < min) { min = grid[m - 1][n] }\n if (n > 0 && grid[m][n - 1] < min) { min = grid[m][n - 1] }\n if (m < grid.length - 1 && grid[m + 1][n] < min) { min = grid[m + 1][n] }\n if (n < grid.length - 1 && grid[m][n + 1] < min) { min = grid[m][n + 1] }\n let p = []\n for (let i = 0; i < k; i++) {\n if (i % 2 == 0) { p.push(1) }\n else { p.push(min) }\n }\n return p\n}\n```\n"}
131
+ {"task_id": "JavaScript/130", "prompt": "为以下代码写单测:\n```\nfunction tri(n) {\n if (n == 0) { return [1] }\n if (n == 1) { return [1, 3] }\n let p = [1, 3]\n for (let i = 2; i <= n; i++) {\n if (i % 2 == 0) {\n p.push(1 + i / 2)\n }\n else {\n p.push(p[i - 2] + p[i - 1] + 1 + (i + 1) / 2)\n }\n }\n return p\n}\n```\n"}
132
+ {"task_id": "JavaScript/131", "prompt": "为以下代码写单测:\n```\nfunction digits(n) {\n let p = 1\n let k = 1\n while (n > 0) {\n let y = n % 10\n if (y % 2 == 1) {\n p *= y; k = 0;\n }\n n = (n - n % 10) / 10\n }\n if (k == 0) { return p }\n return 0\n}\n```\n"}
133
+ {"task_id": "JavaScript/132", "prompt": "为以下代码写单测:\n```\nfunction isNested(string) {\n let opening_bracket_index = []\n let closing_bracket_index1 = []\n for (let i = 0; i < string.length; i++) {\n if (string[i] == '[') {\n opening_bracket_index.push(i)\n }\n else {\n closing_bracket_index1.push(i)\n }\n }\n let closing_bracket_index = []\n for (let i = 0; i < closing_bracket_index1.length; i++) {\n closing_bracket_index.push(closing_bracket_index1[closing_bracket_index1.length - i - 1])\n }\n let cnt = 0\n let i = 0\n let l = closing_bracket_index.length\n for (let k = 0; k < opening_bracket_index.length; k++) {\n if (i < l && opening_bracket_index[k] < closing_bracket_index[i]) {\n cnt += 1;\n i += 1;\n }\n }\n return cnt >= 2\n}\n```\n"}
134
+ {"task_id": "JavaScript/133", "prompt": "为以下代码写单测:\n```\nfunction sumSquares(lst) {\n let p = 0\n for (let i = 0; i < lst.length; i++) {\n let y = lst[i]\n if (y % 1 != 0) {\n if (y > 0) { y = y - y % 1 + 1 }\n else { y = -y; y = y - y % 1 }\n }\n p += y * y\n }\n return p\n}\n```\n"}
135
+ {"task_id": "JavaScript/134", "prompt": "为以下代码写单测:\n```\nfunction checkIfLastCharIsALetter(txt) {\n let len = txt.length\n if (len == 0) { return false }\n let y = txt[len - 1].charCodeAt()\n if (len == 1) {\n if ((y >= 65 && y <= 90) || (y >= 97 && y <= 122)) { return true }\n return false\n }\n if (txt[len - 2] == ' ' && ((y >= 65 && y <= 90) || (y >= 97 && y <= 122))) { return true }\n return false\n}\n```\n"}
136
+ {"task_id": "JavaScript/135", "prompt": "为以下代码写单测:\n```\nfunction canArrange(arr) {\n if (arr.length == 0) { return -1 }\n for (let i = arr.length - 1; i > 0; i--) {\n if (arr[i] < arr[i - 1]) { return i }\n }\n return -1\n}\n```\n"}
137
+ {"task_id": "JavaScript/136", "prompt": "为以下代码写单测:\n```\nfunction largestSmallestIntegers(lst) {\n let a = Infinity\n let b = -Infinity\n for (let i = 0; i < lst.length; i++) {\n if (lst[i] > 0 && lst[i] < a) { a = lst[i] }\n if (lst[i] < 0 && lst[i] > b) { b = lst[i] }\n }\n if (a == Infinity) { a = null }\n if (b == -Infinity) { b = null }\n return (b, a)\n}\n```\n"}
138
+ {"task_id": "JavaScript/137", "prompt": "为以下代码写单测:\n```\nfunction compareOne(a, b) {\n let aa = Number(a)\n if (typeof a == 'string') { aa = Number(a.replace(',', '.')) }\n let bb = Number(b)\n if (typeof b == 'string') { bb = Number(b.replace(',', '.')) }\n if (aa > bb) { return a }\n if (aa < bb) { return b }\n return null\n}\n```\n"}
139
+ {"task_id": "JavaScript/138", "prompt": "为以下代码写单测:\n```\nfunction isEqualToSumEven(n) {\n return (n >= 8 && n % 2 == 0)\n}\n```\n"}
140
+ {"task_id": "JavaScript/139", "prompt": "为以下代码写单测:\n```\nfunction specialFactorial(n) {\n let p = 1;\n let t = 1;\n while (n > 1) {\n let y = p;\n while (y > 0) {\n y--;\n t *= n;\n }\n p++;\n n--;\n }\n return t\n}\n```\n"}
141
+ {"task_id": "JavaScript/140", "prompt": "为以下代码写单测:\n```\nfunction fixSpaces(text) {\n let t = ''\n let c = 0\n for (let i = 0; i < text.length; i++) {\n if (text[i] == ' ') { c++ }\n else if (c > 0) {\n if (c == 1) { t += '_' }\n if (c == 2) { t += '__' }\n if (c > 2) { t += '-' }\n t += text[i]\n c = 0;\n } else {\n t += text[i]\n }\n }\n if (c == 1) { t += '_' }\n if (c == 2) { t += '__' }\n if (c > 2) { t += '-' }\n return t\n}\n```\n"}
142
+ {"task_id": "JavaScript/141", "prompt": "为以下代码写单测:\n```\nfunction fileNameCheck(file_name) {\n let t = file_name.split(/\\./)\n if (t.length != 2) { return 'No' }\n if (t[1] != 'txt' && t[1] != 'dll' && t[1] != 'exe') { return 'No' }\n if (t[0] == '') { return 'No' }\n let a = t[0][0].charCodeAt()\n if (!((a >= 65 && a <= 90) || (a >= 97 && a <= 122))) { return 'No' }\n let y = 0\n for (let i = 1; i < t[0].length; i++) {\n if (t[0][i].charCodeAt() >= 48 && t[0][i].charCodeAt() <= 57) { y++ }\n if (y > 3) { return 'No' }\n }\n return 'Yes'\n}\n```\n"}
143
+ {"task_id": "JavaScript/142", "prompt": "为以下代码写单测:\n```\nfunction sumSquares(lst) {\n let y = 0\n for (let i = 0; i < lst.length; i++) {\n if (i % 3 == 0) { y += lst[i] * lst[i] }\n else if (i % 4 == 0) { y += lst[i] * lst[i] * lst[i] }\n else { y += lst[i] }\n }\n return y\n}\n```\n"}
144
+ {"task_id": "JavaScript/143", "prompt": "为以下代码写单测:\n```\nfunction wordsInSentence(sentence) {\n let t = sentence.split(/\\s/)\n let p = ''\n for (let j = 0; j < t.length; j++) {\n let len = t[j].length;\n let u = 1\n if (len == 1 || len == 0) { continue }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { u = 0 }\n }\n if (u == 0) { continue }\n if (p == '') { p += t[j] }\n else { p = p + ' ' + t[j] }\n }\n return p\n}\n```\n"}
145
+ {"task_id": "JavaScript/144", "prompt": "为以下代码写单测:\n```\nfunction simplify(x, n) {\n let a = x.split(/\\//)\n let b = n.split(/\\//)\n let m = Number(a[0]) * Number(b[0])\n let r = Number(a[1]) * Number(b[1])\n return m % r == 0\n}\n```\n"}
146
+ {"task_id": "JavaScript/145", "prompt": "为以下代码写单测:\n```\nfunction orderByPoints(nums) {\n let p = nums\n for (let j = p.length - 2; j >= 0; j--) {\n for (let k = 0; k <= j; k++) {\n let m = 0\n let n = 0\n let h = p[k]\n let d = p[k + 1]\n let y = 1\n let u = 1\n if (h < 0) { y = -1; h = -h; }\n if (d < 0) { u = -1; d = -d; }\n while (h >= 10) {\n m += h % 10;\n h = (h - h % 10) / 10;\n }\n m += y * h\n while (d >= 10) {\n n += d % 10;\n d = (d - d % 10) / 10;\n }\n n += u * d\n if (m > n) {\n let tmp = p[k]\n p[k] = p[k + 1]\n p[k + 1] = tmp\n }\n }\n }\n return p\n}\n```\n"}
147
+ {"task_id": "JavaScript/146", "prompt": "为以下代码写单测:\n```\nfunction specialFilter(nums) {\n let p = 0\n for (let i = 0; i < nums.length; i++) {\n if (nums[i] < 10) { continue }\n let y = nums[i].toString()\n if (Number(y[0]) % 2 == 1 && Number(y[y.length - 1]) % 2 == 1) {\n p++\n }\n }\n return p\n}\n```\n"}
148
+ {"task_id": "JavaScript/147", "prompt": "为以下代码写单测:\n```\nfunction getMaxTriples(n) {\n let y = []\n for (let i = 1; i <= n; i++) {\n y.push(i * i - i + 1)\n }\n let u = 0\n for (let i = 0; i < n - 2; i++) {\n for (let j = i + 1; j < n - 1; j++) {\n for (let k = j + 1; k < n; k++) {\n if ((y[i] + y[j] + y[k]) % 3 == 0) { u++ }\n }\n }\n }\n return u\n}\n```\n"}
149
+ {"task_id": "JavaScript/148", "prompt": "为以下代码写单测:\n```\nfunction bf(planet1, planet2) {\n let y = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus', 'Neptune']\n let u = []\n let lo = -1\n let hi = -1\n for (let i = 0; i < 8; i++) {\n if (y[i] == planet1) { lo = i }\n }\n for (let i = 0; i < 8; i++) {\n if (y[i] == planet2) { hi = i }\n }\n if (lo == -1 || hi == -1 || lo == hi) { return [] }\n if (lo > hi) {\n let tmp = lo;\n lo = hi;\n hi = tmp;\n }\n for (let i = lo + 1; i < hi; i++) {\n u.push(y[i])\n }\n return u\n}\n```\n"}
150
+ {"task_id": "JavaScript/149", "prompt": "为以下代码写单测:\n```\nfunction sortedListSum(lst) {\n let p = []\n for (let i = 0; i < lst.length; i++) {\n if (lst[i].length % 2 == 0) {\n p.push(lst[i])\n }\n }\n for (let j = p.length - 2; j >= 0; j--) {\n for (let k = 0; k <= j; k++) {\n let f = 0\n if (p[k].length > p[k + 1].length) { f = 1 }\n if (p[k].length == p[k + 1].length) {\n let r = p[k].length\n for (let l = 0; l < r; l++) {\n if (p[k][l].charCodeAt() > p[k + 1][l].charCodeAt()) {\n f = 1;\n break;\n }\n if (p[k][l].charCodeAt() < p[k + 1][l].charCodeAt()) {\n break;\n }\n }\n }\n if (f == 1) {\n let tmp = p[k]\n p[k] = p[k + 1]\n p[k + 1] = tmp\n }\n }\n }\n return p\n}\n```\n"}
151
+ {"task_id": "JavaScript/150", "prompt": "为以下代码写单测:\n```\nfunction xOrY(n, x, y) {\n let len = n\n if (len == 1 || len == 0) { return y }\n for (let i = 2; i * i <= len; i++) {\n if (len % i == 0) { return y }\n }\n return x\n}\n```\n"}
152
+ {"task_id": "JavaScript/151", "prompt": "为以下代码写单测:\n```\nfunction doubleTheDifference(lst) {\n let p = 0\n for (let i = 0; i < lst.length; i++) {\n if (lst[i] % 2 == 1 && lst[i] > 0) {\n p += lst[i] * lst[i]\n }\n }\n return p\n}\n```\n"}
153
+ {"task_id": "JavaScript/152", "prompt": "为以下代码写单测:\n```\nfunction compare(game, guess) {\n for (let i = 0; i < guess.length; i++) {\n game[i] -= guess[i]\n if (game[i]<0)\n game[i]=-game[i]; }\n return game\n}\n```\n"}
154
+ {"task_id": "JavaScript/153", "prompt": "为以下代码写单测:\n```\nfunction strongestExtension(class_name, extensions) {\n let u = 0\n let s = -Infinity\n for (let i = extensions.length - 1; i >= 0; i--) {\n let y = 0\n for (let j = 0; j < extensions[i].length; j++) {\n let k = extensions[i][j].charCodeAt()\n if (k >= 65 && k <= 90) { y += 1 }\n if (k >= 97 && k <= 122) { y -= 1 }\n }\n if (y >= s) {\n s = y;\n u = i;\n }\n }\n return class_name + '.' + extensions[u]\n}\n```\n"}
155
+ {"task_id": "JavaScript/154", "prompt": "为以下代码写单测:\n```\nfunction cycpatternCheck(a, b) {\n let l = b.length\n let pat = b + b\n for (let i = 0; i < a.length - l + 1; i++) {\n for (let j = 0; j < l + 1; j++) {\n let y = 1\n for (let k = 0; k < l; k++) {\n if (a[i + k] != pat[j + k]) { y = 0 }\n }\n if (y == 1) {\n return true\n }\n }\n }\n return false\n}\n```\n"}
156
+ {"task_id": "JavaScript/155", "prompt": "为以下代码写单测:\n```\nfunction evenOddCount(num) {\n let o = 0\n let e = 0\n if (num < 0) { num = -num }\n while (num > 0) {\n if (num % 2 == 0) { e++ }\n else { o++ }\n num = (num - num % 10) / 10\n }\n return (e, o)\n}\n```\n"}
157
+ {"task_id": "JavaScript/156", "prompt": "为以下代码写单测:\n```\nfunction intToMiniRoman(number) {\n let num = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]\n let sym = ['i', 'iv', 'v', 'ix', 'x', 'xl', 'l', 'xc', 'c', 'cd', 'd', 'cm', 'm']\n let i = 12\n let res = ''\n while (number) {\n let div = (number - number % num[i]) / num[i]\n number = number % num[i]\n while (div) {\n res += sym[i]\n div -= 1\n }\n i -= 1\n }\n return res\n}\n```\n"}
158
+ {"task_id": "JavaScript/157", "prompt": "为以下代码写单测:\n```\nfunction rightAngleTriangle(a, b, c) {\n return (a * a + b * b == c * c || a * a == b * b + c * c || b * b == a * a + c * c)\n}\n```\n"}
159
+ {"task_id": "JavaScript/158", "prompt": "为以下代码写单测:\n```\nfunction findMax(words) {\n let s = -1\n let u = -1\n if (words.length == 0) { return '' }\n for (let i = 0; i < words.length; i++) {\n let p = 0\n for (let j = 0; j < words[i].length; j++) {\n let y = 1\n for (let k = 0; k < j; k++) {\n if (words[i][j] == words[i][k]) { y = 0 }\n }\n if (y == 1) { p++ }\n }\n if (p > s || (p == s && words[i] < words[u])) {\n u = i;\n s = p;\n }\n }\n return words[u]\n}\n```\n"}
160
+ {"task_id": "JavaScript/159", "prompt": "为以下代码写单测:\n```\nfunction eat(number, need, remaining) {\n if (need <= remaining) {\n return [need + number, remaining - need]\n }\n return [remaining + number, 0]\n}\n```\n"}
161
+ {"task_id": "JavaScript/160", "prompt": "为��下代码写单测:\n```\nfunction doAlgebra(operator, operand) {\n while (operator.length > 0) {\n let y = 0\n for (let i = operator.length - 1; i >= 0; i--) {\n if (operator[i] == '**') {\n let u = operand[i]\n while (operand[i + 1] > 1) {\n operand[i + 1]--;\n operand[i] *= u;\n }\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n }\n if (y == 1) { continue }\n for (let i = 0; i < operator.length; i++) {\n if (operator[i] == '*') {\n operand[i] *= operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n else if (operator[i] == '//') {\n operand[i] = (operand[i] - operand[i] % operand[i + 1]) / operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n }\n if (y == 1) { continue }\n for (let i = 0; i < operator.length; i++) {\n if (operator[i] == '+') {\n operand[i] += operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n else if (operator[i] == '-') {\n operand[i] -= operand[i + 1]\n operand.splice(i + 1, 1)\n operator.splice(i, 1)\n y = 1;\n break;\n }\n }\n if (y == 1) { continue }\n }\n return operand[0]\n}\n```\n"}
162
+ {"task_id": "JavaScript/161", "prompt": "为以下代码写单测:\n```\nfunction solve(s) {\n let t = 0\n let p = ''\n for (let i = 0; i < s.length; i++) {\n let y = s[i].charCodeAt()\n if (y >= 65 && y <= 90) {\n y += 32;\n t = 1;\n } else if (y >= 97 && y <= 122) {\n y -= 32;\n t = 1;\n }\n p += String.fromCharCode(y)\n }\n if (t == 1) { return p }\n let u = ''\n for (let i = 0; i < p.length; i++) {\n u += p[p.length - i - 1]\n }\n return u\n}\n```\n"}
163
+ {"task_id": "JavaScript/162", "prompt": "为以下代码写单测:\n```\nfunction stringToMd5(text) {\n if (text == '') { return null }\n var md5 = require('js-md5')\n return md5(text)\n}\n```\n"}
164
+ {"task_id": "JavaScript/163", "prompt": "为以下代码写单测:\n```\nfunction generateIntegers(a, b) {\n if (a > b) {\n let tmp = a;\n a = b;\n b = tmp;\n }\n let y = []\n for (let i = a; i <= b; i++) {\n if (i == 2 || i == 4 || i == 6 || i == 8) { y.push(i) }\n }\n return y\n}\n```\n"}
eval_data/python_eval.jsonl ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"task_id": "Python/0", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef remove_duplicates(numbers: List[int]) -> List[int]:\n import collections\n c = collections.Counter(numbers)\n return [n for n in numbers if c[n] <= 1]\n```\n"}
2
+ {"task_id": "Python/1", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fruit_distribution(s,n):\n lis = list()\n for i in s.split(' '):\n if i.isdigit():\n lis.append(int(i))\n return n - sum(lis)\n```\n"}
3
+ {"task_id": "Python/2", "prompt": "为以下Python代码生成单元测试\n```Python\ndef median(l: list):\n l = sorted(l)\n if len(l) % 2 == 1:\n return l[len(l) // 2]\n else:\n return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2.0\n```\n"}
4
+ {"task_id": "Python/3", "prompt": "为以下Python代码生成单元测试\n```Python\ndef decimal_to_binary(decimal):\n return \"db\" + bin(decimal)[2:] + \"db\"\n```\n"}
5
+ {"task_id": "Python/4", "prompt": "为以下Python代码生成单元测试\n```Python\ndef flip_case(string: str) -> str:\n return string.swapcase()\n```\n"}
6
+ {"task_id": "Python/5", "prompt": "为以下Python代码生成单元测试\n```Python\ndef select_words(s, n):\n result = []\n for word in s.split():\n n_consonants = 0\n for i in range(0, len(word)):\n if word[i].lower() not in [\"a\",\"e\",\"i\",\"o\",\"u\"]:\n n_consonants += 1 \n if n_consonants == n:\n result.append(word)\n return result\n```\n\n"}
7
+ {"task_id": "Python/6", "prompt": "为以下Python代码生成单元测试\n```Python\ndef strange_sort_list(lst):\n res, switch = [], True\n while lst:\n res.append(min(lst) if switch else max(lst))\n lst.remove(res[-1])\n switch = not switch\n return res\n```\n"}
8
+ {"task_id": "Python/7", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef filter_by_substring(strings: List[str], substring: str) -> List[str]:\n return [x for x in strings if substring in x]\n```\n"}
9
+ {"task_id": "Python/8", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Tuple\n\n\ndef sum_product(numbers: List[int]) -> Tuple[int, int]:\n sum_value = 0\n prod_value = 1\n\n for n in numbers:\n sum_value += n\n prod_value *= n\n return sum_value, prod_value\n```\n"}
10
+ {"task_id": "Python/9", "prompt": "为以下Python代码生成单元测试\n```Python\ndef iscube(a):\n a = abs(a)\n return int(round(a ** (1. / 3))) ** 3 == a\n```\n"}
11
+ {"task_id": "Python/10", "prompt": "为以下Python代码生成单元测试\n```Python\ndef string_to_md5(text):\n import hashlib\n return hashlib.md5(text.encode('ascii')).hexdigest() if text else None\n```\n"}
12
+ {"task_id": "Python/11", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sort_third(l: list):\n l = list(l)\n l[::3] = sorted(l[::3])\n return l\n```\n"}
13
+ {"task_id": "Python/12", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_palindrome(text: str):\n for i in range(len(text)):\n if text[i] != text[len(text) - 1 - i]:\n return False\n return True\n```\n"}
14
+ {"task_id": "Python/13", "prompt": "为以下Python代码生成单元测试\n```Python\ndef do_algebra(operator, operand):\n expression = str(operand[0])\n for oprt, oprn in zip(operator, operand[1:]):\n expression+= oprt + str(oprn)\n return eval(expression)\n```\n"}
15
+ {"task_id": "Python/14", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_bored(S):\n import re\n sentences = re.split(r'[.?!]\\s*', S)\n return sum(sentence[0:2] == 'I ' for sentence in sentences)\n```\n"}
16
+ {"task_id": "Python/15", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Tuple\n\n\ndef find_closest_elements(numbers: List[float]) -> Tuple[float, float]:\n closest_pair = None\n distance = None\n\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n if distance is None:\n distance = abs(elem - elem2)\n closest_pair = tuple(sorted([elem, elem2]))\n else:\n new_distance = abs(elem - elem2)\n if new_distance < distance:\n distance = new_distance\n closest_pair = tuple(sorted([elem, elem2]))\n\n return closest_pair\n```\n"}
17
+ {"task_id": "Python/16", "prompt": "为以下Python代码生成单元测试\n```Python\ndef modp(n: int, p: int):\n ret = 1\n for i in range(n):\n ret = (2 * ret) % p\n return ret\n```\n"}
18
+ {"task_id": "Python/17", "prompt": "为以下Python代码生成单元测试\n```Python\ndef intersection(interval1, interval2):\n def is_prime(num):\n if num == 1 or num == 0:\n return False\n if num == 2:\n return True\n for i in range(2, num):\n if num%i == 0:\n return False\n return True\n\n l = max(interval1[0], interval2[0])\n r = min(interval1[1], interval2[1])\n length = r - l\n if length > 0 and is_prime(length):\n return \"YES\"\n return \"NO\"\n```\n"}
19
+ {"task_id": "Python/18", "prompt": "为以下Python代码生成单元测试\n```Python\ndef f(n):\n ret = []\n for i in range(1,n+1):\n if i%2 == 0:\n x = 1\n for j in range(1,i+1): x *= j\n ret += [x]\n else:\n x = 0\n for j in range(1,i+1): x += j\n ret += [x]\n return ret\n```\n"}
20
+ {"task_id": "Python/19", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_up_to(n):\n primes = []\n for i in range(2, n):\n is_prime = True\n for j in range(2, i):\n if i % j == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes\n```\n"}
21
+ {"task_id": "Python/20", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n result = []\n current_string = []\n current_depth = 0\n\n for c in paren_string:\n if c == '(':\n current_depth += 1\n current_string.append(c)\n elif c == ')':\n current_depth -= 1\n current_string.append(c)\n\n if current_depth == 0:\n result.append(''.join(current_string))\n current_string.clear()\n\n return result\n```\n"}
22
+ {"task_id": "Python/21", "prompt": "为以下Python代码生成单元测试\n```Python\ndef starts_one_ends(n):\n if n == 1: return 1\n return 18 * (10 ** (n - 2))\n```\n"}
23
+ {"task_id": "Python/22", "prompt": "为以下Python代码生成单元测试\n```Python\ndef minSubArraySum(nums):\n max_sum = 0\n s = 0\n for num in nums:\n s += -num\n if (s < 0):\n s = 0\n max_sum = max(s, max_sum)\n if max_sum == 0:\n max_sum = max(-i for i in nums)\n min_sum = -max_sum\n return min_sum\n```\n"}
24
+ {"task_id": "Python/23", "prompt": "为以下Python代码生成单元测试\n```Python\ndef cycpattern_check(a , b):\n l = len(b)\n pat = b + b\n for i in range(len(a) - l + 1):\n for j in range(l + 1):\n if a[i:i+l] == pat[j:j+l]:\n return True\n return False\n```\n"}
25
+ {"task_id": "Python/24", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_multiply_prime(a):\n def is_prime(n):\n for j in range(2,n):\n if n%j == 0:\n return False\n return True\n\n for i in range(2,101):\n if not is_prime(i): continue\n for j in range(2,101):\n if not is_prime(j): continue\n for k in range(2,101):\n if not is_prime(k): continue\n if i*j*k == a: return True\n return False\n```\n"}
26
+ {"task_id": "Python/25", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef intersperse(numbers: List[int], delimeter: int) -> List[int]:\n if not numbers:\n return []\n\n result = []\n\n for n in numbers[:-1]:\n result.append(n)\n result.append(delimeter)\n\n result.append(numbers[-1])\n\n return result\n```\n"}
27
+ {"task_id": "Python/26", "prompt": "为以下Python代码生成单元测试\n```Python\ndef valid_date(date):\n try:\n date = date.strip()\n month, day, year = date.split('-')\n month, day, year = int(month), int(day), int(year)\n if month < 1 or month > 12:\n return False\n if month in [1,3,5,7,8,10,12] and day < 1 or day > 31:\n return False\n if month in [4,6,9,11] and day < 1 or day > 30:\n return False\n if month == 2 and day < 1 or day > 29:\n return False\n except:\n return False\n\n return True\n```\n"}
28
+ {"task_id": "Python/27", "prompt": "为以下Python代码生成单元测试\n```Python\ndef greatest_common_divisor(a: int, b: int) -> int:\n while b:\n a, b = b, a % b\n return a\n```\n"}
29
+ {"task_id": "Python/28", "prompt": "为以下Python代码生成单元测试\n```Python\ndef encode_cyclic(s: str):\n \"\"\"\n returns encoded string by cycling groups of three characters.\n \"\"\"\n # split string to groups. Each of length 3.\n groups = [s[(3 * i):min((3 * i + 3), len(s))] for i in range((len(s) + 2) // 3)]\n # cycle elements in each group. Unless group has fewer elements than 3.\n groups = [(group[1:] + group[0]) if len(group) == 3 else group for group in groups]\n return \"\".join(groups)\n\n\ndef decode_cyclic(s: str):\n return encode_cyclic(encode_cyclic(s))\n```\n"}
30
+ {"task_id": "Python/29", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_odd_collatz(n):\n if n%2==0:\n odd_collatz = [] \n else:\n odd_collatz = [n]\n while n > 1:\n if n % 2 == 0:\n n = n/2\n else:\n n = n*3 + 1\n \n if n%2 == 1:\n odd_collatz.append(int(n))\n\n return sorted(odd_collatz)\n```\n"}
31
+ {"task_id": "Python/30", "prompt": "为以下Python代码生成单元测试\n```Python\ndef right_angle_triangle(a, b, c):\n return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b\n```\n"}
32
+ {"task_id": "Python/31", "prompt": "为以下Python代码生成单元测试\n```Python\ndef pluck(arr):\n if(len(arr) == 0): return []\n evens = list(filter(lambda x: x%2 == 0, arr))\n if(evens == []): return []\n return [min(evens), arr.index(min(evens))]\n```\n"}
33
+ {"task_id": "Python/32", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sum_to_n(n: int):\n return sum(range(n + 1))\n```\n"}
34
+ {"task_id": "Python/33", "prompt": "为以下Python代码生成单元测试\n```Python\ndef monotonic(l: list):\n if l == sorted(l) or l == sorted(l, reverse=True):\n return True\n return False\n```\n"}
35
+ {"task_id": "Python/34", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_closest_vowel(word):\n if len(word) < 3:\n return \"\"\n\n vowels = {\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", 'O', 'U', 'I'}\n for i in range(len(word)-2, 0, -1):\n if word[i] in vowels:\n if (word[i+1] not in vowels) and (word[i-1] not in vowels):\n return word[i]\n return \"\"\n```\n"}
36
+ {"task_id": "Python/35", "prompt": "为以下Python代码生成单元测试\n```Python\ndef prod_signs(arr):\n if not arr: return None\n prod = 0 if 0 in arr else (-1) ** len(list(filter(lambda x: x < 0, arr)))\n return prod * sum([abs(i) for i in arr])\n```\n"}
37
+ {"task_id": "Python/36", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_simple_power(x, n):\n if (n == 1): \n return (x == 1) \n power = 1\n while (power < x): \n power = power * n \n return (power == x) \n```\n"}
38
+ {"task_id": "Python/37", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef mean_absolute_deviation(numbers: List[float]) -> float:\n mean = sum(numbers) / len(numbers)\n return sum(abs(x - mean) for x in numbers) / len(numbers)\n```\n"}
39
+ {"task_id": "Python/38", "prompt": "为以下Python代码生成单元测试\n```Python\ndef unique_digits(x):\n odd_digit_elements = []\n for i in x:\n if all (int(c) % 2 == 1 for c in str(i)):\n odd_digit_elements.append(i)\n return sorted(odd_digit_elements)\n```\n"}
40
+ {"task_id": "Python/39", "prompt": "为以下Python代码生成单元测试\n```Python\ndef any_int(x, y, z):\n \n if isinstance(x,int) and isinstance(y,int) and isinstance(z,int):\n if (x+y==z) or (x+z==y) or (y+z==x):\n return True\n return False\n return False\n```\n"}
41
+ {"task_id": "Python/40", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_prime(n):\n if n < 2:\n return False\n for k in range(2, n - 1):\n if n % k == 0:\n return False\n return True\n```\n"}
42
+ {"task_id": "Python/41", "prompt": "为以下Python代码生成单元测试\n```Python\ndef next_smallest(lst):\n lst = sorted(set(lst))\n return None if len(lst) < 2 else lst[1]\n```\n"}
43
+ {"task_id": "Python/42", "prompt": "为以下Python代码生成单元测试\n```Python\ndef odd_count(lst):\n res = []\n for arr in lst:\n n = sum(int(d)%2==1 for d in arr)\n res.append(\"the number of odd elements \" + str(n) + \"n the str\"+ str(n) +\"ng \"+ str(n) +\" of the \"+ str(n) +\"nput.\")\n return res\n```\n"}
44
+ {"task_id": "Python/43", "prompt": "为以下Python代码生成单元测试\n```Python\ndef how_many_times(string: str, substring: str) -> int:\n times = 0\n\n for i in range(len(string) - len(substring) + 1):\n if string[i:i+len(substring)] == substring:\n times += 1\n\n return times\n```\n"}
45
+ {"task_id": "Python/44", "prompt": "为以下Python代码生成单元测试\n```Python\ndef rounded_avg(n, m):\n if m < n:\n return -1\n summation = 0\n for i in range(n, m+1):\n summation += i\n return bin(round(summation/(m - n + 1)))\n```\n"}
46
+ {"task_id": "Python/45", "prompt": "为以下Python代码生成单元测试\n```Python\ndef search(lst):\n frq = [0] * (max(lst) + 1)\n for i in lst:\n frq[i] += 1;\n\n ans = -1\n for i in range(1, len(frq)):\n if frq[i] >= i:\n ans = i\n \n return ans\n```\n"}
47
+ {"task_id": "Python/46", "prompt": "为以下Python代码生成单元测试\n```Python\ndef triangle_area(a, b, c):\n if a + b <= c or a + c <= b or b + c <= a:\n return -1 \n s = (a + b + c)/2 \n area = (s * (s - a) * (s - b) * (s - c)) ** 0.5\n area = round(area, 2)\n return area\n```\n"}
48
+ {"task_id": "Python/47", "prompt": "为以下Python代码生成单元测试\n```Python\ndef exchange(lst1, lst2):\n odd = 0\n even = 0\n for i in lst1:\n if i%2 == 1:\n odd += 1\n for i in lst2:\n if i%2 == 0:\n even += 1\n if even >= odd:\n return \"YES\"\n return \"NO\"\n```\n"}
49
+ {"task_id": "Python/48", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef all_prefixes(string: str) -> List[str]:\n result = []\n\n for i in range(len(string)):\n result.append(string[:i+1])\n return result\n```\n"}
50
+ {"task_id": "Python/49", "prompt": "为以下Python代码生成单元测试\n```Python\ndef tri(n):\n if n == 0:\n return [1]\n my_tri = [1, 3]\n for i in range(2, n + 1):\n if i % 2 == 0:\n my_tri.append(i / 2 + 1)\n else:\n my_tri.append(my_tri[i - 1] + my_tri[i - 2] + (i + 3) / 2)\n return my_tri\n```\n"}
51
+ {"task_id": "Python/50", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_max_triples(n):\n A = [i*i - i + 1 for i in range(1,n+1)]\n ans = []\n for i in range(n):\n for j in range(i+1,n):\n for k in range(j+1,n):\n if (A[i]+A[j]+A[k])%3 == 0:\n ans += [(A[i],A[j],A[k])]\n return len(ans)\n```\n"}
52
+ {"task_id": "Python/51", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_positive(l: list):\n return [e for e in l if e > 0]\n```\n"}
53
+ {"task_id": "Python/52", "prompt": "为以下Python代码生成单元测试\n```Python\ndef special_factorial(n):\n fact_i = 1\n special_fact = 1\n for i in range(1, n+1):\n fact_i *= i\n special_fact *= fact_i\n return special_fact\n```\n"}
54
+ {"task_id": "Python/53", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fizz_buzz(n: int):\n ns = []\n for i in range(n):\n if i % 11 == 0 or i % 13 == 0:\n ns.append(i)\n s = ''.join(list(map(str, ns)))\n ans = 0\n for c in s:\n ans += (c == '7')\n return ans\n```\n"}
55
+ {"task_id": "Python/54", "prompt": "为以下Python代码生成单元测试\n```Python\ndef check_dict_case(dict):\n if len(dict.keys()) == 0:\n return False\n else:\n state = \"start\"\n for key in dict.keys():\n\n if isinstance(key, str) == False:\n state = \"mixed\"\n break\n if state == \"start\":\n if key.isupper():\n state = \"upper\"\n elif key.islower():\n state = \"lower\"\n else:\n break\n elif (state == \"upper\" and not key.isupper()) or (state == \"lower\" and not key.islower()):\n state = \"mixed\"\n break\n else:\n break\n return state == \"upper\" or state == \"lower\" \n```\n"}
56
+ {"task_id": "Python/55", "prompt": "为以下Python代码生成单元测试\n```Python\ndef add_elements(arr, k):\n return sum(elem for elem in arr[:k] if len(str(elem)) <= 2)\n```\n"}
57
+ {"task_id": "Python/56", "prompt": "为以下Python代码生成单元测试\n```Python\ndef max_fill(grid, capacity):\n import math\n return sum([math.ceil(sum(arr)/capacity) for arr in grid])\n```\n"}
58
+ {"task_id": "Python/57", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_distinct_characters(string: str) -> int:\n return len(set(string.lower()))\n```\n"}
59
+ {"task_id": "Python/58", "prompt": "为以下Python代码生成单元测试\n```Python\ndef split_words(txt):\n if \" \" in txt:\n return txt.split()\n elif \",\" in txt:\n return txt.replace(',',' ').split()\n else:\n return len([i for i in txt if i.islower() and ord(i)%2 == 0])\n```\n"}
60
+ {"task_id": "Python/59", "prompt": "为以下Python代码生成单元测试\n```Python\ndef largest_prime_factor(n: int):\n def is_prime(k):\n if k < 2:\n return False\n for i in range(2, k - 1):\n if k % i == 0:\n return False\n return True\n largest = 1\n for j in range(2, n + 1):\n if n % j == 0 and is_prime(j):\n largest = max(largest, j)\n return largest\n```\n"}
61
+ {"task_id": "Python/60", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sorted_list_sum(lst):\n lst.sort()\n new_lst = []\n for i in lst:\n if len(i)%2 == 0:\n new_lst.append(i)\n return sorted(new_lst, key=len)\n```\n"}
62
+ {"task_id": "Python/61", "prompt": "为以下Python代码生成单元测试\n```Python\ndef make_a_pile(n):\n return [n + 2*i for i in range(n)]\n```\n"}
63
+ {"task_id": "Python/62", "prompt": "为以下Python代码生成单元测试\n```Python\ndef change_base(x: int, base: int):\n ret = \"\"\n while x > 0:\n ret = str(x % base) + ret\n x //= base\n return ret\n```\n"}
64
+ {"task_id": "Python/63", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sum_squares(lst):\n result =[]\n for i in range(len(lst)):\n if i %3 == 0:\n result.append(lst[i]**2)\n elif i % 4 == 0 and i%3 != 0:\n result.append(lst[i]**3)\n else:\n result.append(lst[i])\n return sum(result)\n```\n"}
65
+ {"task_id": "Python/64", "prompt": "为以下Python代码生成单元测试\n```Python\ndef by_length(arr):\n dic = {\n 1: \"One\",\n 2: \"Two\",\n 3: \"Three\",\n 4: \"Four\",\n 5: \"Five\",\n 6: \"Six\",\n 7: \"Seven\",\n 8: \"Eight\",\n 9: \"Nine\",\n }\n sorted_arr = sorted(arr, reverse=True)\n new_arr = []\n for var in sorted_arr:\n try:\n new_arr.append(dic[var])\n except:\n pass\n return new_arr\n```\n"}
66
+ {"task_id": "Python/65", "prompt": "为以下Python代码生成单元测试\n```Python\ndef eat(number, need, remaining):\n if(need <= remaining):\n return [ number + need , remaining-need ]\n else:\n return [ number + remaining , 0]\n```\n"}
67
+ {"task_id": "Python/66", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef rescale_to_unit(numbers: List[float]) -> List[float]:\n min_number = min(numbers)\n max_number = max(numbers)\n return [(x - min_number) / (max_number - min_number) for x in numbers]\n```\n"}
68
+ {"task_id": "Python/67", "prompt": "为以下Python代码生成单元测试\n```Python\ndef Strongest_Extension(class_name, extensions):\n strong = extensions[0]\n my_val = len([x for x in extensions[0] if x.isalpha() and x.isupper()]) - len([x for x in extensions[0] if x.isalpha() and x.islower()])\n for s in extensions:\n val = len([x for x in s if x.isalpha() and x.isupper()]) - len([x for x in s if x.isalpha() and x.islower()])\n if val > my_val:\n strong = s\n my_val = val\n\n ans = class_name + \".\" + strong\n return ans\n```\n\n"}
69
+ {"task_id": "Python/68", "prompt": "为以下Python代码生成单元测试\n```Python\ndef incr_list(l: list):\n return [(e + 1) for e in l]\n```\n"}
70
+ {"task_id": "Python/69", "prompt": "为以下Python代码生成单元测试\n```Python\nimport math\n\n\ndef poly(xs: list, x: float):\n \"\"\"\n Evaluates polynomial with coefficients xs at point x.\n return xs[0] + xs[1] * x + xs[1] * x^2 + .... xs[n] * x^n\n \"\"\"\n return sum([coeff * math.pow(x, i) for i, coeff in enumerate(xs)])\n\n\ndef find_zero(xs: list):\n begin, end = -1., 1.\n while poly(xs, begin) * poly(xs, end) > 0:\n begin *= 2.0\n end *= 2.0\n while end - begin > 1e-10:\n center = (begin + end) / 2.0\n if poly(xs, center) * poly(xs, begin) > 0:\n begin = center\n else:\n end = center\n return begin\n```\n"}
71
+ {"task_id": "Python/70", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_sorted(lst):\n count_digit = dict([(i, 0) for i in lst])\n for i in lst:\n count_digit[i]+=1 \n if any(count_digit[i] > 2 for i in lst):\n return False\n if all(lst[i-1] <= lst[i] for i in range(1, len(lst))):\n return True\n else:\n return False\n```\n"}
72
+ {"task_id": "Python/71", "prompt": "为以下Python代码生成单元测试\n```Python\ndef will_it_fly(q,w):\n if sum(q) > w:\n return False\n\n i, j = 0, len(q)-1\n while i<j:\n if q[i] != q[j]:\n return False\n i+=1\n j-=1\n return True\n```\n"}
73
+ {"task_id": "Python/72", "prompt": "为以下Python代码生成单元测试\n```Python\ndef find_max(words):\n return sorted(words, key = lambda x: (-len(set(x)), x))[0]\n```\n"}
74
+ {"task_id": "Python/73", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_happy(s):\n if len(s) < 3:\n return False\n\n for i in range(len(s) - 2):\n \n if s[i] == s[i+1] or s[i+1] == s[i+2] or s[i] == s[i+2]:\n return False\n return True\n```\n"}
75
+ {"task_id": "Python/74", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef concatenate(strings: List[str]) -> str:\n return ''.join(strings)\n```\n"}
76
+ {"task_id": "Python/75", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sort_even(l: list):\n evens = l[::2]\n odds = l[1::2]\n evens.sort()\n ans = []\n for e, o in zip(evens, odds):\n ans.extend([e, o])\n if len(evens) > len(odds):\n ans.append(evens[-1])\n return ans\n```\n"}
77
+ {"task_id": "Python/76", "prompt": "为以下Python代码生成单元测试\n```Python\ndef minPath(grid, k):\n n = len(grid)\n val = n * n + 1\n for i in range(n):\n for j in range(n):\n if grid[i][j] == 1:\n temp = []\n if i != 0:\n temp.append(grid[i - 1][j])\n\n if j != 0:\n temp.append(grid[i][j - 1])\n\n if i != n - 1:\n temp.append(grid[i + 1][j])\n\n if j != n - 1:\n temp.append(grid[i][j + 1])\n\n val = min(temp)\n\n ans = []\n for i in range(k):\n if i % 2 == 0:\n ans.append(1)\n else:\n ans.append(val)\n return ans\n```\n"}
78
+ {"task_id": "Python/77", "prompt": "为以下Python代码生成单元测试\n```Python\ndef compare(game,guess):\n return [abs(x-y) for x,y in zip(game,guess)]\n```\n"}
79
+ {"task_id": "Python/78", "prompt": "为以下Python代码生成单元测试\n```Python\ndef bf(planet1, planet2):\n planet_names = (\"Mercury\", \"Venus\", \"Earth\", \"Mars\", \"Jupiter\", \"Saturn\", \"Uranus\", \"Neptune\")\n if planet1 not in planet_names or planet2 not in planet_names or planet1 == planet2:\n return ()\n planet1_index = planet_names.index(planet1)\n planet2_index = planet_names.index(planet2)\n if planet1_index < planet2_index:\n return (planet_names[planet1_index + 1: planet2_index])\n else:\n return (planet_names[planet2_index + 1 : planet1_index])\n```\n"}
80
+ {"task_id": "Python/79", "prompt": "为以下Python代码生成单元测试\n```Python\ndef derivative(xs: list):\n return [(i * x) for i, x in enumerate(xs)][1:]\n```\n"}
81
+ {"task_id": "Python/80", "prompt": "为以下Python代码生成单元测试\n```Python\ndef string_sequence(n: int) -> str:\n return ' '.join([str(x) for x in range(n + 1)])\n```\n"}
82
+ {"task_id": "Python/81", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_upper(s):\n count = 0\n for i in range(0,len(s),2):\n if s[i] in \"AEIOU\":\n count += 1\n return count\n```\n"}
83
+ {"task_id": "Python/82", "prompt": "为以下Python代码生成单元测试\n```Python\ndef double_the_difference(lst):\n return sum([i**2 for i in lst if i > 0 and i%2!=0 and \".\" not in str(i)])\n```\n"}
84
+ {"task_id": "Python/83", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef filter_by_prefix(strings: List[str], prefix: str) -> List[str]:\n return [x for x in strings if x.startswith(prefix)]\n```\n"}
85
+ {"task_id": "Python/84", "prompt": "为以下Python代码生成单元测试\n```Python\ndef words_string(s):\n if not s:\n return []\n\n s_list = []\n\n for letter in s:\n if letter == ',':\n s_list.append(' ')\n else:\n s_list.append(letter)\n\n s_list = \"\".join(s_list)\n return s_list.split()\n```\n"}
86
+ {"task_id": "Python/85", "prompt": "为以下Python代码生成单元测试\n```Python\ndef get_row(lst, x):\n coords = [(i, j) for i in range(len(lst)) for j in range(len(lst[i])) if lst[i][j] == x]\n return sorted(sorted(coords, key=lambda x: x[1], reverse=True), key=lambda x: x[0])\n```\n"}
87
+ {"task_id": "Python/86", "prompt": "为以下Python代码生成单元测试\n```Python\ndef reverse_delete(s,c):\n s = ''.join([char for char in s if char not in c])\n return (s,s[::-1] == s)\n```\n"}
88
+ {"task_id": "Python/87", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef has_close_elements(numbers: List[float], threshold: float) -> bool:\n for idx, elem in enumerate(numbers):\n for idx2, elem2 in enumerate(numbers):\n if idx != idx2:\n distance = abs(elem - elem2)\n if distance < threshold:\n return True\n\n return False\n```\n"}
89
+ {"task_id": "Python/88", "prompt": "为以下Python代码生成单元测试\n```Python\ndef smallest_change(arr):\n ans = 0\n for i in range(len(arr) // 2):\n if arr[i] != arr[len(arr) - i - 1]:\n ans += 1\n return ans\n```\n"}
90
+ {"task_id": "Python/89", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef factorize(n: int) -> List[int]:\n import math\n fact = []\n i = 2\n while i <= int(math.sqrt(n) + 1):\n if n % i == 0:\n fact.append(i)\n n //= i\n else:\n i += 1\n\n if n > 1:\n fact.append(n)\n return fact\n```\n"}
91
+ {"task_id": "Python/90", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Any\n\n\ndef filter_integers(values: List[Any]) -> List[int]:\n return [x for x in values if isinstance(x, int)]\n```\n"}
92
+ {"task_id": "Python/91", "prompt": "为以下Python代码生成单元测试\n```Python\ndef truncate_number(number: float) -> float:\n return number % 1.0\n```\n"}
93
+ {"task_id": "Python/92", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef parse_music(music_string: str) -> List[int]:\n note_map = {'o': 4, 'o|': 2, '.|': 1}\n return [note_map[x] for x in music_string.split(' ') if x]\n```\n"}
94
+ {"task_id": "Python/93", "prompt": "为以下Python代码生成单元测试\n```Python\ndef sort_array(arr):\n return sorted(sorted(arr), key=lambda x: bin(x)[2:].count('1'))\n```\n"}
95
+ {"task_id": "Python/94", "prompt": "为以下Python代码生成单元测试\n```Python\ndef generate_integers(a, b):\n lower = max(2, min(a, b))\n upper = min(8, max(a, b))\n\n return [i for i in range(lower, upper+1) if i % 2 == 0]\n```\n"}
96
+ {"task_id": "Python/95", "prompt": "为以下Python代码生成单元测试\n```Python\ndef check_if_last_char_is_a_letter(txt):\n \n check = txt.split(' ')[-1]\n return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False\n```\n"}
97
+ {"task_id": "Python/96", "prompt": "为以下Python代码生成单元测试\n```Python\ndef encode_shift(s: str):\n \"\"\"\n returns encoded string by shifting every character by 5 in the alphabet.\n \"\"\"\n return \"\".join([chr(((ord(ch) + 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n\n\ndef decode_shift(s: str):\n return \"\".join([chr(((ord(ch) - 5 - ord(\"a\")) % 26) + ord(\"a\")) for ch in s])\n```\n"}
98
+ {"task_id": "Python/97", "prompt": "为以下Python代码生成单元测试\n```Python\ndef prime_fib(n: int):\n import math\n\n def is_prime(p):\n if p < 2:\n return False\n for k in range(2, min(int(math.sqrt(p)) + 1, p - 1)):\n if p % k == 0:\n return False\n return True\n f = [0, 1]\n while True:\n f.append(f[-1] + f[-2])\n if is_prime(f[-1]):\n n -= 1\n if n == 0:\n return f[-1]\n```\n"}
99
+ {"task_id": "Python/98", "prompt": "为以下Python代码生成单元测试\n```Python\ndef strlen(string: str) -> int:\n return len(string)\n```\n"}
100
+ {"task_id": "Python/99", "prompt": "为以下Python代码生成单元测试\n```Python\ndef encode(message):\n vowels = \"aeiouAEIOU\"\n vowels_replace = dict([(i, chr(ord(i) + 2)) for i in vowels])\n message = message.swapcase()\n return ''.join([vowels_replace[i] if i in vowels else i for i in message])\n```\n"}
101
+ {"task_id": "Python/100", "prompt": "为以下Python代码生成单元测试\n```Python\ndef choose_num(x, y):\n if x > y:\n return -1\n if y % 2 == 0:\n return y\n if x == y:\n return -1\n return y - 1\n```\n"}
102
+ {"task_id": "Python/101", "prompt": "为以下Python代码生成单元测试\n```Python\ndef even_odd_count(num):\n even_count = 0\n odd_count = 0\n for i in str(abs(num)):\n if int(i)%2==0:\n even_count +=1\n else:\n odd_count +=1\n return (even_count, odd_count)\n```\n"}
103
+ {"task_id": "Python/102", "prompt": "为以下Python代码生成单元测试\n```Python\ndef anti_shuffle(s):\n return ' '.join([''.join(sorted(list(i))) for i in s.split(' ')])\n```\n"}
104
+ {"task_id": "Python/103", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_equal_to_sum_even(n):\n return n%2 == 0 and n >= 8\n```\n"}
105
+ {"task_id": "Python/104", "prompt": "为以下Python代码生成单元测试\n```Python\ndef max_element(l: list):\n m = l[0]\n for e in l:\n if e > m:\n m = e\n return m\n```\n"}
106
+ {"task_id": "Python/105", "prompt": "为以下Python代码生成单元测试\n```Python\ndef largest_divisor(n: int) -> int:\n for i in reversed(range(n)):\n if n % i == 0:\n return i\n```\n"}
107
+ {"task_id": "Python/106", "prompt": "为以下Python代码生成单元测试\n```Python\ndef count_nums(arr):\n def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return len(list(filter(lambda x: x > 0, [digits_sum(i) for i in arr])))\n```\n"}
108
+ {"task_id": "Python/107", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef sort_numbers(numbers: str) -> str:\n value_map = {\n 'zero': 0,\n 'one': 1,\n 'two': 2,\n 'three': 3,\n 'four': 4,\n 'five': 5,\n 'six': 6,\n 'seven': 7,\n 'eight': 8,\n 'nine': 9\n }\n return ' '.join(sorted([x for x in numbers.split(' ') if x], key=lambda x: value_map[x]))\n```\n"}
109
+ {"task_id": "Python/108", "prompt": "为以下Python代码生成单元测试\n```Python\ndef largest_smallest_integers(lst):\n smallest = list(filter(lambda x: x < 0, lst))\n largest = list(filter(lambda x: x > 0, lst))\n return (max(smallest) if smallest else None, min(largest) if largest else None)\n```\n"}
110
+ {"task_id": "Python/109", "prompt": "为以下Python代码生成单元测试\n```Python\ndef car_race_collision(n: int):\n return n**2\n```\n"}
111
+ {"task_id": "Python/110", "prompt": "为以下Python代码生成单元测试\n```Python\ndef specialFilter(nums):\n \n count = 0\n for num in nums:\n if num > 10:\n odd_digits = (1, 3, 5, 7, 9)\n number_as_string = str(num)\n if int(number_as_string[0]) in odd_digits and int(number_as_string[-1]) in odd_digits:\n count += 1\n \n return count \n```\n"}
112
+ {"task_id": "Python/111", "prompt": "为以下Python代码生成单元测试\n```Python\ndef solution(lst):\n return sum([x for idx, x in enumerate(lst) if idx%2==0 and x%2==1])\n```\n"}
113
+ {"task_id": "Python/112", "prompt": "为以下Python代码生成单元测试\n```Python\ndef same_chars(s0: str, s1: str):\n return set(s0) == set(s1)\n```\n"}
114
+ {"task_id": "Python/113", "prompt": "为以下Python代码生成单元测试\n```Python\ndef prime_length(string):\n l = len(string)\n if l == 0 or l == 1:\n return False\n for i in range(2, l):\n if l % i == 0:\n return False\n return True\n```\n"}
115
+ {"task_id": "Python/114", "prompt": "为以下Python代码生成单元测试\n```Python\ndef digitSum(s):\n if s == \"\": return 0\n return sum(ord(char) if char.isupper() else 0 for char in s)\n```\n"}
116
+ {"task_id": "Python/115", "prompt": "为以下Python代码生成单元测试\n```Python\ndef closest_integer(value):\n from math import floor, ceil\n\n if value.count('.') == 1:\n # remove trailing zeros\n while (value[-1] == '0'):\n value = value[:-1]\n\n num = float(value)\n if value[-2:] == '.5':\n if num > 0:\n res = ceil(num)\n else:\n res = floor(num)\n elif len(value) > 0:\n res = int(round(num))\n else:\n res = 0\n\n return res\n```\n\n"}
117
+ {"task_id": "Python/116", "prompt": "为以下Python代码生成单元测试\n```Python\ndef encrypt(s):\n d = 'abcdefghijklmnopqrstuvwxyz'\n out = ''\n for c in s:\n if c in d:\n out += d[(d.index(c)+2*2) % 26]\n else:\n out += c\n return out\n```\n"}
118
+ {"task_id": "Python/117", "prompt": "为以下Python代码生成单元测试\n```Python\ndef can_arrange(arr):\n ind=-1\n i=1\n while i<len(arr):\n if arr[i]<arr[i-1]:\n ind=i\n i+=1\n return ind\n```\n"}
119
+ {"task_id": "Python/118", "prompt": "为以下Python代码生成单元测试\n```Python\ndef multiply(a, b):\n return abs(a % 10) * abs(b % 10)\n```\n"}
120
+ {"task_id": "Python/119", "prompt": "为以下Python代码生成单元测试\n```Python\ndef unique(l: list):\n return sorted(list(set(l)))\n```\n"}
121
+ {"task_id": "Python/120", "prompt": "为以下Python代码生成单元测试\n```Python\ndef pairs_sum_to_zero(l):\n for i, l1 in enumerate(l):\n for j in range(i + 1, len(l)):\n if l1 + l[j] == 0:\n return True\n return False\n```\n"}
122
+ {"task_id": "Python/121", "prompt": "为以下Python代码生成单元测试\n```Python\ndef x_or_y(n, x, y):\n if n == 1:\n return y\n for i in range(2, n):\n if n % i == 0:\n return y\n break\n else:\n return x\n```\n"}
123
+ {"task_id": "Python/122", "prompt": "为以下Python代码生成单元测试\n```Python\ndef triples_sum_to_zero(l: list):\n for i in range(len(l)):\n for j in range(i + 1, len(l)):\n for k in range(j + 1, len(l)):\n if l[i] + l[j] + l[k] == 0:\n return True\n return False\n```\n"}
124
+ {"task_id": "Python/123", "prompt": "为以下Python代码生成单元测试\n```Python\ndef hex_key(num):\n primes = ('2', '3', '5', '7', 'B', 'D')\n total = 0\n for i in range(0, len(num)):\n if num[i] in primes:\n total += 1\n return total\n```\n"}
125
+ {"task_id": "Python/124", "prompt": "为以下Python代码生成单元测试\n```Python\ndef common(l1: list, l2: list):\n ret = set()\n for e1 in l1:\n for e2 in l2:\n if e1 == e2:\n ret.add(e1)\n return sorted(list(ret))\n```\n"}
126
+ {"task_id": "Python/125", "prompt": "为以下Python代码生成单元测试\n```Python\ndef compare_one(a, b):\n temp_a, temp_b = a, b\n if isinstance(temp_a, str): temp_a = temp_a.replace(',','.')\n if isinstance(temp_b, str): temp_b = temp_b.replace(',','.')\n if float(temp_a) == float(temp_b): return None\n return a if float(temp_a) > float(temp_b) else b \n```\n"}
127
+ {"task_id": "Python/126", "prompt": "为以下Python代码生成单元测试\n```Python\ndef words_in_sentence(sentence):\n new_lst = []\n for word in sentence.split():\n flg = 0\n if len(word) == 1:\n flg = 1\n for i in range(2, len(word)):\n if len(word)%i == 0:\n flg = 1\n if flg == 0 or len(word) == 2:\n new_lst.append(word)\n return \" \".join(new_lst)\n```\n"}
128
+ {"task_id": "Python/127", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef string_xor(a: str, b: str) -> str:\n def xor(i, j):\n if i == j:\n return '0'\n else:\n return '1'\n\n return ''.join(xor(x, y) for x, y in zip(a, b))\n```\n"}
129
+ {"task_id": "Python/128", "prompt": "为以下Python代码生成单元测试\n```Python\ndef move_one_ball(arr):\n if len(arr)==0:\n return True\n sorted_array=sorted(arr)\n my_arr=[]\n \n min_value=min(arr)\n min_index=arr.index(min_value)\n my_arr=arr[min_index:]+arr[0:min_index]\n for i in range(len(arr)):\n if my_arr[i]!=sorted_array[i]:\n return False\n return True\n```\n"}
130
+ {"task_id": "Python/129", "prompt": "为以下Python代码生成单元测试\n```Python\ndef solve(s):\n flg = 0\n idx = 0\n new_str = list(s)\n for i in s:\n if i.isalpha():\n new_str[idx] = i.swapcase()\n flg = 1\n idx += 1\n s = \"\"\n for i in new_str:\n s += i\n if flg == 0:\n return s[len(s)::-1]\n return s\n```\n"}
131
+ {"task_id": "Python/130", "prompt": "为以下Python代码生成单元测试\n```Python\ndef remove_vowels(text):\n return \"\".join([s for s in text if s.lower() not in [\"a\", \"e\", \"i\", \"o\", \"u\"]])\n```\n"}
132
+ {"task_id": "Python/131", "prompt": "为以下Python代码生成单元测试\n```Python\ndef digits(n):\n product = 1\n odd_count = 0\n for digit in str(n):\n int_digit = int(digit)\n if int_digit%2 == 1:\n product= product*int_digit\n odd_count+=1\n if odd_count ==0:\n return 0\n else:\n return product\n```\n"}
133
+ {"task_id": "Python/132", "prompt": "为以下Python代码生成单元测试\n```Python\ndef numerical_letter_grade(grades):\n\n \n letter_grade = []\n for gpa in grades:\n if gpa == 4.0:\n letter_grade.append(\"A+\")\n elif gpa > 3.7:\n letter_grade.append(\"A\")\n elif gpa > 3.3:\n letter_grade.append(\"A-\")\n elif gpa > 3.0:\n letter_grade.append(\"B+\")\n elif gpa > 2.7:\n letter_grade.append(\"B\")\n elif gpa > 2.3:\n letter_grade.append(\"B-\")\n elif gpa > 2.0:\n letter_grade.append(\"C+\")\n elif gpa > 1.7:\n letter_grade.append(\"C\")\n elif gpa > 1.3:\n letter_grade.append(\"C-\")\n elif gpa > 1.0:\n letter_grade.append(\"D+\")\n elif gpa > 0.7:\n letter_grade.append(\"D\")\n elif gpa > 0.0:\n letter_grade.append(\"D-\")\n else:\n letter_grade.append(\"E\")\n return letter_grade\n```\n"}
134
+ {"task_id": "Python/133", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fibfib(n: int):\n if n == 0:\n return 0\n if n == 1:\n return 0\n if n == 2:\n return 1\n return fibfib(n - 1) + fibfib(n - 2) + fibfib(n - 3)\n```\n"}
135
+ {"task_id": "Python/134", "prompt": "为以下Python代码生成单元测试\n```Python\ndef add(lst):\n return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])\n```\n"}
136
+ {"task_id": "Python/135", "prompt": "为以下Python代码生成单元测试\n```Python\ndef maximum(arr, k):\n if k == 0:\n return []\n arr.sort()\n ans = arr[-k:]\n return ans\n```\n"}
137
+ {"task_id": "Python/136", "prompt": "为以下Python代码生成单元测试\n```Python\ndef skjkasdkd(lst):\n def isPrime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n\n return True\n maxx = 0\n i = 0\n while i < len(lst):\n if(lst[i] > maxx and isPrime(lst[i])):\n maxx = lst[i]\n i+=1\n result = sum(int(digit) for digit in str(maxx))\n return result\n```\n"}
138
+ {"task_id": "Python/137", "prompt": "为以下Python代码生成单元测试\n```Python\ndef simplify(x, n):\n a, b = x.split(\"/\")\n c, d = n.split(\"/\")\n numerator = int(a) * int(c)\n denom = int(b) * int(d)\n if (numerator/denom == int(numerator/denom)):\n return True\n return False\n```\n"}
139
+ {"task_id": "Python/138", "prompt": "为以下Python代码生成单元测试\n```Python\ndef match_parens(lst):\n def check(s):\n val = 0\n for i in s:\n if i == '(':\n val = val + 1\n else:\n val = val - 1\n if val < 0:\n return False\n return True if val == 0 else False\n\n S1 = lst[0] + lst[1]\n S2 = lst[1] + lst[0]\n return 'Yes' if check(S1) or check(S2) else 'No'\n```\n"}
140
+ {"task_id": "Python/139", "prompt": "为以下Python代码生成单元测试\n```Python\ndef histogram(test):\n dict1={}\n list1=test.split(\" \")\n t=0\n\n for i in list1:\n if(list1.count(i)>t) and i!='':\n t=list1.count(i)\n if t>0:\n for i in list1:\n if(list1.count(i)==t):\n \n dict1[i]=t\n return dict1\n```\n"}
141
+ {"task_id": "Python/140", "prompt": "为以下Python代码生成单元测试\n```Python\ndef total_match(lst1, lst2):\n l1 = 0\n for st in lst1:\n l1 += len(st)\n \n l2 = 0\n for st in lst2:\n l2 += len(st)\n \n if l1 <= l2:\n return lst1\n else:\n return lst2\n```\n"}
142
+ {"task_id": "Python/141", "prompt": "为以下Python代码生成单元测试\n```Python\ndef circular_shift(x, shift):\n s = str(x)\n if shift > len(s):\n return s[::-1]\n else:\n return s[len(s) - shift:] + s[:len(s) - shift]\n```\n"}
143
+ {"task_id": "Python/142", "prompt": "为以下Python代码生成单元测试\n```Python\ndef file_name_check(file_name):\n suf = ['txt', 'exe', 'dll']\n lst = file_name.split(sep='.')\n if len(lst) != 2:\n return 'No'\n if not lst[1] in suf:\n return 'No'\n if len(lst[0]) == 0:\n return 'No'\n if not lst[0][0].isalpha():\n return 'No'\n t = len([x for x in lst[0] if x.isdigit()])\n if t > 3:\n return 'No'\n return 'Yes'\n```\n"}
144
+ {"task_id": "Python/143", "prompt": "为以下Python代码生成单元测试\n```Python\nFIX = \"\"\"\nAdd more test cases.\n\"\"\"\n\ndef vowels_count(s):\n vowels = \"aeiouAEIOU\"\n n_vowels = sum(c in vowels for c in s)\n if s[-1] == 'y' or s[-1] == 'Y':\n n_vowels += 1\n return n_vowels\n```\n"}
145
+ {"task_id": "Python/144", "prompt": "为以下Python代码生成单元测试\n```Python\ndef is_nested(string):\n opening_bracket_index = []\n closing_bracket_index = []\n for i in range(len(string)):\n if string[i] == '[':\n opening_bracket_index.append(i)\n else:\n closing_bracket_index.append(i)\n closing_bracket_index.reverse()\n cnt = 0\n i = 0\n l = len(closing_bracket_index)\n for idx in opening_bracket_index:\n if i < l and idx < closing_bracket_index[i]:\n cnt += 1\n i += 1\n return cnt >= 2\n```\n \n\n"}
146
+ {"task_id": "Python/145", "prompt": "为以下Python代码生成单元测试\n```Python\ndef even_odd_palindrome(n):\n def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\n even_palindrome_count = 0\n odd_palindrome_count = 0\n\n for i in range(1, n+1):\n if i%2 == 1 and is_palindrome(i):\n odd_palindrome_count += 1\n elif i%2 == 0 and is_palindrome(i):\n even_palindrome_count += 1\n return (even_palindrome_count, odd_palindrome_count)\n```\n"}
147
+ {"task_id": "Python/146", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef below_zero(operations: List[int]) -> bool:\n balance = 0\n\n for op in operations:\n balance += op\n if balance < 0:\n return True\n\n return False\n```\n"}
148
+ {"task_id": "Python/147", "prompt": "为以下Python代码生成单元测试\n```Python\ndef below_threshold(l: list, t: int):\n for e in l:\n if e >= t:\n return False\n return True\n```\n"}
149
+ {"task_id": "Python/148", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List\n\n\ndef parse_nested_parens(paren_string: str) -> List[int]:\n def parse_paren_group(s):\n depth = 0\n max_depth = 0\n for c in s:\n if c == '(':\n depth += 1\n max_depth = max(depth, max_depth)\n else:\n depth -= 1\n\n return max_depth\n\n return [parse_paren_group(x) for x in paren_string.split(' ') if x]\n```\n"}
150
+ {"task_id": "Python/149", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Tuple\n\n\ndef rolling_max(numbers: List[int]) -> List[int]:\n running_max = None\n result = []\n\n for n in numbers:\n if running_max is None:\n running_max = n\n else:\n running_max = max(running_max, n)\n\n result.append(running_max)\n\n return result\n```\n"}
151
+ {"task_id": "Python/150", "prompt": "为以下Python代码生成单元测试\n```Python\ndef int_to_mini_roman(number):\n num = [1, 4, 5, 9, 10, 40, 50, 90, \n 100, 400, 500, 900, 1000] \n sym = [\"I\", \"IV\", \"V\", \"IX\", \"X\", \"XL\", \n \"L\", \"XC\", \"C\", \"CD\", \"D\", \"CM\", \"M\"] \n i = 12\n res = ''\n while number: \n div = number // num[i] \n number %= num[i] \n while div: \n res += sym[i] \n div -= 1\n i -= 1\n return res.lower()\n```\n"}
152
+ {"task_id": "Python/151", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fix_spaces(text):\n new_text = \"\"\n i = 0\n start, end = 0, 0\n while i < len(text):\n if text[i] == \" \":\n end += 1\n else:\n if end - start > 2:\n new_text += \"-\"+text[i]\n elif end - start > 0:\n new_text += \"_\"*(end - start)+text[i]\n else:\n new_text += text[i]\n start, end = i+1, i+1\n i+=1\n if end - start > 2:\n new_text += \"-\"\n elif end - start > 0:\n new_text += \"_\"\n return new_text\n```\n"}
153
+ {"task_id": "Python/152", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fib(n: int):\n if n == 0:\n return 0\n if n == 1:\n return 1\n return fib(n - 1) + fib(n - 2)\n```\n"}
154
+ {"task_id": "Python/153", "prompt": "为以下Python代码生成单元测试\n```Python\ndef correct_bracketing(brackets: str):\n depth = 0\n for b in brackets:\n if b == \"(\":\n depth += 1\n else:\n depth -= 1\n if depth < 0:\n return False\n return depth == 0\n```\n"}
155
+ {"task_id": "Python/154", "prompt": "为以下Python代码生成单元测试\n```Python\ndef fib4(n: int):\n results = [0, 0, 2, 0]\n if n < 4:\n return results[n]\n\n for _ in range(4, n + 1):\n results.append(results[-1] + results[-2] + results[-3] + results[-4])\n results.pop(0)\n\n return results[-1]\n```\n"}
156
+ {"task_id": "Python/155", "prompt": "为以下Python代码生成单元测试\n```Python\ndef order_by_points(nums):\n def digits_sum(n):\n neg = 1\n if n < 0: n, neg = -1 * n, -1 \n n = [int(i) for i in str(n)]\n n[0] = n[0] * neg\n return sum(n)\n return sorted(nums, key=digits_sum)\n```\n"}
157
+ {"task_id": "Python/156", "prompt": "为以下Python代码生成单元测试\n```Python\nfrom typing import List, Optional\n\n\ndef longest(strings: List[str]) -> Optional[str]:\n if not strings:\n return None\n\n maxlen = max(len(x) for x in strings)\n for s in strings:\n if len(s) == maxlen:\n return s\n```\n"}
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "transformers_version": "4.33.2"
6
+ }
pytorch_model-00001-of-00002.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e5152251e91b28a010ceb7e435ae8cdf835bc1a34915f9aa6256850d6de31cf
3
+ size 9976754202
pytorch_model-00002-of-00002.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4dbf4de5e0f7427821f4d061d1d44df42fe9a2d67f073f588b1f6c7e3de14a18
3
+ size 3500442883
pytorch_model.bin.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ca9b8f5a8f500eafd4bdcbd52898a75834f2f5d596630cdca4da3c30034b625
3
+ size 23950
special_tokens_map.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "▁<PRE>",
4
+ "▁<MID>",
5
+ "▁<SUF>",
6
+ "▁<EOT>"
7
+ ],
8
+ "bos_token": {
9
+ "content": "<s>",
10
+ "lstrip": false,
11
+ "normalized": true,
12
+ "rstrip": false,
13
+ "single_word": false
14
+ },
15
+ "eos_token": {
16
+ "content": "</s>",
17
+ "lstrip": false,
18
+ "normalized": true,
19
+ "rstrip": false,
20
+ "single_word": false
21
+ },
22
+ "unk_token": {
23
+ "content": "<unk>",
24
+ "lstrip": false,
25
+ "normalized": true,
26
+ "rstrip": false,
27
+ "single_word": false
28
+ }
29
+ }
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:45ccb9c8b6b561889acea59191d66986d314e7cbd6a78abc6e49b139ca91c1e6
3
+ size 500058
tokenizer_config.json ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": false,
4
+ "additional_special_tokens": [
5
+ "▁<PRE>",
6
+ "▁<MID>",
7
+ "▁<SUF>",
8
+ "▁<EOT>"
9
+ ],
10
+ "bos_token": {
11
+ "__type": "AddedToken",
12
+ "content": "<s>",
13
+ "lstrip": false,
14
+ "normalized": true,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "clean_up_tokenization_spaces": false,
19
+ "eos_token": {
20
+ "__type": "AddedToken",
21
+ "content": "</s>",
22
+ "lstrip": false,
23
+ "normalized": true,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ },
27
+ "eot_token": "▁<EOT>",
28
+ "fill_token": "<FILL_ME>",
29
+ "legacy": false,
30
+ "middle_token": "▁<MID>",
31
+ "model_max_length": 1000000000000000019884624838656,
32
+ "pad_token": null,
33
+ "prefix_token": "▁<PRE>",
34
+ "sp_model_kwargs": {},
35
+ "suffix_first": false,
36
+ "suffix_token": "▁<SUF>",
37
+ "tokenizer_class": "CodeLlamaTokenizer",
38
+ "unk_token": {
39
+ "__type": "AddedToken",
40
+ "content": "<unk>",
41
+ "lstrip": false,
42
+ "normalized": true,
43
+ "rstrip": false,
44
+ "single_word": false
45
+ },
46
+ "use_default_system_prompt": false
47
+ }