Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
stringlengths
6
6
category
stringclasses
5 values
prompt
stringlengths
96
330
api_description
stringclasses
1 value
expected_output
stringlengths
18
64
cs-000
integers
Interpret the 32-bit pattern 0xfffffffe as (a) a two's-complement signed int and (b) an unsigned int. Return one row [signed, unsigned].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-2, 4294967294]]}
cs-001
integers
Give the 32-bit two's-complement bit pattern of -1000 as a lowercase hex string, 8 digits, '0x' prefixed. Return one row [pattern].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["0xfffffc18"]]}
cs-002
integers
The 8-bit signed value -76 is sign-extended to 32 bits, and separately the same 8 bits are zero-extended to 32 bits. Return one row [sign_extended value as a signed int, zero_extended value as an int].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-76, 180]]}
cs-003
integers
For 32-bit ints, compute INT_MIN, INT_MAX, and the value of -INT_MIN when it wraps in 32-bit two's complement. Return one row [INT_MIN, INT_MAX, negated_INT_MIN].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-2147483648, 2147483647, -2147483648]]}
cs-004
integers
In 32-bit signed arithmetic, does 2000000000 + 2000000000 overflow, and what value results after wrapping? Return one row [overflowed as a bool, wrapped result as a signed int].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[true, -294967296]]}
cs-005
integers
Take the 32-bit pattern of -20. Shift it right by 3 as C would for a SIGNED int (arithmetic) and as C would for an UNSIGNED int (logical). Return one row [arithmetic result as a signed int, logical result as an unsigned int].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-3, 536870909]]}
cs-006
integers
In 8-bit two's complement, compute (char)200 — that is, the low 8 bits of 200 read as signed — and then multiply that by 3, again in 8-bit wrapping arithmetic. Return one row [cast_value, product].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-56, 88]]}
cs-007
integers
For a 32-bit UNSIGNED int, compute 5 - 9 with wraparound, and state whether the C comparison (5u - 9u) > 0 is true. Return one row [wrapped difference, comparison as a bool].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[4294967292, true]]}
cs-008
integers
Left-shift 0x40000000 by 1 and by 2 in a 32-bit SIGNED int, wrapping each time. Return one row [after one shift as a signed int, after two shifts as a signed int].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-2147483648, 0]]}
cs-009
integers
Divide -17 by 4 the way C does for signed ints (truncation toward zero) and the way Python's // does (floor). Return one row [c_result, python_result, c_remainder from -17 % 4 with C semantics].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-4, -5, -1]]}
cs-010
integers
In 16-bit two's complement, add 30000 and 10000 with wrapping, then read the result as unsigned. Return one row [signed result, unsigned result].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-25536, 40000]]}
cs-011
integers
For a 32-bit signed int x = -1, evaluate the C expressions (x >> 31) and ((unsigned)x >> 31). Return one row [arithmetic_shift result as a signed int, logical_shift result as an int].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-1, 1]]}
cs-012
floats
Give the IEEE-754 single-precision (float32) bit pattern of 1.0 and of -2.5 as lowercase hex strings with a '0x' prefix and 8 digits. Return one row [pattern_of_1.0, pattern_of_-2.5].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["0x3f800000", "0xc0200000"]]}
cs-013
floats
Decode the float32 bit pattern 0x41200000 to its exact value. Return one row [value as a float].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[10.0]]}
cs-014
floats
For a float32, give the sign bit, the raw 8-bit exponent field and the 23-bit mantissa field of -6.25, each as an integer. Return one row [sign, exponent_field, mantissa_field].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[1, 129, 4718592]]}
cs-015
floats
Round 2**24 + 1 to the nearest float32 and report the result, and whether it equals 2**24. Return one row [rounded value as a float, equals_2_24 as a bool].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[16777216.0, true]]}
cs-016
floats
Float32 addition is not associative. With a = 1e8, b = -1e8 and c = 1.0, compute (a + b) + c and a + (b + c), rounding through float32 after EVERY operation. Return one row [left_assoc, right_assoc, they_differ as a bool].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[1.0, 0.0, true]]}
cs-017
floats
In double precision, is 0.1 + 0.2 exactly 0.3? Also give the exact double value of 0.1 + 0.2 rendered by repr, and the bit pattern of 0.1 as a 16-digit lowercase hex string with a '0x' prefix. Return one row [equal as a bool, sum_repr as a string, bits_of_0.1].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[false, "0.30000000000000004", "0x3fb999999999999a"]]}
cs-018
floats
Give the smallest positive NORMAL float32 and the smallest positive DENORMAL (subnormal) float32, each decoded from its bit pattern. Return one row [smallest_normal, smallest_denormal].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[1.1754943508222875e-38, 1.401298464324817e-45]]}
cs-019
floats
Decode the float32 bit patterns 0x7f800000, 0xff800000 and 0x7fc00000, and report each as a string via repr. Return one row [repr of the first, repr of the second, repr of the third].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["inf", "-inf", "nan"]]}
cs-020
floats
The integer 16777217 is converted to float32 and back to an integer. Report the round-tripped integer and whether it differs from the original. Return one row [round_tripped, differs as a bool].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[16777216, true]]}
cs-021
floats
Compute, in float32, the value of 0.1 + 0.2 and its bit pattern as an 8-digit lowercase hex string with a '0x' prefix, rounding through float32 after the addition. Return one row [value, pattern].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[0.30000001192092896, "0x3e99999a"]]}
cs-022
bits
For the 32-bit value 0x0000ff00, isolate the lowest set bit and clear the lowest set bit, using the classic x & -x and x & (x - 1) identities under 32-bit wrapping. Return one row [lowest_set_bit, cleared as ints].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[256, 65024]]}
cs-023
bits
Count the set bits in the 32-bit patterns of 0x0f0f0f0f and of -1. Return one row [popcount_first, popcount_second].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[16, 32]]}
cs-024
bits
Reverse the byte order of the 32-bit value 0x12345678 (a 32-bit byte swap). Return one row [swapped as an 8-digit lowercase hex string with a '0x' prefix].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["0x78563412"]]}
cs-025
bits
For the 32-bit value 0x000000a5, compute a rotate-left by 4 and a rotate-right by 4 (rotations, not shifts). Return one row [rotl4, rotr4 as 8-digit lowercase hex strings with a '0x' prefix].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["0x00000a50", "0x5000000a"]]}
cs-026
bits
Extract bits 8 through 15 inclusive (a byte field) from the 32-bit value 0xdeadbeef, as an integer, and give the value with that field cleared to zero. Return one row [field, cleared as an 8-digit lowercase hex string with a '0x' prefix].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[190, "0xdead00ef"]]}
cs-027
bits
Compute the 32-bit XOR of 0xaaaaaaaa and 0x55555555, and the 32-bit value of ~0x0000ffff. Return one row [xor, complement as 8-digit lowercase hex strings with a '0x' prefix].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["0xffffffff", "0xffff0000"]]}
cs-028
memory
The 32-bit integer 0x01020304 is stored at an address. List its four bytes in memory order on a LITTLE-endian machine and on a BIG-endian machine. Return two rows: the little-endian bytes as four ints, then the big-endian bytes as four ints.
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[4, 3, 2, 1], [1, 2, 3, 4]]}
cs-029
memory
A C struct is { char a; int b; char c; } with 4-byte alignment for int and 1-byte for char. Give the byte offset of each member and the total size including trailing padding. Return one row [offset_a, offset_b, offset_c, sizeof].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[0, 4, 8, 12]]}
cs-030
memory
The same three members reordered as { int b; char a; char c; }. Give each offset and the total size including trailing padding, with the same alignment rules. Return one row [offset_b, offset_a, offset_c, sizeof].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[0, 4, 5, 8]]}
cs-031
memory
Interpret the four bytes 0xff 0xff 0xff 0xff as a little-endian 32-bit signed int and as an unsigned int. Return one row [signed, unsigned].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[-1, 4294967295]]}
cs-032
memory
Given an array `int a[10]` starting at address 0x1000 with 4-byte ints, give the addresses of a[0], a[3] and a[9] as 4-digit lowercase hex strings with a '0x' prefix. Return one row [addr0, addr3, addr9].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [["0x1000", "0x100c", "0x1024"]]}
cs-033
memory
The bytes 0x40 0x49 0x0f 0xdb are stored in BIG-endian order and read as a float32. Give the value, and give the value if the same four bytes are read LITTLE-endian instead. Return one row [big_endian_value, little_endian_value].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[3.1415927410125732, -4.03314608963584e+16]]}
cs-034
cache
A direct-mapped cache has 64 sets and 16-byte blocks, with 32-bit addresses. Decompose the address 0x00001834 into its block offset, set index and tag (as integers). Return one row [offset, set_index, tag].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[4, 3, 6]]}
cs-035
cache
Same cache: 64 sets, 16-byte blocks, direct-mapped, 32-bit addresses. Give the number of offset bits, index bits and tag bits. Return one row [offset_bits, index_bits, tag_bits].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[4, 6, 22]]}
cs-036
cache
A 2-way set-associative cache holds 8 KiB of data with 32-byte blocks. Give the number of blocks, the number of sets, and the number of index bits. Return one row [blocks, sets, index_bits].
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[256, 128, 7]]}
cs-037
cache
A direct-mapped cache has 4 sets and 16-byte blocks, initially empty. The addresses 0, 16, 0, 64, 0 are accessed in that order. For each access report 1 for a hit and 0 for a miss. Return one row of five values, in order.
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[0, 0, 1, 0, 0]]}
cs-038
cache
A fully-associative cache holds 4 blocks of 8 bytes and evicts least-recently used. The addresses 0, 8, 16, 24, 0, 32, 8 are accessed in that order. Report 1 for a hit and 0 for a miss for each. Return one row of seven values, in order.
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[0, 0, 0, 0, 1, 0, 0]]}
cs-039
cache
An `int a[4][8]` of 4-byte ints starts at address 0. The cache is DIRECT-MAPPED with 2 sets and 16-byte blocks — far smaller than the array. Count the total misses when every element is read in ROW-major order (i outer, j inner) and in COLUMN-major order (j outer, i inner). Return one row [row_major_misses, column_majo...
You are answering machine-level computer-systems questions by COMPUTING the answer in Python, not by recalling it. Available imports: struct, math (nothing else is needed). Python's integers are unbounded and its `>>` is always an arithmetic shift, so C's fixed-width behaviour must be emulated deliberately. Two helpe...
{"rows": [[8, 32]]}

csapp-tasks-v1

40 machine-level computer-systems tasks for the csapp-env RL environment — two's complement, integer overflow, IEEE-754, bit manipulation, struct layout and caches, on the topics of Computer Systems: A Programmer's Perspective (Bryant & O'Hallaron).

field meaning
task_id cs-000cs-039
category integers / floats / bits / memory / cache
prompt the question and the exact shape of the answer
api_description the shared preamble (available imports, how to emulate C's fixed widths)
expected_output JSON {"rows": [...]}, computed by executing a reference solution

Categories: integers 12, floats 10, bits 6, memory 6, cache 6. No dependencies — every task is answered with struct and math.

Original problems, not the book's exercises

Nothing here is copied from CS:APP. Every task is written fresh on the topics the book teaches.

That is a copyright decision and the stronger evaluation choice: the book's exercises and their worked solutions are all over the public web, so a model can recall them instead of computing. Original problems with executed answer keys cannot be recalled.

The answer keys are executed, never typed

Every expected output is produced by running a reference implementation, so a key cannot drift from the instruction beside it. That rule caught four defects in this dataset's own first draft:

  • a task that said "show that float32 addition is not associative" where both groupings came out 0.0 — the values chosen did not demonstrate it;
  • a row-major vs column-major cache comparison where both orders tied at 8, because the cache was large enough to hold the array;
  • a hit/miss trace that was five misses and no hits, so answering 0 five times scored full marks;
  • struct offsets that were four typed constants instead of a computed layout.

All four are now asserted in the builder, so the dataset fails to build if any of them recurs.

Grading

Exact — no tolerance anywhere. Every answer is an integer, a bit pattern, a boolean or a float read back from its own bit pattern, so there is nothing for a tolerance to absorb, and on a question about exact bit patterns a tolerance would only let wrong answers through. 1 does not pass for True, and "0x2a" does not pass for 42.

Verify with python environments/csapp_env/build_tasks.py --verify (40/40). Source: https://github.com/eltociear/my-molt-agent/tree/main/environments/csapp_env

Downloads last month
37