diff --git a/1991/fine/README.md b/1991/fine/README.md index 570cada52..50ad37bbb 100644 --- a/1991/fine/README.md +++ b/1991/fine/README.md @@ -1,11 +1,8 @@ # Best One Liner -Thomas A. Fine -Ohio State University -Department of Computer and Information Science -2036 Neil Avenue Mall -Columbus, Ohio 43210 -US +Thomas A. Fine
+US
+[@thomasafine@social.linux.pizza](https://social.linux.pizza/@thomasafine) ## 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] +NOTE: Bits are referred to as 76543210, high to low. + +1. Get the character in variable `a`. Note the fun way we check for `EOF`. +(thanks J). + +2. Reverse bit 6, and strip bit 5. Bit 6 determines (mostly) whether + 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. + +3. Check this value to see if it is a letter. It must be non-zero - + if it is zero, then we have either the `@` (64) or the + `` ` `` (96). It also must be less than 27 - this checks the + range for letters as well as implicitly checking the value of bit 6 + (if it was originally clear, it is set now, so `b` would be too big). + +4. If it is not a letter, the conditional expression inside of the + `putchar()` returns the original character (`a`). Otherwise, it + returns a really messy expression that performs the actual rotation + and fixes the fifth and sixth bits: + * 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). + +Notice that this implementation operates only on characters with the +high bit clear. The high bit can be ignored without changing the size +of the program. Also, if you know you are only dealing with seven bit +data, the size can be reduced by one byte. These are left as exercises +for the student. + - ABGR: Ovgf ner ersreerq gb nf 76543210, uvtu gb ybj. - - 1. Trg gur punenpgre va inevnoyr n. Abgr gur sha jnl jr purpx sbe RBS. - (gunaxf W). - - 2. Erirefr ovg 6, naq fgevc ovg 5. Ovg 6 qrgrezvarf (zbfgyl) jurgure - be abg guvf punenpgre vf n yrggre. Ovg 5 jbhyq qrgrezvar pnfr vs - jr pnerq. Nffvta guvf inyhr gb inevnoyr o (Jr arrq gb fnir vg, - fvapr jr arrq gb znxr 2 pbzcnevfbaf naq znlor bar bcrengvba jvgu - guvf inyhr). Jr pna'g nohfr bhe svefg inevnoyr, fvapr vg fnirf gur - ovgf jr'er punatvat. - - 3. Purpx guvf inyhr gb frr vs vg vf n yrggre. Vg zhfg or aba-mreb - - vs vg vf mreb, gura jr unir rvgure gur ng-fvta (64) be gur - onpxdhbgr (96). Vg nyfb zhfg or yrff guna 27 - guvf purpxf gur - enatr sbe yrggref nf jryy nf vzcyvpvgyl purpxvat gur inyhr bs ovg 6 - (vs vg jnf bevtvanyyl pyrne, vg vf frg abj, fb o jbhyq or gb ovt). - - 4. Vs vg vf abg n yrggre, gur pbaqvgvbany rkcerffvba vafvqr bs gur - chgpune() ergheaf gur bevtvany punenpgre (n). Bgurejvfr, vg - ergheaf n ernyyl zrffl rkcerffvba gung cresbezf gur npghny ebgngvba - naq svkrf gur svsgu naq fvkgu ovgf: - - 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: diff --git a/author/Thomas_A_Fine.json b/author/Thomas_A_Fine.json index a35b02ada..cf42db469 100644 --- a/author/Thomas_A_Fine.json +++ b/author/Thomas_A_Fine.json @@ -10,8 +10,8 @@ "url" : "http://hea-www.harvard.edu/~fine/", "alt_url" : null, "deprecated_twitter_handle" : null, - "mastodon" : null, - "mastodon_url" : null, + "mastodon" : "@thomasafine@social.linux.pizza", + "mastodon_url" : "https://social.linux.pizza/@thomasafine", "github" : null, "affiliation" : null, "winning_entry_set" : [