Sleep IoT Quest - Day 6 Progress Update
Day Summary
- Active reading (10m, +4 pages): hit the string-slice “clutter” example; contrasted Pythonic build-a-string vs. Rust slice approach.
- Exploratory coding (play): tried the
bytes().iter().enumerate()
pattern to see why returning a&str
slice is effectively O(1) space. - Sidequest: moved another box to the new apartment.
- Training: aerobic exercise(sprint on treadmill 20m with iterative speedincrease every minute for the first 10m, then every 30s for the next 8m, then push to 15km/h for 1m, then cooldown) boosted energy and focus - by a lot (oxygen ftw).
Context
- Started the day clear-headed, but drifted into philosophizing instead of taking the easy win (clearing 90m workpackage when energy is high early).
- Ate earlier to protect sleep; then slipped into recovery mode, and focus dipped.
Reading
Covered +4 pages. Found an Example that was supposed to illustrate the use of slices (return first word via slices) and wanted to try it myself first
Coding Practice
Played with the slice approach to understand it (a bit of exploration):
- My first pass (Python-style): iterate
char
bychar
, push into a helperString
, return on space → O(n) space. - Book’s pass: scan bytes, find the first space, return a
&str
slice → O(1) space. - Win: avoid allocation by borrowing a view into the original string.
- Key point vs. Pythonic build: no helper buffer; just a borrowed slice.
Reflection
- I had an easy win lined up for grabs but postponed it, losing time, momentum and ultimately the execution win for the day.
- Even so, I kept the streak alive with real progress.
- Protect the execution window: act first, analyze later.
- Aerobic sessions noticeably increase energy and focus.
Key Learning
-
Slices over copies: Prefer returning
&str
when possible to keep O(1) space. -
String
vs.str
(really&str
in code):String
= owned, growable, heap-allocated UTF-8 buffer.&str
= borrowed slice into UTF-8 data; no ownership, not growable.
-
Meta: Philosophizing feels productive but often delays the first action; starting is the leverage point.Do High impact activities first.
Total Time Spent
- Reading: 10m
- Coding (exploratory): 30m
PCT (Project Cumulative Time): 8h39m