File size: 5,848 Bytes
18e0abf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245ed4a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
---
dataset_info:
  features:
  - name: id
    dtype: string
  - name: chapter
    dtype: string
  - name: section
    dtype: string
  - name: title
    dtype: string
  - name: source_file
    dtype: string
  - name: question_markdown
    dtype: string
  - name: answer_markdown
    dtype: string
  - name: code_blocks
    list:
    - name: lang
      dtype: string
    - name: code
      dtype: string
  - name: has_images
    dtype: bool
  - name: image_refs
    list: string
  splits:
  - name: train
    num_bytes: 1282175
    num_examples: 1016
  download_size: 609478
  dataset_size: 1282175
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
---

# CLRS Solutions QA 

**Short description.**  
A compact Q&A dataset distilled from the community-maintained **CLRS solutions** project. Each row contains:
- the exercise **question** (markdown),
- the **answer** (markdown),
- book **chapter/section** metadata,
- optional **code blocks** (language-tagged),
- optional **image references** (relative paths from the source repo).

This set is useful for building retrieval, RAG, tutoring, and evaluation pipelines for classic algorithms & data structures topics.

> ⚠️ **Attribution:** This dataset is **derived** from the open-source repository **[walkccc/CLRS](https://github.com/walkccc/CLRS)** (MIT license). Credit belongs to **@walkccc** and all contributors. This packaging only restructures their content into a machine-friendly format.

---

## Contents & Stats

- **Split(s):** `train`
- **Rows:** ~1,016
- **Source:** Parsed from markdown files in `walkccc/CLRS` (third-edition exercises/solutions)

> Note: A small number of rows reference images present in the original repo (`docs/img/...`). This dataset includes the image *references* (paths) as metadata; actual image files are not bundled here.

---

**Also available (human-readable copies):**

```python
# JSONL
ds_json = load_dataset(
    "json",
    data_files="hf://datasets/Siddharth899/clrs-qa/data/train.jsonl.gz",
    token=True,  # needed if the repo is private
)

# CSV
ds_csv = load_dataset(
    "csv",
    data_files="hf://datasets/Siddharth899/clrs-qa/data/train.csv.gz",
    token=True,
)
```
## Data Fields

| Field               | Type                             | Description                                                           |
| ------------------- | -------------------------------- | --------------------------------------------------------------------- |
| `id`                | `string`                         | Stable row id composed from chapter/section/title (e.g., `02-2.3-5`). |
| `chapter`           | `string`                         | Chapter number as a zero-padded string (e.g., `"02"`).                |
| `section`           | `string`                         | Section identifier as in the source (e.g., `"2.3"` or `"2-1"`).       |
| `title`             | `string`                         | Exercise/problem label (e.g., `"2.3-5"` or `"2-1"`).                  |
| `source_file`       | `string`                         | Original markdown relative path in the source repo.                   |
| `question_markdown` | `string`                         | Exercise prompt in markdown.                                          |
| `answer_markdown`   | `string`                         | Solution/answer in markdown (often includes LaTeX).                   |
| `code_blocks`       | `list` of objects `{lang, code}` | Zero or more language-tagged code snippets extracted from the answer. |
| `has_images`        | `bool`                           | Whether this item references images.                                  |
| `image_refs`        | `list[string]`                   | Relative paths to referenced images in the original repo.             |

Example `code_blocks` entry:

```json
[
  {"lang": "cpp", "code": "INSERTION-SORT(A)\n  ..."},
  {"lang": "python", "code": "def merge(...):\n  ..."}
]
```

---

## Data Construction

* **Source:** [`walkccc/CLRS`](https://github.com/walkccc/CLRS)
* **License upstream:** MIT
* **Method:** A small script parses chapter/section markdown files, extracts headings, prompts, answers, fenced code blocks, and image references, and emits JSONL → uploaded to the Hub (Parquet auto-materialized).
* **Known quirks:**

  * Some answers are brief/telegraphic (mirroring the original).
  * Image references point to paths in the upstream repo; not all images are bundled here.
  * Math is plain markdown with LaTeX snippets (`$...$`, `$$...$$`); rendering depends on your viewer.

---

## License

* **This dataset (packaging)**: MIT
* **Upstream content**: MIT (from `walkccc/CLRS`)

You must preserve the original MIT license notice and attribute **@walkccc** and contributors when using this dataset.

```
MIT License

Copyright (c) walkccc
... (see upstream repository for the full license text)
```

Additionally, include attribution similar to:

> “Portions of the content are derived from walkccc/CLRS (MIT). © The respective contributors.”

---

## Citation

If you use this dataset, please cite both the dataset and the upstream project:

**Dataset (this repo):**

```
@misc{clrs_qa_dataset_2025,
  title  = {CLRS Solutions QA (walkccc-derived)},
  author = {Siddharth899},
  year   = {2025},
  howpublished = {\url{https://huggingface.co/datasets/Siddharth899/clrs-qa}},
  note   = {Derived from walkccc/CLRS (MIT)}
}
```

**Upstream CLRS solutions:**

```
@misc{walkccc_clrs,
  title         = {Solutions to Introduction to Algorithms (Third Edition)},
  author        = {walkccc and contributors},
  howpublished  = {\url{https://github.com/walkccc/CLRS}},
  license       = {MIT}
}
```

## Contact & Maintenance

* **Maintainer of this dataset packaging:** @Siddharth899
* Issues / requests: open an issue on the HF dataset repo.