seed: curriculum content
This commit is contained in:
39
1.solar-system/1.welcome/05.the-mover/index.md
Normal file
39
1.solar-system/1.welcome/05.the-mover/index.md
Normal file
@@ -0,0 +1,39 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Mover"
|
||||
xp: 50
|
||||
duration: 25
|
||||
difficulty: 2
|
||||
---
|
||||
|
||||
# The Mover
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, your cargo bay is built. Now stock it.
|
||||
>
|
||||
> When your script runs, an `inbox/` of fresh supplies has arrived.
|
||||
> Each item is labeled by category — `food-`, `water-`, or `tool-`.
|
||||
> Sort them into the right rooms. Then make a backup of the food
|
||||
> manifest.
|
||||
>
|
||||
> Two commands:
|
||||
>
|
||||
> - `mv` — move (or rename)
|
||||
> - `cp` — copy
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.sh`, write the commands to:
|
||||
|
||||
1. Move each `food-*` file into `cargo/food/`
|
||||
2. Move each `water-*` file into `cargo/water/`
|
||||
3. Move each `tool-*` file into `cargo/tools/`
|
||||
4. Copy `cargo/food/manifest.txt` to `cargo/food/manifest.backup`
|
||||
|
||||
## Objectives
|
||||
|
||||
- All `food-*`, `water-*`, `tool-*` files moved to the correct rooms
|
||||
- `cargo/food/manifest.backup` exists
|
||||
20
1.solar-system/1.welcome/05.the-mover/starter/starter.sh
Normal file
20
1.solar-system/1.welcome/05.the-mover/starter/starter.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# The Mover — sort the supplies.
|
||||
#
|
||||
# When this script runs:
|
||||
# - cargo/food/, cargo/water/, cargo/tools/ already exist
|
||||
# - cargo/food/manifest.txt exists (empty)
|
||||
# - inbox/ contains files with prefixes:
|
||||
# food-apple.txt, food-bread.txt
|
||||
# water-bottle.txt, water-canteen.txt
|
||||
# tool-wrench.txt, tool-hammer.txt
|
||||
#
|
||||
# Your script must:
|
||||
# 1. Move all food-*.txt files into cargo/food/
|
||||
# 2. Move all water-*.txt files into cargo/water/
|
||||
# 3. Move all tool-*.txt files into cargo/tools/
|
||||
# 4. Copy cargo/food/manifest.txt to cargo/food/manifest.backup
|
||||
#
|
||||
# Tools: mv, cp
|
||||
|
||||
# Your code here.
|
||||
25
1.solar-system/1.welcome/05.the-mover/testing/test.sh
Normal file
25
1.solar-system/1.welcome/05.the-mover/testing/test.sh
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
mkdir -p cargo/food cargo/water cargo/tools inbox
|
||||
touch cargo/food/manifest.txt cargo/water/manifest.txt cargo/tools/manifest.txt
|
||||
echo "1 apple" > inbox/food-apple.txt
|
||||
echo "1 loaf" > inbox/food-bread.txt
|
||||
echo "500ml" > inbox/water-bottle.txt
|
||||
echo "1L" > inbox/water-canteen.txt
|
||||
echo "10mm" > inbox/tool-wrench.txt
|
||||
echo "claw" > inbox/tool-hammer.txt
|
||||
|
||||
bash solution.sh > /dev/null 2>&1
|
||||
|
||||
N=0
|
||||
check() {
|
||||
N=$((N+1))
|
||||
if eval "$1"; then echo "ok $N - $2"; else echo "not ok $N - $2"; fi
|
||||
}
|
||||
|
||||
check '[ -f cargo/food/food-apple.txt ]' "food-apple in cargo/food"
|
||||
check '[ -f cargo/food/food-bread.txt ]' "food-bread in cargo/food"
|
||||
check '[ -f cargo/water/water-bottle.txt ]' "water-bottle in cargo/water"
|
||||
check '[ -f cargo/water/water-canteen.txt ]' "water-canteen in cargo/water"
|
||||
check '[ -f cargo/tools/tool-wrench.txt ]' "tool-wrench in cargo/tools"
|
||||
check '[ -f cargo/tools/tool-hammer.txt ]' "tool-hammer in cargo/tools"
|
||||
check '[ -f cargo/food/manifest.backup ]' "cargo/food/manifest.backup exists"
|
||||
Reference in New Issue
Block a user