Skip to content

Instantly share code, notes, and snippets.

@Chirimen-Jako
Last active August 19, 2019 16:27
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 Chirimen-Jako/d9d137e231fee2cad5c7e635c180680d to your computer and use it in GitHub Desktop.
Save Chirimen-Jako/d9d137e231fee2cad5c7e635c180680d to your computer and use it in GitHub Desktop.
おっぱいそんちくびんびん♪ (Bash)
#!/bin/bash
#
# おっぱい.sh
#
# 2019/08/20: initial release
#
# Ubuntu 18.04.2 LTS (Bionic Beaver)
#
# GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
# Copyright (C) 2016 Free Software Foundation, Inc.
# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
#
# Dedicated to shirasu
# https://gist.github.com/8q/a5331c6ef8a205b32125
#
MAX_RAND=$((32767-(32767 % 6)))
oppaiRand () {
local rand=$RANDOM
while [ "${rand}" -ge "${MAX_RAND}" ]
do
rand=$RANDOM
done
echo "$((${rand} % 6))"
}
contains () {
local e match="$1"
shift
for e; do [[ "${e}" == "${match}" ]] && return 0; done
return 1
}
readonly RealStr='おっぱいそんちくびんびん'
readonly OppaiElements=('おっ', 'ぱい', 'そん', 'ちく', 'びん', 'びん')
testStr=''
count=0
while [ "${testStr}" != "${RealStr}" ]
do
let ++count
numList=()
while [ ${#numList[@]} -lt 6 ]
do
num=`oppaiRand`
contains "${num}" "${numList[@]}"
if [ $? -ne 0 ]; then
numList=("${num}" "${numList[@]}")
fi
done
testStr=''
for n in "${numList[@]}";
do
testStr="${testStr}${OppaiElements[${n}]}"
done
testStr="${testStr//,/}"
echo "${count} ${testStr}"
done
printf "おめでとうございます!\x20"
echo "あなたは${count}回目に${RealStr}しました。"
echo "end"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment