From 0ce6cf4d6cb2621f7e851daf82542f66729b32e5 Mon Sep 17 00:00:00 2001 From: gnat Date: Fri, 25 Oct 2024 00:37:26 -0700 Subject: [PATCH] add thought --- html/thoughts/dollcode | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 html/thoughts/dollcode diff --git a/html/thoughts/dollcode b/html/thoughts/dollcode new file mode 100644 index 0000000..a7d189d --- /dev/null +++ b/html/thoughts/dollcode @@ -0,0 +1,98 @@ + + + +recently, dollcode (two track pharmacode except rewritten by autistic transgender girlthings) has become a thing frequently utilized by this one's friends. +this is inconvenient, because many of them have written their own transcoders for the format which can handle arbitrarily large numbers. +the only two translators (this and this) this one could find online did not support messages that were represented as numbers larger than the 64 bit integer limit. +thusly, it simply could not read some of its friend's messages. +

+the optimal solution to such a problem was probably either asking the sender what their message said or asking them for their transcoder program. +this one did neither. +
+below, one may find a very good and reasonable dollcode translator tool. one may tell it is good and reasonable because it contains a y combinator written in python lambda statements. +
+~/src/dollcode λ cat dollcode
+#!/usr/bin/env -S bash -c 'python3 -c "__import__(\"sys\").setrecursionlimit(2**31-1); exec(open(\"$(which dollcode)\").read())" "$@"' _ 
+print((lambda d, ud, args:
+    d(int(args[-1])) if '-n' in args else 
+    d(int(''.join(map(lambda x: str(hex(ord(x))[2::]), args[-1])), 16)) if '-a' in args else
+    ud(args[-1]) if '-dn' in args else
+    (lambda h: ''.join(map(lambda i: chr(int(h[i:i+2], 16)), range(0, len(h), 2))))(hex(ud(args[-1]))[2::]) if '-da' in args else
+    "0x6e6174\'s dollcode conversion tool\n"
+    "\t-n: encode decimal number as dollcode\n"
+    "\t-a: encode ascii string as dollcode\n"
+    "\t-dn: decode dollcode as decimal\n"
+    "\t-da: decode dollcode as ascii string"
+)(lambda n: ''.join(map(lambda n: ''.join(['▖','▘','▌'][int(n)]), (lambda f: (lambda x: f(lambda y: x(x)(y))) (lambda x: f(lambda y: x(x)(y))))(lambda f: lambda n: (lambda x, y: str(f(x)) + str(y))(*divmod(n-1, 3)) if n else '')(n))),
+  lambda d: __import__('functools').reduce(lambda a, d: a * 3 + d, map(lambda x: {'▖': 1, '▘': 2, '▌': 3}[x], d), 0),
+  __import__('sys').argv)
+)
+
+also, it can be written in one line (ignoring the shebang): +
+~/src/dollcode λ cat $(which dollcode)
+#!/usr/bin/env -S bash -c 'python3 -c "__import__(\"sys\").setrecursionlimit(2**31-1); exec(open(\"$(which dollcode)\").read())" "$@"' _ 
+print((lambda d,ud,args:d(int(args[-1]))if'-n'in args else d(int(''.join(map(lambda x:str(hex(ord(x))[2::]),args[-1])),16))if'-a'in args else ud(args[-1])if'-dn'in args else(lambda h:''.join(map(lambda i:chr(int(h[i:i+2],16)),range(0,len(h),2))))(hex(ud(args[-1]))[2::])if'-da'in args else"0x6e6174\'s dollcode conversion tool\n\t-n: encode decimal number as dollcode\n\t-a: encode ascii string as dollcode\n\t-dn: decode dollcode as decimal\n\t-da:decode dollcode as ascii string")(lambda n:''.join(map(lambda n:''.join(['▖','▘','▌'][int(n)]),(lambda f:(lambda x:f(lambda y:x(x)(y)))(lambda x:f(lambda y:x(x)(y))))(lambda f:lambda n:(lambda x,y:str(f(x))+str(y))(*divmod(n-1,3))if n else'')(n))),lambda d:__import__('functools').reduce(lambda a,d:a*3+d,map(lambda x:{'▖':1,'▘':2,'▌':3}[x],d),0),__import__('sys').argv))
+
+python is a very good language. this is observable in that it allows integers to have arbitrarily$[make-footnote "up to a value that the user can change at runtime"] many digits. +it isn't really sure why python allows this, but it is glad it does, because it is funny. +one may wonder: "why is the shebang like that?" +the answer is because it did not want to set the recursion limit inside of the actual program, and decided it would be amusing to have a really weird shebang instead. +
+bafflingly, this program works. +
+~ λ dollcode -a nat
+▖▖▖▖▘▖▖▖▖▘▌▖▖▖▘
+
+
+~ λ dollcode -da $(dollcode -a nat)
+nat
+
+it is very efficient: +
+~ λ dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" >/dev/null & pid=$!; while kill -0 $pid 2>/dev/null; do pmap -x $pid | tail -n 1 | awk '{print ""$3/1024/1024 " GB"}'; sleep .5; done; wait $pid 
+[1] 11113
+0.0247803 GB
+0.261642 GB
+0.625462 GB
+0.982468 GB
+1.34475 GB
+1.69653 GB
+2.07035 GB
+2.43603 GB
+2.80609 GB
+3.16292 GB
+3.53598 GB
+3.90202 GB
+4.27491 GB
+4.63856 GB
+5.02195 GB
+5.37629 GB
+5.75089 GB
+6.13502 GB
+6.48058 GB
+6.85527 GB
+7.24199 GB
+7.6222 GB
+7.96089 GB
+8.33753 GB
+8.719 GB
+9.0616 GB
+9.44017 GB
+9.82001 GB
+10.1397 GB
+10.526 GB
+10.9109 GB
+11.0703 GB
+10.956 GB
+10.8826 GB
+10.8184 GB
+0 GB
+[1]  + done       dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" > /dev/null
+
$[make-footnote 'it had to kill firefox to perform this test'] +
+~ λ time dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" >/dev/null                                                                                                                          
+dollcode -a "$(for i in {0..65536}; do echo -ne a; done)" > /dev/null  13.35s user 4.77s system 99% cpu 18.168 total
+
$[make-footnote 'one must not worry, it is only like that for large inputs. this one is pretty sure there is some exponential time (and memory) complexity in there somewhere'] +
+$[put-footnotes]