Last active
December 7, 2022 01:40
-
-
Save robhanlon22/5016fa9a8be60805705d4a8a7835a250 to your computer and use it in GitHub Desktop.
day6.sh
This file contains 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 | |
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