easy +8 pts

Parse Hex Dump

Convert a space-separated hex dump string into a list of byte values.

You are given a string that represents raw binary data as a hex dump: each byte is written as exactly two hexadecimal digits (0-9, A-F, a-f) and consecutive byte tokens are separated by one or more spaces. Write a function `parse_hex_dump(hex_dump: str) -> list` that returns a list of integers (0-255) representing the bytes in the order they appear. If the string is empty or contains only whitespace, return an empty list. You may assume the input is well-formed; every non-whitespace character is part of a valid two-digit hex token, and there are no newline characters.

Constraints

- `hex_dump` is a string that may be empty or contain only spaces. - Each byte is exactly two hex digits (case-insensitive) separated by one or more spaces. - The length of `hex_dump` is at most 10^5 characters. - Time complexity: O(n), where n is the length of the string.

Example

>>> parse_hex_dump("48 65 6c 6c 6f")
[72, 101, 108, 108, 111]
>>> parse_hex_dump("0a 0D")
[10, 13]
>>> parse_hex_dump("   ")
[]
8 points ~12 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use `split()` on the string to get all byte tokens, which already handles multiple spaces.
Each token is a hex string; convert it with `int(token, 16)`.
Build the final result as a list of these integers.
If `split()` returns an empty list, return `[]` directly.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.