bananacode/banana.sh

32 lines
455 B
Bash
Raw Normal View History

2023-09-22 02:57:30 +02:00
#!/bin/sh
2021-03-07 23:55:48 +01:00
2023-09-22 02:36:11 +02:00
set -eu
2023-09-22 02:57:30 +02:00
num="$1"
minlength=2
vowels='aeiou'
consonantics='bcdfglmnprstvz'
v="$num"
2021-03-07 23:55:48 +01:00
length=0
2023-09-22 02:57:30 +02:00
st=
2021-03-07 23:55:48 +01:00
2023-09-22 02:57:30 +02:00
idx=1
while [ "$v" -ne 0 ] || [ $idx -ne 1 ] || [ $length -lt $minlength ]
2021-03-07 23:55:48 +01:00
do
2023-09-22 02:57:30 +02:00
if [ "${idx}" -eq 1 ]; then
al="$vowels"
idx=0
else
al="$consonantics"
idx=1
fi
len="${#al}"
r=$((v % len + 1))
v=$((v / len))
st="$(echo "$al" | cut -c "$r")$st"
2021-03-07 23:55:48 +01:00
2023-09-22 02:57:30 +02:00
length=$((length + 1))
2021-03-07 23:55:48 +01:00
done
2023-09-22 02:36:03 +02:00
echo "$st"