Created
July 9, 2021 18:14
-
-
Save smartwatermelon/fee89fbfd63a6b6b01eeb8efd5f55d6b to your computer and use it in GitHub Desktop.
@cassidoo's interview question from July 4, 2021
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 -eu -o pipefail | |
| # Imagine your users are all typing slightly incorrectly, in that they shifted their | |
| # hands one key to the right. Write a function that translates what they mean to say. | |
| if [ $# -ne 1 ]; then | |
| echo "$(basename $0): enter a mis-typed string, e.g. ';p; epe'" | |
| exit 1 | |
| fi | |
| STR=$1 | |
| QWERTY='qwertyuiop[]\' | |
| WERTYU='wertyuiop[]\' | |
| ASDFGH='asdfghjkl;' | |
| SDFGHJ='sdfghjkl;' | |
| ZXCVBN='zxcvbnm,./' | |
| XCVBNM='xcvbnm,./' | |
| echo $STR | tr $WERTYU $QWERTY | tr $SDFGHJ $ASDFGH | tr $XCVBNM $ZXCVBN |
Author
smartwatermelon
commented
Jul 9, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment