Dataset Viewer
Auto-converted to Parquet Duplicate
id
string
language
string
expected_action
string
prompt
string
harness_template
string
must_contain
list
must_not_contain
list
tags
list
max_new_tokens
int64
go_normalize_path
go
code
Return only Go code. Implement exactly this function: func NormalizePath(input string) string Rules: - Unix-style paths only. - Collapse repeated slashes. - Remove '.' segments. - Resolve '..' without going above root for absolute paths. - Preserve leading '..' segments for relative paths. - Return '/' for empty absol...
package main import "testing" {{code}} func TestNormalizePathAbsolute(t *testing.T) { cases := map[string]string{ "/a//b/./c/../d": "/a/b/d", "/../../a": "/a", "///": "/", } for input, want := range cases { if got := NormalizePath(input); got != want { t.Fatalf("NormalizePath(%q) = ...
[ "func NormalizePath" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test" ]
384
go_parse_size
go
code
Return only Go code. Implement exactly this function: func ParseSize(input string) (uint64, error) Rules: - Support B, KB, MB, and GB units with base 1024. - Unit matching is ASCII case-insensitive. - Allow surrounding whitespace and optional whitespace between number and unit. - Reject empty input, decimals, negative...
package main import "testing" {{code}} func TestParseSizeValid(t *testing.T) { cases := map[string]uint64{ "42": 42, "2 KB": 2 * 1024, "3mb": 3 * 1024 * 1024, "1Gb": 1024 * 1024 * 1024, } for input, want := range cases { got, err := ParseSize(input) if err != nil || got != want { t.Fatalf("ParseSiz...
[ "func ParseSize" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test" ]
384
go_merge_intervals
go
code
Return only Go code. Implement exactly this function: type Interval struct { Start int; End int } func MergeIntervals(intervals []Interval) []Interval Rules: - Normalize reversed intervals like {5,3} into {3,5}. - Sort by Start ascending, then End ascending. - Merge overlapping intervals and also merge touching interv...
package main import ( "reflect" "testing" ) {{code}} func TestMergeIntervals(t *testing.T) { got := MergeIntervals([]Interval{{5, 3}, {4, 8}, {20, 21}, {22, 22}}) want := []Interval{{3, 8}, {20, 22}} if !reflect.DeepEqual(got, want) { t.Fatalf("got %#v, want %#v", got, want) } } func TestMergeIntervalsEmpty...
[ "type Interval struct", "func MergeIntervals" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test" ]
384
go_dedup_case_insensitive
go
code
Return only Go code. Implement exactly this function: func DedupCaseInsensitive(values []string) []string Rules: - Compare using ASCII lowercase after trimming surrounding whitespace. - Skip entries that become empty after trimming. - Preserve the first original trimmed spelling for each unique lowercase key. - Use pa...
package main import ( "reflect" "testing" ) {{code}} func TestDedupCaseInsensitive(t *testing.T) { got := DedupCaseInsensitive([]string{" Foo", "foo", "BAR", "bar ", "Baz"}) want := []string{"Foo", "BAR", "Baz"} if !reflect.DeepEqual(got, want) { t.Fatalf("got %#v, want %#v", got, want) } } func TestDedupC...
[ "func DedupCaseInsensitive" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test" ]
384
go_top_k_words
go
code
Return only Go code. Implement exactly this function: type WordCount struct { Word string; Count int } func TopKWords(words []string, k int) []WordCount Rules: - Trim each word and ignore empties. - Compare case-insensitively using ASCII lowercase. - Sort by frequency descending, then word ascending. - Return at most ...
package main import ( "reflect" "testing" ) {{code}} func TestTopKWords(t *testing.T) { got := TopKWords([]string{" Go ", "rust", "go", "Rust", "zig", "go"}, 2) want := []WordCount{{"go", 3}, {"rust", 2}} if !reflect.DeepEqual(got, want) { t.Fatalf("got %#v, want %#v", got, want) } } func TestTopKWordsZeroA...
[ "type WordCount struct", "func TopKWords" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test" ]
384
go_longest_balanced_prefix
go
code
Return only Go code. Implement exactly this function: func LongestBalancedPrefix(input string) int Rules: - Track only (), [], and {}. - Ignore all other bytes. - Return the byte index immediately after the longest prefix that is valid and fully balanced. - If the prefix becomes invalid because of a mismatched closing...
package main import "testing" {{code}} func TestLongestBalancedPrefixBalanced(t *testing.T) { cases := map[string]int{"([])x": 4, "{a[b]c}tail": 7, "abc": 3} for input, want := range cases { if got := LongestBalancedPrefix(input); got != want { t.Fatalf("%q got %d want %d", input, got, want) } } } func Te...
[ "func LongestBalancedPrefix" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test" ]
384
go_parse_csv_line
go
code
Return only Go code. Implement exactly this function: func ParseCSVLine(line string) ([]string, error) Rules: - Parse a single CSV record without using encoding/csv. - Commas split fields unless they are inside double quotes. - A doubled quote inside a quoted field becomes one quote. - Return an error for an unclosed ...
package main import ( "reflect" "testing" ) {{code}} func TestParseCSVLineValid(t *testing.T) { cases := []struct{ in string; want []string }{ {"a,b,c", []string{"a", "b", "c"}}, {`"a,b",c`, []string{"a,b", "c"}}, {`"a""b",x`, []string{`a"b`, "x"}}, } for _, tc := range cases { got, err := ParseCSVLine(...
[ "func ParseCSVLine" ]
[ "panic(", "TODO", "encoding/csv" ]
[ "go", "code-first", "unit-test", "parser" ]
640
go_stable_toposort
go
code
Return only Go code. Implement exactly this function: func StableTopoSort(edges [][2]string) ([]string, bool) Rules: - Each edge is [from, to]. - Include every node that appears in any edge. - Return a topological order and true when possible. - When several nodes are ready, choose the lexicographically smallest node ...
package main import ( "reflect" "testing" ) {{code}} func TestStableTopoSortOrder(t *testing.T) { got, ok := StableTopoSort([][2]string{{"b", "d"}, {"a", "d"}, {"a", "c"}}) want := []string{"a", "b", "c", "d"} if !ok || !reflect.DeepEqual(got, want) { t.Fatalf("got %#v %v, want %#v true", got, ok, want) } } ...
[ "func StableTopoSort" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test", "graph" ]
640
go_shortest_path_grid
go
code
Return only Go code. Implement exactly this function: func ShortestPath(grid []string) int Rules: - Grid cells are bytes. - 'S' is the start, 'E' is the end, and '#' is blocked. - Move up, down, left, or right by one cell. - Return the shortest distance in steps. - Return -1 if unreachable or if the grid is malformed....
package main import "testing" {{code}} func TestShortestPath(t *testing.T) { grid := []string{"S..", ".#.", "..E"} if got := ShortestPath(grid); got != 4 { t.Fatalf("got %d want 4", got) } } func TestShortestPathInvalidAndBlocked(t *testing.T) { if got := ShortestPath([]string{"S#E"}); got != -1 { t.Fatalf(...
[ "func ShortestPath" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test", "graph" ]
512
go_render_template
go
code
Return only Go code. Implement exactly this function: func RenderTemplate(input string, values map[string]string) (string, error) Rules: - Replace ${name} with values["name"]. - Names may contain ASCII letters, digits, and underscore. - Return an error for unknown, empty, invalid, or unclosed placeholders. - Preserve ...
package main import "testing" {{code}} func TestRenderTemplate(t *testing.T) { got, err := RenderTemplate("hi ${name}, id=${id}", map[string]string{"name": "Ada", "id": "42"}) if err != nil || got != "hi Ada, id=42" { t.Fatalf("got %q %v", got, err) } } func TestRenderTemplateErrors(t *testing.T) { bad := []s...
[ "func RenderTemplate" ]
[ "panic(", "TODO", "interface{}" ]
[ "go", "code-first", "unit-test", "parser" ]
512
normalize_path
rust
code
Return only Rust code. Implement exactly this function: pub fn normalize_path(input: &str) -> String Rules: - Unix-style paths only. - Collapse repeated slashes. - Remove '.' segments. - Resolve '..' without going above root for absolute paths. - Preserve leading '..' segments for relative paths. - Return '/' for empt...
{{code}} #[cfg(test)] mod tests { use super::normalize_path; #[test] fn normalizes_absolute_paths() { assert_eq!(normalize_path("/a//b/./c/../d"), "/a/b/d"); assert_eq!(normalize_path("/../../a"), "/a"); assert_eq!(normalize_path("///"), "/"); } #[test] fn normalizes_r...
[ "pub fn normalize_path" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
parse_size
rust
code
Return only Rust code. Implement exactly this function: pub fn parse_size(input: &str) -> Result<u64, String> Rules: - Support B, KB, MB, and GB units with base 1024. - Unit matching is ASCII case-insensitive. - Allow surrounding whitespace and optional whitespace between number and unit. - Reject empty input, decimal...
{{code}} #[cfg(test)] mod tests { use super::parse_size; #[test] fn parses_valid_sizes() { assert_eq!(parse_size("42").unwrap(), 42); assert_eq!(parse_size("2 KB").unwrap(), 2 * 1024); assert_eq!(parse_size("3mb").unwrap(), 3 * 1024 * 1024); assert_eq!(parse_size("1Gb").unw...
[ "pub fn parse_size" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
merge_intervals
rust
code
Return only Rust code. Implement exactly this function: pub fn merge_intervals(intervals: &[(i32, i32)]) -> Vec<(i32, i32)> Rules: - Normalize reversed intervals like (5, 3) into (3, 5). - Sort by start ascending, then end ascending. - Merge overlapping intervals and also merge touching intervals where next.start <= c...
{{code}} #[cfg(test)] mod tests { use super::merge_intervals; #[test] fn merges_and_normalizes() { assert_eq!( merge_intervals(&[(5, 3), (4, 8), (20, 21), (22, 22)]), vec![(3, 8), (20, 22)] ); } #[test] fn handles_empty_and_separate() { assert_e...
[ "pub fn merge_intervals" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
dedup_case_insensitive
rust
code
Return only Rust code. Implement exactly this function: pub fn dedup_case_insensitive(values: &[&str]) -> Vec<String> Rules: - Compare using ASCII lowercase after trimming surrounding whitespace. - Skip entries that become empty after trimming. - Preserve the first original trimmed spelling for each unique lowercase k...
{{code}} #[cfg(test)] mod tests { use super::dedup_case_insensitive; #[test] fn preserves_first_spelling() { assert_eq!( dedup_case_insensitive(&[" Foo", "foo", "BAR", "bar ", "Baz"]), vec!["Foo".to_string(), "BAR".to_string(), "Baz".to_string()] ); } #[te...
[ "pub fn dedup_case_insensitive" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
top_k_words
rust
code
Return only Rust code. Implement exactly this function: pub fn top_k_words(words: &[&str], k: usize) -> Vec<(String, usize)> Rules: - Trim each word and ignore empties. - Compare case-insensitively using ASCII lowercase. - Sort by frequency descending, then word ascending. - Return at most k entries.
{{code}} #[cfg(test)] mod tests { use super::top_k_words; #[test] fn ranks_words() { assert_eq!( top_k_words(&[" Rust ", "go", "rust", "Go", "zig", "rust"], 2), vec![("rust".to_string(), 3), ("go".to_string(), 2)] ); } #[test] fn handles_zero_and_ties()...
[ "pub fn top_k_words" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
longest_balanced_prefix
rust
code
Return only Rust code. Implement exactly this function: pub fn longest_balanced_prefix(input: &str) -> usize Rules: - Track only (), [], and {}. - Ignore all other characters. - Return the byte index immediately after the longest prefix that is valid and fully balanced. - If the prefix becomes invalid because of a mis...
{{code}} #[cfg(test)] mod tests { use super::longest_balanced_prefix; #[test] fn finds_balanced_prefixes() { assert_eq!(longest_balanced_prefix("([])x"), 4); assert_eq!(longest_balanced_prefix("{a[b]c}tail"), 7); assert_eq!(longest_balanced_prefix("abc"), 3); } #[test] ...
[ "pub fn longest_balanced_prefix" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
parse_header_block
rust
code
Return only Rust code. Implement exactly this function: pub fn parse_header_block(input: &str) -> Result<Vec<(String, String)>, String> Rules: - Each non-empty line must be 'Key: Value'. - Trim outer whitespace around key and value. - Lowercase keys using ASCII lowercase. - Reject empty keys and duplicate keys.
{{code}} #[cfg(test)] mod tests { use super::parse_header_block; #[test] fn parses_headers() { assert_eq!( parse_header_block("Host: example.com\n X-Mode : Fast ").unwrap(), vec![ ("host".to_string(), "example.com".to_string()), ("x-mode".to_...
[ "pub fn parse_header_block" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
compact_sorted_numbers
rust
code
Return only Rust code. Implement exactly this function: pub fn compact_sorted_numbers(nums: &[i32]) -> Vec<String> Rules: - Input is sorted ascending but may contain duplicates. - Collapse duplicates before formatting. - Runs of length 1 become 'n'. - Runs of length 2 become 'a,b'. - Runs of length >= 3 become 'a-b'.
{{code}} #[cfg(test)] mod tests { use super::compact_sorted_numbers; #[test] fn compacts_ranges() { assert_eq!( compact_sorted_numbers(&[1, 2, 3, 5, 6, 9, 9, 10, 11, 12]), vec!["1-3".to_string(), "5,6".to_string(), "9-12".to_string()] ); } #[test] fn ha...
[ "pub fn compact_sorted_numbers" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
retry_schedule
rust
code
Return only Rust code. Implement exactly this function: pub fn retry_schedule(base_ms: u64, factor: u64, attempts: usize, max_ms: u64) -> Vec<u64> Rules: - Return exactly attempts entries. - First delay is base_ms. - Each next delay is previous * factor using saturating arithmetic. - Clamp every returned delay to max_...
{{code}} #[cfg(test)] mod tests { use super::retry_schedule; #[test] fn builds_schedule() { assert_eq!(retry_schedule(100, 2, 5, 1_000), vec![100, 200, 400, 800, 1_000]); } #[test] fn handles_edge_cases() { assert_eq!(retry_schedule(5, 3, 0, 99), Vec::<u64>::new()); as...
[ "pub fn retry_schedule" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384
strip_line_comments
rust
code
Return only Rust code. Implement exactly this function: pub fn strip_line_comments(input: &str) -> String Rules: - Remove // comments until end of line. - Ignore // inside double-quoted strings. - Respect backslash escapes inside strings. - Preserve line breaks.
{{code}} #[cfg(test)] mod tests { use super::strip_line_comments; #[test] fn strips_comments() { let src = "let a = 1; // comment\nlet b = 2;//x\n"; assert_eq!(strip_line_comments(src), "let a = 1; \nlet b = 2;\n"); } #[test] fn keeps_comment_markers_inside_strings() { ...
[ "pub fn strip_line_comments" ]
[ "todo!(", "unimplemented!(", "panic!(" ]
[ "rust", "code-first", "unit-test" ]
384

No dataset card yet

Downloads last month
2