aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-11 00:01:26 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-11 00:01:41 +1300
commit10ae1d5d9fa62ad294f2018cf43e41f94d5e6dcf (patch)
tree8df41cc7a301af255a2a33e79884098b3f1cf164 /games
parentReplace misplaced shebang line with comment (diff)
downloaddotfiles-10ae1d5d9fa62ad294f2018cf43e41f94d5e6dcf.tar.gz
dotfiles-10ae1d5d9fa62ad294f2018cf43e41f94d5e6dcf.zip
Golf/refactor drakon(1df) a bit
Diffstat (limited to 'games')
-rw-r--r--games/drakon.awk23
1 files changed, 8 insertions, 15 deletions
diff --git a/games/drakon.awk b/games/drakon.awk
index e960a6c0..39bb3732 100644
--- a/games/drakon.awk
+++ b/games/drakon.awk
@@ -1,20 +1,13 @@
# TyPe lIkE AnDoR DrAkOn fRoM AnCiEnT DoMaInS Of mYsTeRy
# <http://www.adomgb.info/adomgb-4.html>
{
- s = ""
- u = 0
- for (i = 1; i <= length($0); i++) {
- c = substr($0, i, 1)
- if (c ~ /[a-zA-Z]/) {
- if (u) {
- c = toupper(c)
- }
- else {
- c = tolower(c)
- }
- u = !u
- }
- s = s c
+ line = ""
+ case = 0
+ for (i = 1; i <= length; i++) {
+ char = substr($0, i, 1)
+ if (char ~ /[a-zA-Z]/)
+ char = (case = !case) ? tolower(char) : toupper(char)
+ line = line char
}
- print s
+ print line
}