Skip to content

Instantly share code, notes, and snippets.

@Eriner
Created January 23, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eriner/14c1a3e7ae2ab4080d4a to your computer and use it in GitHub Desktop.
Save Eriner/14c1a3e7ae2ab4080d4a to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
numbers=($(<${1}))
results=()
# getting 0-10, ..., 90-99
for i in {0..9}; do
lower=$(( ${i} * 10 ))
upper=$(( ${lower} + 9 ))
count=0
for n in ${numbers}; do
if [[ ${n} -ge ${lower} ]] && [[ ${n} -le ${upper} ]]; then
count=$(( count + 1 ))
fi
done
# add to final array
results+=(${count})
done
# print in the required format
printf "%s" ${results}
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment