aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-07-01 21:20:32 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-07-01 21:20:32 +1200
commit7992ad768824a861a8622b6bc71689a42fb562e7 (patch)
tree7fcef021fb7ca667bc64fc3badc7dc32918c90ec
parentMake fgscr POSIX sh/find compliant (diff)
downloaddotfiles-7992ad768824a861a8622b6bc71689a42fb562e7.tar.gz
dotfiles-7992ad768824a861a8622b6bc71689a42fb562e7.zip
Add rndn(6)
-rw-r--r--README.markdown1
-rwxr-xr-xgames/rndn12
-rw-r--r--man/man6/rndn.619
3 files changed, 32 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index 21c88166..fb588424 100644
--- a/README.markdown
+++ b/README.markdown
@@ -337,6 +337,7 @@ There's some silly stuff in `install-games`:
* `kvlt(6)` translates input to emulate a style of typing unique to black
metal communities on the internet.
+* `rndn(6)` implements an esoteric random number generation algorithm.
* `zs(6)` prepends "z" case-appropriately to every occurrence of "s" in the
text on its standard input.
diff --git a/games/rndn b/games/rndn
new file mode 100755
index 00000000..fd7f3813
--- /dev/null
+++ b/games/rndn
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+# Esoteric random number generator
+# <http://dilbert.com/strip/2001-10-25>
+for ((seed = RANDOM ** 2, i = 0; i < ${#seed}; i++)) ; do
+ ((sum += ${seed:i:1}))
+done
+for ((red = seed-sum; ${#red} > 1; red=redn)) ; do
+ for ((j = 0, redn=0; j < ${#red}; j++)) ; do
+ ((redn += ${red:j:1}))
+ done
+done
+printf '%u\n' "$red"
diff --git a/man/man6/rndn.6 b/man/man6/rndn.6
new file mode 100644
index 00000000..11169f3c
--- /dev/null
+++ b/man/man6/rndn.6
@@ -0,0 +1,19 @@
+.TH RNDN 6 "June 2016" "Manual page for rndn"
+.SH NAME
+.B rndn
+\- esoteric random number generator
+.SH USAGE
+.B rndn
+.br
+business-critical-process -t "$(\fBrndn\fR)"
+.SH DESCRIPTION
+.B rndn
+uses an advanced but somewhat esoteric algorithm derived by Adams (2001) to
+return a random number. While it has proven robust in the author's production
+usage, its algorithm has not been formally verified.
+.SH SEE ALSO
+<http://dilbert.com/strip/2001-10-25>
+.SH AUTHORS
+Tom Ryder <tom@sanctum.geek.nz>
+.br
+Inspired by discussions with Wade Brown