Created
August 19, 2025 19:14
-
-
Save smartwatermelon/ace82cf8ec7800b186ff63ddaa3066d0 to your computer and use it in GitHub Desktop.
@cassidoo's interview question from August 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
smartwatermelon
commented
Aug 19, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment