flame-rust-30m / rust_tasks.json
Rohxn08's picture
Upload folder using huggingface_hub
8f4068b verified
Raw History Blame Contribute Delete
4.8 kB
{
"about": "Task set for tools/task_eval.py. complete: prompt ends with the function's opening brace; test is a main() with asserts. fix: source must fail with the given error code; accept lists substrings that count as the correct fix in the model's help text.",
"tasks": [
{"id": "add", "kind": "complete",
"prompt": "/// Returns the sum of `a` and `b`.\nfn add(a: i32, b: i32) -> i32 {",
"test": "fn main() { assert_eq!(add(2, 3), 5); assert_eq!(add(-4, 4), 0); }"},
{"id": "is_even", "kind": "complete",
"prompt": "/// Returns true if `n` is even.\nfn is_even(n: u32) -> bool {",
"test": "fn main() { assert!(is_even(4)); assert!(!is_even(7)); assert!(is_even(0)); }"},
{"id": "max_of", "kind": "complete",
"prompt": "/// Returns the larger of `a` and `b`.\nfn max_of(a: i32, b: i32) -> i32 {",
"test": "fn main() { assert_eq!(max_of(3, 9), 9); assert_eq!(max_of(-1, -5), -1); }"},
{"id": "square", "kind": "complete",
"prompt": "/// Returns `x` multiplied by itself.\nfn square(x: i64) -> i64 {",
"test": "fn main() { assert_eq!(square(7), 49); assert_eq!(square(-3), 9); }"},
{"id": "factorial", "kind": "complete",
"prompt": "/// Returns n! (the factorial of `n`).\nfn factorial(n: u64) -> u64 {",
"test": "fn main() { assert_eq!(factorial(0), 1); assert_eq!(factorial(5), 120); }"},
{"id": "fibonacci", "kind": "complete",
"prompt": "/// Returns the `n`-th Fibonacci number (fib(0) = 0, fib(1) = 1).\nfn fibonacci(n: u32) -> u64 {",
"test": "fn main() { assert_eq!(fibonacci(0), 0); assert_eq!(fibonacci(1), 1); assert_eq!(fibonacci(10), 55); }"},
{"id": "sum_slice", "kind": "complete",
"prompt": "/// Returns the sum of all numbers in `v`.\nfn sum_slice(v: &[i32]) -> i32 {",
"test": "fn main() { assert_eq!(sum_slice(&[1, 2, 3]), 6); assert_eq!(sum_slice(&[]), 0); }"},
{"id": "contains_zero", "kind": "complete",
"prompt": "/// Returns true if `v` contains the number 0.\nfn contains_zero(v: &[i32]) -> bool {",
"test": "fn main() { assert!(contains_zero(&[3, 0, 1])); assert!(!contains_zero(&[1, 2])); }"},
{"id": "count_chars", "kind": "complete",
"prompt": "/// Returns the number of characters in `s`.\nfn count_chars(s: &str) -> usize {",
"test": "fn main() { assert_eq!(count_chars(\"hello\"), 5); assert_eq!(count_chars(\"\"), 0); }"},
{"id": "reverse_string", "kind": "complete",
"prompt": "/// Returns `s` with its characters in reverse order.\nfn reverse_string(s: &str) -> String {",
"test": "fn main() { assert_eq!(reverse_string(\"abc\"), \"cba\"); assert_eq!(reverse_string(\"\"), \"\"); }"},
{"id": "first_word", "kind": "complete",
"prompt": "/// Returns the first word of `s` (everything before the first space).\nfn first_word(s: &str) -> &str {",
"test": "fn main() { assert_eq!(first_word(\"hello world\"), \"hello\"); assert_eq!(first_word(\"rust\"), \"rust\"); }"},
{"id": "abs_value", "kind": "complete",
"prompt": "/// Returns the absolute value of `x`.\nfn abs_value(x: i32) -> i32 {",
"test": "fn main() { assert_eq!(abs_value(-8), 8); assert_eq!(abs_value(3), 3); }"},
{"id": "use_after_move", "kind": "fix", "code": "E0382",
"source": "fn main() {\n let s = String::from(\"hello\");\n let t = s;\n println!(\"{}\", s);\n}\n",
"accept": [".clone()", "= &s"]},
{"id": "assign_immutable", "kind": "fix", "code": "E0384",
"source": "fn main() {\n let x = 5;\n x = 6;\n println!(\"{}\", x);\n}\n",
"accept": ["let mut x"]},
{"id": "typo_variable", "kind": "fix", "code": "E0425",
"source": "fn main() {\n let count = 1;\n println!(\"{}\", cont);\n}\n",
"accept": ["count"]},
{"id": "push_immutable_vec", "kind": "fix", "code": "E0596",
"source": "fn main() {\n let v = Vec::new();\n v.push(1);\n println!(\"{:?}\", v);\n}\n",
"accept": ["let mut v"]},
{"id": "missing_import", "kind": "fix", "code": "E0433",
"source": "fn main() {\n let mut m = HashMap::new();\n m.insert(1, 2);\n}\n",
"accept": ["use std::collections::HashMap"]},
{"id": "trailing_semicolon", "kind": "fix", "code": "E0308",
"source": "fn five() -> i32 {\n 5;\n}\n\nfn main() {\n println!(\"{}\", five());\n}\n",
"accept": ["remove this semicolon", "remove the semicolon"]},
{"id": "mutable_reference", "kind": "fix", "code": "E0596",
"source": "fn add_one(v: &Vec<i32>) {\n v.push(1);\n}\n\nfn main() {\n let mut v = vec![];\n add_one(&mut v);\n}\n",
"accept": ["&mut Vec"]},
{"id": "str_to_int", "kind": "fix", "code": "E0308",
"source": "fn main() {\n let x: i32 = \"5\";\n println!(\"{}\", x);\n}\n",
"accept": ["= 5;", ".parse", "x: &str"]}
]
}