Created
August 21, 2019 05:24
-
-
Save Chirimen-Jako/7d4cea9d01b78d231bda23e7fc298114 to your computer and use it in GitHub Desktop.
おっぱいそんちくびんびん♪ (AWK)
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/awk -f | |
# | |
# おっぱい.awk | |
# | |
# 2019/08/21: initial release | |
# | |
# Microsoft Windows 10 Version 1903 (OS build 18362.295) | |
# | |
# GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) | |
# | |
# cmd.exe | |
# | |
# Windows PowerShell | |
# | |
# PS C:\> $PSVersionTable | |
# | |
# Name Value | |
# ---- ----- | |
# PSVersion 5.1.18362.145 | |
# PSEdition Desktop | |
# PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} | |
# BuildVersion 10.0.18362.145 | |
# CLRVersion 4.0.30319.42000 | |
# WSManStackVersion 3.0 | |
# PSRemotingProtocolVersion 2.3 | |
# SerializationVersion 1.1.0.1 | |
# | |
# git bash (git for Windows) | |
# | |
# GNU bash, version 4.4.23(1)-release (x86_64-pc-msys) | |
# | |
# Ubuntu 18.04.2 LTS (Bionic Beaver) | |
# | |
# GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2) | |
# | |
# bash | |
# | |
# GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu) | |
# | |
# Dedicated to shirasu | |
# https://gist.github.com/8q/a5331c6ef8a205b32125 | |
# | |
function randomize() { | |
cmd = "seq 32767 | shuf -n 1" | |
cmd | getline | |
srand($1) | |
close(cmd) | |
} | |
function oppaiRand() { | |
return int(rand() * 6) + 1 | |
} | |
function contains(_num, _numList) { | |
for (i = 0; i < 6; i++) | |
if (_num == _numList[i + 1]) | |
return 1 | |
return 0 | |
} | |
BEGIN { | |
randomize() | |
RealStr = "おっぱいそんちくびんびん" | |
m = 1 # utf-8 | |
if (length(RealStr) == 36) m = 3 # single byte | |
for (i = 0; i < 6; i++) { | |
OppaiElements[i + 1] = substr(RealStr, i * 2 * m + 1, 2 * m) | |
} | |
count = 0 | |
testStr = "" | |
while (testStr != RealStr) { | |
++count | |
len = 0 | |
delete numList | |
while (len < 6) { | |
num = oppaiRand() | |
if (!contains(num, numList)) numList[++len] = num | |
} | |
testStr = "" | |
for (i = 0; i < 6; i++) | |
testStr = testStr OppaiElements[numList[i + 1]] | |
printf "%d %s\n", count, testStr | |
} | |
printf "おめでとうございます!" | |
printf " " | |
printf "あなたは%d回目に%sしました。\n", count, RealStr | |
print "end" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment