seed: curriculum content
This commit is contained in:
45
1.solar-system/3.strings/02.the-slicer/index.md
Normal file
45
1.solar-system/3.strings/02.the-slicer/index.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Slicer"
|
||||
xp: 50
|
||||
duration: 25
|
||||
difficulty: 2
|
||||
---
|
||||
|
||||
# The Slicer
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, *slicing* grabs a chunk of a string instead of one character.
|
||||
> The syntax is `s[start:end]` — `start` is included, `end` is not.
|
||||
>
|
||||
> ```python
|
||||
> s = "ANDROMEDA"
|
||||
> s[0:3] # "AND"
|
||||
> s[3:7] # "ROME"
|
||||
> s[-2:] # "DA"
|
||||
> ```
|
||||
>
|
||||
> Telemetry packets always arrive in this exact format (length 30):
|
||||
>
|
||||
> ```
|
||||
> TIMESTAMP=YYYY-MM-DDTHH:MM:SSZ
|
||||
> ```
|
||||
>
|
||||
> Implement `extract(header)` that returns a tuple `(date, time)`:
|
||||
>
|
||||
> - `date` = `YYYY-MM-DD` (10 chars)
|
||||
> - `time` = `HH:MM:SS` (8 chars)
|
||||
>
|
||||
> Figure out which slice positions hold each piece.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.py`, return `(date, time)` extracted with slicing.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `extract("TIMESTAMP=2026-05-04T14:32:01Z")` → `("2026-05-04", "14:32:01")`
|
||||
- Works for any header in the same fixed format
|
||||
Reference in New Issue
Block a user