Update 1991/fine/README.md + add mastodon handle
Undo rot13 and fix formatting. Added mastodon handle. This was done in the author/Thomas_A_Fine.json file too.
This commit is contained in:
1 parent
88137405e8
commit
ffa8792360
2 files changed
+35
-38
No files matched your search
+33
-36
@@ -1,11 +1,8 @@
|
|||||||
# Best One Liner
|
# Best One Liner
|
||||||
|
|
||||||
Thomas A. Fine
|
Thomas A. Fine<br>
|
||||||
Ohio State University
|
US<br>
|
||||||
Department of Computer and Information Science
|
[@thomasafine@social.linux.pizza](https://social.linux.pizza/@thomasafine)
|
||||||
2036 Neil Avenue Mall
|
|
||||||
Columbus, Ohio 43210
|
|
||||||
US
|
|
||||||
|
|
||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
@@ -60,43 +57,43 @@ The author wishes to thank J Greely for the last 6 bytes.
|
|||||||
|
|
||||||
Here's about how it does it: [rot13 to read]
|
Here's about how it does it: [rot13 to read]
|
||||||
|
|
||||||
|
NOTE: Bits are referred to as 76543210, high to low.
|
||||||
|
|
||||||
ABGR: Ovgf ner ersreerq gb nf 76543210, uvtu gb ybj.
|
1. Get the character in variable `a`. Note the fun way we check for `EOF`.
|
||||||
|
(thanks J).
|
||||||
|
|
||||||
1. Trg gur punenpgre va inevnoyr n. Abgr gur sha jnl jr purpx sbe RBS.
|
2. Reverse bit 6, and strip bit 5. Bit 6 determines (mostly) whether
|
||||||
(gunaxf W).
|
or not this character is a letter. Bit 5 would determine case if
|
||||||
|
we cared. Assign this value to variable `b` (We need to save it,
|
||||||
|
since we need to make 2 comparisons and maybe one operation with
|
||||||
|
this value). We can't abuse our first variable, since it saves the
|
||||||
|
bits we're changing.
|
||||||
|
|
||||||
2. Erirefr ovg 6, naq fgevc ovg 5. Ovg 6 qrgrezvarf (zbfgyl) jurgure
|
3. Check this value to see if it is a letter. It must be non-zero -
|
||||||
be abg guvf punenpgre vf n yrggre. Ovg 5 jbhyq qrgrezvar pnfr vs
|
if it is zero, then we have either the `@` (64) or the
|
||||||
jr pnerq. Nffvta guvf inyhr gb inevnoyr o (Jr arrq gb fnir vg,
|
`` ` `` (96). It also must be less than 27 - this checks the
|
||||||
fvapr jr arrq gb znxr 2 pbzcnevfbaf naq znlor bar bcrengvba jvgu
|
range for letters as well as implicitly checking the value of bit 6
|
||||||
guvf inyhr). Jr pna'g nohfr bhe svefg inevnoyr, fvapr vg fnirf gur
|
(if it was originally clear, it is set now, so `b` would be too big).
|
||||||
ovgf jr'er punatvat.
|
|
||||||
|
|
||||||
3. Purpx guvf inyhr gb frr vs vg vf n yrggre. Vg zhfg or aba-mreb -
|
4. If it is not a letter, the conditional expression inside of the
|
||||||
vs vg vf mreb, gura jr unir rvgure gur ng-fvta (64) be gur
|
`putchar()` returns the original character (`a`). Otherwise, it
|
||||||
onpxdhbgr (96). Vg nyfb zhfg or yrff guna 27 - guvf purpxf gur
|
returns a really messy expression that performs the actual rotation
|
||||||
enatr sbe yrggref nf jryy nf vzcyvpvgyl purpxvat gur inyhr bs ovg 6
|
and fixes the fifth and sixth bits:
|
||||||
(vs vg jnf bevtvanyyl pyrne, vg vf frg abj, fb o jbhyq or gb ovt).
|
* A. Subtract 1, to get into the range 0-25 (for the modulo operation).
|
||||||
|
* B. Add 13 to the character. Steps A and B are combined.
|
||||||
|
* C. Take this modulo 26 to make the addition wrap around.
|
||||||
|
* D. Fix bits 5 and 6, based on variable `a`.
|
||||||
|
* E. Add 1 back in (we took it out in step A.) This is okay to do *after*
|
||||||
|
step D, because we know the addition won't trickle up past the fourth bit
|
||||||
|
(`b` would have to be 31 for this to happen).
|
||||||
|
|
||||||
4. Vs vg vf abg n yrggre, gur pbaqvgvbany rkcerffvba vafvqr bs gur
|
Notice that this implementation operates only on characters with the
|
||||||
chgpune() ergheaf gur bevtvany punenpgre (n). Bgurejvfr, vg
|
high bit clear. The high bit can be ignored without changing the size
|
||||||
ergheaf n ernyyl zrffl rkcerffvba gung cresbezf gur npghny ebgngvba
|
of the program. Also, if you know you are only dealing with seven bit
|
||||||
naq svkrf gur svsgu naq fvkgu ovgf:
|
data, the size can be reduced by one byte. These are left as exercises
|
||||||
|
for the student.
|
||||||
|
|
||||||
N. Fhogenpg 1, gb trg vagb gur enatr 0-25 (sbe gur zbqhyb bcrengvba).
|
|
||||||
O. Nqq 13 gb gur punenpgre. Fgrcf N naq O ner pbzovarq.
|
|
||||||
P. Gnxr guvf zbqhyb 26 gb znxr gur nqqvgvba jenc nebhaq.
|
|
||||||
Q. Svk ovgf 5 naq 6, onfrq ba inevnoyr n.
|
|
||||||
R. Nqq 1 onpx va (jr gbbx vg bhg va fgrc N.) Guvf vf bxnl gb qb
|
|
||||||
*nsgre* fgrc Q, orpnhfr jr xabj gur nqqvgvba jba'g gevpxyr hc
|
|
||||||
cnfg gur sbhegu ovg (o jbhyq unir gb or 31 sbe guvf gb unccra).
|
|
||||||
|
|
||||||
Abgvpr gung guvf vzcyrzragngvba bcrengrf bayl ba punenpgref jvgu gur
|
|
||||||
uvtu ovg pyrne. Gur uvtu ovg pna or vtaberq jvgubhg punatvat gur fvmr
|
|
||||||
bs gur cebtenz. Nyfb, vs lbh xabj lbh ner bayl qrnyvat jvgu frira ovg
|
|
||||||
qngn, gur fvmr pna or erqhprq ol bar olgr. Gurfr ner yrsg nf rkrepvfrf
|
|
||||||
sbe gur fghqrag.
|
|
||||||
|
|
||||||
## Copyright and CC BY-SA 4.0 License:
|
## Copyright and CC BY-SA 4.0 License:
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
"url" : "http://hea-www.harvard.edu/~fine/",
|
"url" : "http://hea-www.harvard.edu/~fine/",
|
||||||
"alt_url" : null,
|
"alt_url" : null,
|
||||||
"deprecated_twitter_handle" : null,
|
"deprecated_twitter_handle" : null,
|
||||||
"mastodon" : null,
|
"mastodon" : "@thomasafine@social.linux.pizza",
|
||||||
"mastodon_url" : null,
|
"mastodon_url" : "https://social.linux.pizza/@thomasafine",
|
||||||
"github" : null,
|
"github" : null,
|
||||||
"affiliation" : null,
|
"affiliation" : null,
|
||||||
"winning_entry_set" : [
|
"winning_entry_set" : [
|
||||||
|
|||||||
Reference in new issue
Block a user