Skip to content

Instantly share code, notes, and snippets.

@robhanlon22
Last active December 7, 2022 01:40
Show Gist options
  • Save robhanlon22/5016fa9a8be60805705d4a8a7835a250 to your computer and use it in GitHub Desktop.
Save robhanlon22/5016fa9a8be60805705d4a8a7835a250 to your computer and use it in GitHub Desktop.
day6.sh
#!/usr/bin/env bash
s="$(< /dev/stdin)"
n="$1"
for (( i = 0; i < ${#s} - n; i++ )); do
unset m
declare -A m
for (( j = 0; j < n; j++ )); do
m[${s:$((i + j)):1}]=$j
done
if ((${#m[@]} == n )); then
echo $((i + n))
exit
fi
done
echo "it's not possible :(" >&2
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment