Skip to content

Instantly share code, notes, and snippets.

@smartwatermelon
Created August 19, 2025 19:14
Show Gist options
  • Save smartwatermelon/ace82cf8ec7800b186ff63ddaa3066d0 to your computer and use it in GitHub Desktop.
Save smartwatermelon/ace82cf8ec7800b186ff63ddaa3066d0 to your computer and use it in GitHub Desktop.
@cassidoo's interview question from August 17, 2025
#!/usr/bin/env bash
set -uo pipefail
cycles=("done" "dry" "spin" "rinse" "wash" "soak")
createLaundryItem() { echo "5"; }
nextCycle() {
echo "${cycles[$1]}"
(($1 > 0)) && return $(($1 - 1)) || return 0
}
# Test it
towel=$(createLaundryItem)
for i in {1..7}; do
nextCycle "${towel}"
towel=$?
done
@smartwatermelon
Copy link
Author

⏚ [andrewrich:~/Developer/cassidoo] 20250817 ± ./doLaundry.sh
soak
wash
rinse
spin
dry
done
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment