bananacode/banana.sh

26 lines
489 B
Bash
Raw Normal View History

2021-03-07 23:55:48 +01:00
#!/bin/bash
num=$1
minlength=1
alphabets=(bcdfglmnprstvz aeiou)
numalpha=${#alphabets[@]}
v=$num
st=
length=0
2023-09-22 02:36:03 +02:00
idx=$(((numalpha - 1) % numalpha))
while ! { [ "$v" -eq 0 ] && [ $idx -eq $(((numalpha - 1) % numalpha)) ] && [ $length -ge $minlength ] ; }
2021-03-07 23:55:48 +01:00
do
al=${alphabets[idx]}
2023-09-22 02:36:03 +02:00
r=$((v % ${#al}))
v=$((v / ${#al}))
2021-03-07 23:55:48 +01:00
st="${al:$r:1}$st"
2023-09-22 02:36:03 +02:00
idx=$(((idx + numalpha - 1) % numalpha))
length=$((length + 1))
2021-03-07 23:55:48 +01:00
done
2023-09-22 02:36:03 +02:00
echo "$st"