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
| 1. Use ANSI-escaped string (last answer in https://stackoverflow.com/questions/25608503/using-single-quotes-with-echo-in-bash) | |
| ``` | |
| echo $'\'' | |
| ``` | |
| 2. via awk: use octal escape sequences (' = 39, https://unix.stackexchange.com/questions/593212/awk-print-apostrophe-single-quote) | |
| ``` | |
| awk '{print "\047" $0 "\047"}' input |
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
| def rotate(L, n_rotations): | |
| """ | |
| rotates list L in place by n_rotations | |
| [a,b,c,d] -> [b,c,d,a] (n_rotations = 1) | |
| [a,b,c,d] -> [c,d,a,b] (n_rotations = 2) | |
| assumption: | |
| n_rotations can be at most |L| - 1, i.e. |L| rotations | |
| will result in L itself, |L| + 1 in L rotated once, etc. |