Created
February 4, 2023 22:28
-
-
Save pedroarthur/a5417b9543fe923435bc4c399ebf3d5e to your computer and use it in GitHub Desktop.
stupid, untested, probably with presentation errors solution to https://www.hackerrank.com/contests/pycode2015/challenges/dictionary-assignment
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
| #!/bin/bash | |
| split () { grep -o .; } | |
| remove_spaces () { grep -vP '[[:space:]]+'; } | |
| count () { sort | uniq -c; } | |
| read -r _ # just ignore and halt on EoF | |
| while read -r sentence | |
| do | |
| echo "$sentence" | split | remove_spaces | count | while read -r count char | |
| do | |
| echo "Letter $char appears $count time/s" | |
| done | |
| echo | |
| done |
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
| #!/bin/bash | |
| bash tst.sh <<EoF | |
| 100 | |
| asdsa | |
| qwewq | |
| o rato roeu a roupa do rei de roma | |
| EoF |
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
| #!/bin/bash | |
| grep -o . | grep -vP '[[:space:]]+' | sort | uniq -c | while read -r count char | |
| do | |
| echo "Letter $char appears $count time/s" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment