趣题:Anagram辅助程序的数据结构

    Anagram是一个比较流行的英文文字游戏,本Blog之前曾经介绍过,这里我再提一下。Anagram就是把一个词或者一句话里的字母重新排列,组成一个新的单词或句子,通常前后两者有一种讽刺的意味。比如,Dormitory = Dirty Room,或者Desperation = A Rope Ends It。创作一个有意思的Anagram并不是一件容易的事,你很可能需要计算机的帮助才能找到合适的词。例如,我们可以利用Hash表瞬间找出与给定单词所使用的字母完全相同的单词。我们可以把字典中每个单词的字母按照字母顺序重新排列,于是对单词dame和made操作后的结果都是adem,这样的话使用字母完全相同的单词就对应了一个唯一的Hash值,我们就可以方便地把它们归在一起。
    而实际上,这个Hash表往往没什么用。一个Anagram很可能是由多个单词构成的,因此我们更希望知道,使用某个单词中的字母(不一定全部使用)可以构造出哪些新的单词。例如,我输入单词dormitory,则程序可以输出dirty, motor, trim, dry, room等单词。很多Anagram辅助程序都有这样的功能,并且这也单独作为一个文字游戏存在。我们称这种只用到一部分给定字母的单词叫做不完全Anagram。假如字典里共有n个单词,输入数据长度为l,那么你怎样才能找出所有的不完全Anagram?一种方法是遍历所有n个单词,依次判断每个单词是否合法;另一种方法则是枚举输入数据的2^l子集,对每个子集在之前建立的Hash表中查询一次。现在,你能否想出一个数据结构,使得你的Anagram辅助程序能够以最快的速度输出任何一个给定单词的不完全Anagram?

  
    答案比你想像的更简单,这是一个非常简单的数据结构。我们建立一棵高度为26的树,按照每个字母出现的次数像Trie一样插入到树中。比如,abacus有2个a,于是插入到根的第二个子树里,接下来数出字母b的个数为1,并继续沿标号为1的边往下走,依此类推。最后,所有的数据都存放在对应的叶子节点上。查询时,在每个节点上只需数一数输入数据中对应字母的个数N,沿着标号小于等于N的边往下走就行了。
    下面是一个非常有趣的问题:这个数据结构还有什么优化的余地?比如,单词在树中是按照从A到Z的顺序依次分类,但实际上我们可以任意调整这个顺序。那么,你觉得建这棵树时是先按E、T等常用字母的个数分类好,还是先按照Q、Z等不常用字母的个数分类好?这个问题很简单,留给大家思考吧。
    另一个比较类似的东西是用于拼写检查的数据结构。这两个有趣的数据结构都是我在这里看到的。

做人要厚道
转贴请注明出处

十个有趣的英文文字游戏(下)

Ambigram
    Ambigram是指把一个单词或短语写成对称的样子,这样从两个不同的角度看这个图形都能读出这个单词或短语。例如,下面一个图形就是单词Ambigram的Ambigram:
      

    ambigram.com的首页有个这样的图片:
      

    Wikipedia上有这样一个Ambigram:
      

    最后来看一个左右轴对称的Ambigram(献丑了):
      

    Erich Friedman教授为他的朋友创作了很多Ambigram。你可以在他的个人主页上看到。

Alphametic
    Alphametic是指,把一句话写成加法算式,每一个字母表示一个数字,那么这个“虫食算”有唯一解。最常见的Alphametic可能是这个:
    SEND + MORE = MONEY
    它的唯一解是9567 + 1085 = 10652

    另一些Alphametic如下:
    FIFTY + STATES = AMERICA
    TERRIBLE + NUMBER = THIRTEEN
    EARTH + AIR + FIRE + WATER = NATURE
    SATURN + URANUS + NEPTUNE + PLUTO = PLANETS

    1969年,有人发现了这样一个有趣的Alphametic:
    THREE + THREE + TWO + TWO + ONE = ELEVEN

    这样的Alphametic叫做Doubly-True Alphametic。可以证明上面这个Doubly-True Alphametic是合法的Alphametic中“最小的”一个。另外两个稍微大一点的Doubly-True Alphametic为:
    SEVEN + SEVEN + SIX = TWENTY
    EIGHT + EIGHT + TWO + ONE + ONE = TWENTY

Mnemonic
    Mnemonic本意是可以帮助记忆的句子。例如,我原来记together这个单词就记作We want to get her。再比如,arithmetic可以记作A Rat In Tom's House Might Eat Tom's Ice Cream(每个单词的首字母)。当然,也有一些专门搞笑的Mnemonic,比如Microsoft = Most Intelligent Customers Realize Our Software Only Fools Them,而Macintosh = Most Applications Crash. If Not, The Operating System Hangs。
    数学家George Pólya(就是Pólya置换定理的那个Pólya)曾说过一句经典的话:How I need a drink, alcoholic of course, after the heavy chapters involving quantum mechanics! 依次数出每个单词的字母个数,你会惊讶的发现它正好是圆周率的前15位。后来又有人在后面加上一句All of thy geometry, Herr Planck, is fairly hard,让圆周率长度增加到24位。另一些圆周率的Mnemonic如下:
    Can I have a large container of orange juice?
    May I have a white telephone, or pastel color?
    How I wish I could calculate pi faster.
    For a girl I loved contrived; by nature tough, her heart survived.

    下面这首诗给出了圆周率的前740位。其中10个字母的单词表示一个数字0,字母数大于10的单词则表示两位数。

Poe, E.
      Near a Raven

Midnights so dreary, tired and weary.
    Silently pondering volumes extolling all by-now obsolete lore.
During my rather long nap – the weirdest tap!
    An ominous vibrating sound disturbing my chamber's antedoor.
        "This", I whispered quietly, "I ignore".

Perfectly, the intellect remembers: the ghostly fires, a glittering ember.
    Inflamed by lightning's outbursts, windows cast penumbras upon this floor.
Sorrowful, as one mistreated, unhappy thoughts I heeded:
    That inimitable lesson in elegance – Lenore –
        Is delighting, exciting…nevermore.

Ominously, curtains parted (my serenity outsmarted),
    And fear overcame my being – the fear of "forevermore".
Fearful foreboding abided, selfish sentiment confided,
    As I said, "Methinks mysterious traveler knocks afore.
        A man is visiting, of age threescore."

Taking little time, briskly addressing something: "Sir," (robustly)
    "Tell what source originates clamorous noise afore?
Disturbing sleep unkindly, is it you a-tapping, so slyly?
    Why, devil incarnate!–" Here completely unveiled I my antedoor–
        Just darkness, I ascertained – nothing more.

While surrounded by darkness then, I persevered to clearly comprehend.
    I perceived the weirdest dream…of everlasting "nevermores".
Quite, quite, quick nocturnal doubts fled – such relief! – as my intellect said,
    (Desiring, imagining still) that perchance the apparition was uttering a whispered "Lenore".
        This only, as evermore.

Silently, I reinforced, remaining anxious, quite scared, afraid,
    While intrusive tap did then come thrice – O, so stronger than sounded afore.
"Surely" (said silently) "it was the banging, clanging window lattice."
    Glancing out, I quaked, upset by horrors hereinbefore,
        Perceiving: a "nevermore".

Completely disturbed, I said, "Utter, please, what prevails ahead.
    Repose, relief, cessation, or but more dreary 'nevermores'?"
The bird intruded thence – O, irritation ever since! –
    Then sat on Pallas' pallid bust, watching me (I sat not, therefore),
        And stated "nevermores".

Bemused by raven's dissonance, my soul exclaimed, "I seek intelligence;
    Explain thy purpose, or soon cease intoning forlorn 'nevermores'!"
"Nevermores", winged corvus proclaimed – thusly was a raven named?
    Actually maintain a surname, upon Pluvious seashore?
        I heard an oppressive "nevermore".

My sentiments extremely pained, to perceive an utterance so plain,
    Most interested, mystified, a meaning I hoped for.
"Surely," said the raven's watcher, "separate discourse is wiser.
    Therefore, liberation I'll obtain, retreating heretofore –
        Eliminating all the 'nevermores' ".

Still, the detestable raven just remained, unmoving, on sculptured bust.
    Always saying "never" (by a red chamber's door).
A poor, tender heartache maven – a sorrowful bird – a raven!
    O, I wished thoroughly, forthwith, that he&#
39;d fly heretofore.
        Still sitting, he recited "nevermores".

The raven's dirge induced alarm – "nevermore" quite wearisome.
    I meditated: "Might its utterances summarize of a calamity before?"
O, a sadness was manifest – a sorrowful cry of unrest;
    "O," I thought sincerely, "it's a melancholy great – furthermore,
        Removing doubt, this explains 'nevermores' ".

Seizing just that moment to sit – closely, carefully, advancing beside it,
    Sinking down, intrigued, where velvet cushion lay afore.
A creature, midnight-black, watched there – it studied my soul, unawares.
    Wherefore, explanations my insight entreated for.
        Silently, I pondered the "nevermores".

"Disentangle, nefarious bird! Disengage – I am disturbed!"
    Intently its eye burned, raising the cry within my core.
"That delectable Lenore – whose velvet pillow this was, heretofore,
    Departed thence, unsettling my consciousness therefore.
        She's returning – that maiden – aye, nevermore."

Since, to me, that thought was madness, I renounced continuing sadness.
    Continuing on, I soundly, adamantly forswore:
"Wretch," (addressing blackbird only) "fly swiftly – emancipate me!"
    "Respite, respite, detestable raven – and discharge me, I implore!"
        A ghostly answer of: "nevermore".

" 'Tis a prophet? Wraith? Strange devil? or the ultimate evil?"
    "Answer, tempter-sent creature!", I inquired, like before.
"Forlorn, though firmly undaunted, with 'nevermores' quite indoctrinated,
    Is everything depressing, generating great sorrow evermore?
        I am subdued!", I then swore.

In answer, the raven turned – relentless distress it spurned.
    "Comfort, surcease, quiet, silence!" – pleaded I for.
"Will my (abusive raven!) sorrows persist unabated?
    Nevermore Lenore respondeth?", adamantly I encored.
        The appeal was ignored.

"O, satanic inferno's denizen — go!", I said boldly, standing then.
    "Take henceforth loathsome "nevermores" – O, to an ugly Plutonian shore!
Let nary one expression, O bird, remain still here, replacing mirth.
    Promptly leave and retreat!", I resolutely swore.
        Blackbird's riposte: "nevermore".

So he sitteth, observing always, perching ominously on these doorways.
    Squatting on the stony bust so untroubled, O therefore.
Suffering stark raven's conversings, so I am condemned, subserving,
    To a nightmare cursed, containing miseries galore.
        Thus henceforth, I'll rise (from a darkness, a grave) — nevermore!

                        — original: E. Poe
                        — Redone by measuring circles.

Lipogram
    看看下面这句话有什么问题?

This is an unusual paragraph. I'm curious how quickly you can find out what is so unusual about it. It looks so plain you would think nothing was wrong with it! In fact, nothing is wrong with it! It is unusual though. Study it, and think about it, but you still may not find anything odd. But if you work at it a bit, you might find out! Try to do so without any coaching!

    答案:这段话里竟然没有一个字母e !
    Lipogram就是指的这样一个段落(甚至文章),里面缺少某个常用的字母。在所有的Lipogram中,写一个没有字母e的文章是最难的,因为字母e出现的频率最高。
    看一个比较长的Lipogram。下面这篇文章里硬是没有一个字母e!

Looking at this paragraph with confusion? I'll aid you slightly. Is any odd gap, lacuna or omission obvious to you? Got it now? No?

That's right – this is a lipogram – a book, paragraph or similar thing in writing that lacks a symbol, particularly (but not always) that symbol fifth in rank out of our 26 script-signs (found amidst 'd' and 'f'), which stands for a sound such as that in 'kiwi'. I won't bring it up right now, to avoid spoiling it. I could play with lipograms morning, noon and night. So it is with joy that I submit to you this location – truly, a loquacious location – for lipogram fanatics to join as a unit to glorify this form of wordplay.

As far as I know, this location has a distinct honour: it contains such an abundant quantity of words without using this taboo glyph that no WWW location can outmatch it. As of right now, it contains 1500 words without any hint of that symbol. Naturally, many long lipograms abound in print, including books, rhyming stanzas, and similar works of fiction. Most notably, La Disparition (A Void) by a famous author of a writing group known as Oulipo, stands out as a paragon of lipogrammaticity. I cannot aim to surpass it, but as a fan, I can look upon it with admiration.

Writing lipograms is, as you might think, a difficult task. In my lingo, 2/3 of all words contain that symbol which I am now avoiding, including many common pronouns and similar words commonly found in writing. Without using abbrvs., slang and odd jargon, which most purists scorn as cop-outs, it's darn tough to impart information in a stylistically satisfying way. Stripping paragraphs of particular symbols has a way of making looking at lipograms jarring. No doubt about it, a lipogram is a particularly arduous form of wordplay.

Having said this, acquiring a knack for lipogram composition isn't that hard, and may assist you in your non-lipogrammatic writing. Not to say that I'm without aid in this activity; my dictionary is always handy, as is a book with synonyms for words. And, notwithstanding any drawbacks flowing from passing many an hour looking for unusual ways to say ordinary things, it might aid your socialization skills. Chicks truly dig lipogrammatists, or so my old lady says.

Sadly, a handful of critics find lipograms ridiculous, ugly or without worth (as fiction or as wordplay). To such sorry saps, I say only that in constraining your thoughts and writing in a particular way aids in promoting branching paths of thought, thus amplifying vocabulary and instilling adroit linguistic skills among both young and old. By putting into praxis ways of thinking that wouldn't occur normally, lipograms call for authors to look at writing as an activity in ways that, frankly, wouldn't occur to such niggling adjudicators of linguistic conduct.

Withholding a symbol found in so many words has drastic symptoms that disallow many topics of discussion. (From this point on, I'll stick to talking about that sign I'm skipping right now). Using math is almost an impossibility; you can only main
tain 15 of all non-digital words for cardinal quantity up to 100, and hardly any at all past that point, though using digits is a good way out. You can go north or south, but talking about circumnavigating our world latitudinally is an impossibility. How can I possibly talk about various kinds of malt liquor, or parts of my body, without it? To top it all off, as an Anglo, strict prohibitions apply to naming of my own form of linguistic communication. I ought to thank my lucky stars that I'm not writing in lipogrammatic français, though, which holds on to only an octal portion of its original vocabulary.

But all is not lost. Surprisingly, profanity is mostly intact. As a practicing lipogrammatist, you'll find you want many such words, for it is a task so awkward as to call for cussing and cursing on a normal basis. A world map is truly a blissful oasis; my country (Canada) is totally satisfactory, as with most toponyms for nations (111 out of 186, by my count); with a bit of work, USA, UK, and so on, can still show up, and with twin island nations Trinidad and Tobago and Antigua and Barbuda (both with 17 glyphs) topping my list for prolongation. Musicians (particularly classical artists), astonishingly, hold firm as topics of discussion, with Bach, Bartok, Brahms, Chopin, Dvorak, Haydn, Holst, Liszt, Mozart, orff, Puccini, Rachmaninov, Rossini, Scarlatti, Schumann, Strauss, Stravinsky, Tchaikovsky and Vivaldi void of my lost non-consonant.

An additional branch of family Lipogrammatica consists of univocalics. This form of wordplay is akin to a lipogram, but contains a solitary sign that's not a consonant. To wit, a univocalic might omit 'a', 'i', 'o', and 'u' (but what about 'y'?). A univocalic has a sonorant quality that a lipogram lacks, so you must look at a lipogram, but contrarily, a univocalic is both auditory and visual, and has a strong sound if said aloud. Univocalic writing is hard to pull off, but if it's good, its payoff is gigantic.

另外推荐本Blog里的两个相关内容:
http://www.matrix67.com/blog/article.asp?id=104
http://www.matrix67.com/blog/article.asp?id=173

Matrix67收集整理
转贴请注明出处

十个有趣的英文文字游戏(上)

Crossword
    Crossword我就不用多废话了,这应该是最流行的英文文字游戏。和大多数人想象的不同,构造一个Crossword谜题非常难。真正的Crossword谜题里的空格比你想象的更多,整个填字区域要做到中心对称,而且通常每个Crossword需要有一个特定的主题。去年有一个记录片叫Wordplay,很不错(我给它打了8分)。记录片里介绍了很多和Crossword有关的文化,包括出谜人、解谜人、俱乐部、比赛等很多内容。
    下面是一个以数学为主题的Crossword,大家没事可以做做。答案在本文最后面。

  
Across

1. Cut corners
5. The __ plane, or S(7)
9. Hydrogen
14. Large reptile
16. Column
17. Gives the slope of a tangent to a curve
19. Book by Zienkiewicz and Taylor, abbr.
20. Divide
21. Sin reciprocal
22. The playing field, in nim
25. "I saw Blanusa's paper __ after it appeared." — Tutte
26. pronoun
27. Hydroxyl group bonded to a doubly-bonded carbon atom
28. (e^z – e^(-z))/2
29. Bar
30. The sphinx is a __-tile
31. __-digit
32. Fit
35. A type of map projection
38. The ___ hypothesis is independent of Zermelo-Fraenkel-Choice
39. Floor coverings, frequently symmetrical
40. Graph theorist Hai Peng
41. Angle
42. Branch or Dedekind
43. Math __ (where to find a prof)
44. 2, 4, 6, 30, 32, 34, 36, 40, 42 …
46. Art __
47. Computer Algebra: Systems and Algorithms for Algebraic Computation editor
48. MAA president Graham
49. Rule
50. As opposed to LHS
51. The gamma function has these at negative integers
57. Puzzle creator van Deventer
58. Tries
59. Paris river
60. Philosopher Descartes
61. Charts

Down

1. Saturnine
2. Director of Ulugh Beg's observatory
3. 3-30 KHz, as heard by "whistler" receivers
4. An OOPL or tower.
5. Plow
6. Supped
7. Proof of existance, without a specific example
8. Hermite orthogonal polynomial
9. Stat
10. GTE rival
11. Quasi-conformal enemy of Edmund Landau
12. (23/9)^5 and 109, for example
13. Ergo
15. Pilot stunt: "pulling ___"
18. Faraday theory, later proven by Arrhenius
22. Peace prize winner Shimon
23. J of ___ and Appl
24. The Inverse Variational Problem in Classical Mechanics author
25. The "sampling" function
26. A searching method for Ramsey numbers
28. "What I give form to in daylight is only one per cent of what I have __ in darkness." — Escher
29. boxers
31. High school math
32. Add-with-carry, inverse congruential, rule 30, dice, etc.
33. Chaos and Fractals author Dietmar
34. Graphica author Michael
36. ICOSAHOM editor Andrew
37. Focus, for example
42. Triangle part studied by Kimberling
43. In anatomy, away from the origin
44. More than 1500 math papers have his name
45. Where Set theory: On the structure of the real line was written
46. Actor Knotts
47. Number theorist Peter
49. Sported
50. Theorem
52. Cylinder
53. O'__ group (order 460815505920)
54. Skater Midori
55. Mind plotter
56. It's better than angle-angle-side

Anagram
    Anagram是指调整一个单词或短语的字母顺序后组成另外一个单词或短语,通常前后两者的关系有点讽刺意味。比如,《达芬奇密码》上就有一个:
    O, Draconian devil! Oh, lame saint! = Leonardo da Vinci, The Mona Lisa

    经典的Anagram非常有意思。看下面几个Anagram:
    Listen = Silent
    Dormitory = Dirty Room
    Desperation = A Rope Ends It
    Mother-in-law = Woman Hitler
    A telephone girl = Repeating "Hello"
    The country side = No City Dust Here

    一些Anagram有可能很长。比如这一个:
    To be or not to be: that is the question, whether tis nobler in the mind to suffer the slings and arrows of outrageous fortune.
    = In one of the Bard's best-thought-of tragedies, our insistent hero, Hamlet, queries on two fronts about how life turns rotten.

    另一个有趣的Anagram是这样:
    Eleven plus two = Twelve plus one

Pangram
    Pangram是指这样一种句子,它虽然不长,但包含了所有26个英文字母。Pangram常用于打字机测试和字体演示。大家最熟悉不过的是Windows字体演示时所用的Pangram:
    The quick brown fox jumps over the lazy dog.

    而Macintosh的字体演示则是使用的这个Pangram:
    Cozy lummox gives smart squid who asks for job pen.

    另一个比较常见的Pangram如下:
    Pack my box with five dozen liquor jugs.

    当然,有人肯定想问,有没有最短的Pangram?当然有。有的Pangram只有26个字母(每个字母恰好用一次),这样的Pangram叫做Perfect pangram。比如下面这一个:
    New job: fix Mr. Gluck's hazy TV, PDQ!

Autogram
    Autogram又叫做Self-enumerating Sentence,是指一句话的内容描述的正是这句话本身。下面是一些常见的Autogram:
    This sentence contains five words.
    This sentence contains thirty-six letters.
    There are fourteen vowels in this sentence.

    1982年,Scientific American月刊上刊登出一个Autogram杰作:

Only the fool would take trouble to verify that his sentence was composed of ten a's, three b's, four c's, four d's, forty-six e's, sixteen f's, four g's, thirteen h's, fifteen i's, two k's, nine l's, four m's, twenty-five n's, twenty-four o's, five p's, sixteen r's, forty-one s's, thirty-seven t's, ten u's, eight v's, eight w's, four x's, eleven y's, twenty-seven commas, twenty-three apostrophes, seven hyphens and, last but not least, a single !

    另一个类似的Autogram如下:

This autogram contains five a's, one b, two c's, two d's, thirty-one e's, five f's, five g's, eight h's, twelve i's, one j, one k, two l's, two m's, eighteen n's, sixteen o's, one p, one q, six r's, twenty-seven s's, twenty-one t's, three u's, seven v's, eight w's, three x's, four y's, and one z.

Palindrome
    Palindrome是指这样一种单词或句子,从左往右和从右往左读都是一样的。例如,单词eye, noon, level, racecar, redivider都是Palindrome。一些比较长的句子也可能是Palindrome,比如USACO上曾出现过这样一个Palindrome:
    Madam, I'm Adam.

    另一些有趣的Palindrome如下:
    Never odd or even.
    Was it a cat I saw?
    Step on no pets!
    Dammit, I'm mad!
    Rise to vote, sir.
&nbs
p;   God lived as a devil dog.
    A man, a plan, a canal — Panama!

    1814年,当拿破仑被流放到Elba岛时,拿破仑曾说过:
    Able was I ere I saw Elba.

    这里有一份号称世上最长的Palindrome。

Alphamagic Square
    1986年,一个叫Lee Sallows的电子工程师发现了这样一个3阶幻方:
5       22      18
28      15      2
12      8       25

    初看之下这个幻方似乎没有什么特别之处。然而,把它转换成文字后:
five            twenty-two      eighteen
twenty-eight    fifteen         two
twelve          eight           twenty-five

    再数一下每个单词的字母个数,我们可以得到一个新的幻方,它恰好由3到11这9个数字组成:
4       9       8
11      7       3
6       5       10

Matrix67收集整理
转贴请注明出处

      

Yuor bairn is samtrer tahn you tnhik

Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, the oredr of letetrs in a wrod dosen't mttaer, the olny thnig thta's iopmrantt is that the frsit and lsat ltteer of eevry word is in the crcreot ptoision. The rset can be jmbueld and one is stlil able to raed the txet wiohtut dclftfuiiy. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe.

Dnot konw if you gyus hvae alerday seen it berfoe

十大另类程序语言(下)

5. TMMLPTEALPAITAFNFAL语言 http://p-nand-q.com/humor/programming_languages/tmmlpteal.html
    你没看错,上面这一排毫无意义的字母是一个语言的名称。它是The Multi-Million Language Project To End All Language Projects And Isn't That A Fine Name For A Language的缩写。TMMLPTEALPAITAFNFAL语言没有固定的语法规则,每一天都是不同的语法。例如,2000年10月13日你可以使用DIV但不能使用MOD;到了10月14日时你可以使用MOD了但DIV又不能用了。因此,你今天写的程序运行起来完全正常,但是到了明天就无法编译了。下面是一个TMMLPTEALPAITAFNFAL的Hello World程序,当然现在已经无法编译了。
    DECLARE CELL 100 AS READPOS
    DECLARE 10 AS NEWLINE
    WRITE CHAR NEWLINE
    COPY "Hello, World" TO CELL 0
    COPY 0 TO READPOS
    WHILE READPOS INDIRECT DO GOSUB 300
    WRITE CHAR NEWLINE
    RETURN
LINE 300: WRITE CHAR READPOS INDIRECT
    ADD 1 TO READPOS
    RETURN

4. l33t语言 http://web.archive.org/web/20050329085620/http://electrod.ifreepages.com/l33t.htm
    Leetspeak是国外网络上曾经流行的一种字母书写方式,就像这个样子。很多电影和美剧的名字也是Leetspeak,比如se7en、numb3rs、s1m0ne等等。l33t程序的代码故意仿照这种风格。它的代码中只有0到9这九个数字是有意义的,其它的字符都没用。因此,你可以先写好一篇文章,然后依次把里面出现的字母替换成你的l33t代码,让一段Leetspeak文字中隐藏一个小程序。下面就是一个Hello World示例程序:
   // "Hello World" by Stephen McGreal.
   // Note that the views expressed in this source code do not necessarily coincide with those of the author :o)
  
   Gr34t l33tN3$$?
   M3h...
   iT 41n't s0 7rIckY.
  
   l33t sP33k is U8er keWl 4nD eA5y wehn u 7hink 1t tHr0uGh.
   1f u w4nn4be UB3R-l33t u d3f1n1t3lY w4nt in 0n a b4d4sS h4xX0r1ng s1tE!!!;p
   w4r3Z c0ll3cT10n2 r 7eh l3Et3r!
  
   Qu4k3 cL4nS r 7eh bE5t tH1ng 1n teh 3nTIr3 w0rlD!!!
   g4m3s wh3r3 u g3t to 5h00t ppl r 70tAl1_y w1cK1d!!
   I'M teh fr4GM4stEr aN I'lL t0t41_1Ly wIpE teh phr34k1ng fL00r ***j3d1 5tYlE*** wItH y0uR h1dE!!!!L0L0L0L!
   t3lEphR4gG1nG l4m3rs wit mY m8tes r34lLy k1kK$ A$$
  
   l33t hAxX0r$ CrE4t3 u8er- k3wL 5tUff lIkE n34t pR0gR4mm1nG lAnguidGe$...
   s0m3tIm3$ teh l4nGu4gES l00k jUst l1k3 rE41_ 0neS 7o mAkE ppl Th1nk th3y'r3 ju$t n0rMal lEE7 5pEEk but th3y're 5ecRetLy c0dE!!!!
   n080DY unDer5tAnD$ l33t SpEaK 4p4rT fr0m j3d1!!!!!
   50mE kId 0n A me$$4gEb04rD m1ghT 8E a r0xX0r1nG hAxX0r wH0 w4nT2 t0 bR34k 5tuFf, 0r mAyb3 ju5t sh0w 7eh wAy5 l33t ppl cAn 8E m0re lIkE y0d4!!! hE i5 teh u8ER!!!!
   1t m1ght 8E 5omE v1rus 0r a Pl4ySt4tI0n ch34t c0dE.
   1t 3v3n MiTe jUs7 s4y "H3LL0 W0RLD!!!" u ju5t cAn'T gu3s5.
   tH3r3's n3v3r anY p0iNt l00KiNg sC3pT1c4l c0s th4t, be1_1Ev3 iT 0r n0t, 1s whAt th1s 1s!!!!!
  
   5uxX0r5!!!L0L0L0L0L!!!!!!!

3. Java2K语言 http://p-nand-q.com/humor/programming_languages/java2k.html
    Java2K是一种非确定性的语言,程序正常运行是有一定概率的。很多时候程序并不能按照你的意愿去运行,即使是系统函数也不会总是去做它该做的事。所有的函数都有两种不同的解释,程序运行时会随机选择一个作为实际调用的函数。
    几乎所有的系统函数返回正确结果都只有90%的可能性,因此程序运行的最终结果或多或少都和预期结果不同。写出正确率尽量高的Java2K程序是一个非常有趣的挑战。

2. Chef语言 http://www.dangermouse.net/esoteric/chef.html
    一个完整的Chef程序代码分为三个部分:程序名、变量声明和一系列栈操作。所有的操作都写成食谱的样子。例如,Put x into the mixing bowl就表示把变量x压入栈中,而Stir for 2 minutes则表示把栈顶元素向下移两格。下面的程序打印出前100个Fibonacci数。
Fibonacci Numbers with Caramel Sauce.

Ingredients.
100 g flour
250 g butter
1 egg

Method.
Sift the flour. Put flour into mixing bowl. Serve with caramel sauce. Stir for 2 minutes. Remove egg. Rub the flour until sifted. Stir for 2 minutes. Fold the butter into the mixing bowl. Pour contents of the mixing bowl into the baking dish.

Serves 1.

Caramel Sauce.

Ingredients.
1 cup white sugar
1 cup brown sugar
1 vanilla bean

Method.
Fold white sugar into mixing bowl. Put white sugar into mixing bowl. Fold brown sugar into mixing bowl. Clean mixing bowl. Put white sugar into mixing bowl. Remove vanilla bean. Fold white sugar into mixing bowl. Melt white sugar. Put vanilla bean into mixing bowl. Refrigerate. Heat white sugar until melted. Put white sugar into mixing bowl. Remove vanilla bean. Fold white sugar into mixing bowl. Caramelise white sugar. Put vanilla bean into mixing bowl. Refrigerate. Cook white sugar until caramelised. Put white sugar into mixing bowl. Serve with caramel sauce. Fold brown sugar into mixing bowl. Put white sugar into mixing bowl. Add vanilla bean. Serve with caramel sauce. Add brown sugar.

1. Shakespeare语言 http://shakespearelang.sourceforge.net/
    在所有的另类语言中,Shakespeare语言可能是最搞笑的了,并且难以置信的是它居然是SourceForge.net的一个项目。Shakespeare的代码完全模仿莎士比亚的戏剧。它也是一个基于栈的程序语言,程序中出场的每一个人物都代表一个栈。Shakespeare的代码自由度很高,因此同一个程序你可以写出完全不同的代码出来。Shakespeare的Hello World代码如下:
The Infamous Hello World Program.

Romeo, a young man with a remarkable patience.
Juliet, a likewise young woman of remarkable grace.
Ophelia, a remarkable woman much in dispute with Hamlet.
Hamlet, the flatterer of Andersen Insulting A/S.

                    Act I: Hamlet's insults and flattery.

                    Scene I: The insulting of Romeo.

[Enter Hamlet and Romeo]

Hamlet:
You lying stupid fatherless big smelly half-witted coward!
You are as stupid as the difference between a handsome rich brave
hero and thyself! Speak your mind!

You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!

You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.

Speak your mind!

[Exit Romeo]

                    Scene II:
The praising of Juliet.

[Enter Juliet]

Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!

[Exit Juliet]

                    Scene III: The praising of Ophelia.

[Enter Ophelia]

Hamlet:
Thou art as lovely as the product of a large rural town and my amazing
bottomless embroidered purse. Speak thy mind!

Thou art as loving as the product of the bluest clearest sweetest sky
and the sum of a squirrel and a white horse. Thou art as beautiful as
the difference between Juliet and thyself. Speak thy mind!

[Exeunt Ophelia and Hamlet]

                    Act II: Behind Hamlet's back.

                    Scene I: Romeo and Juliet's conversation.

[Enter Romeo and Juliet]

Romeo:
Speak your mind. You are as worried as the sum of yourself and the
difference between my small smooth hamster and my nose. Speak your
mind!

Juliet:
Speak YOUR mind! You are as bad as Hamlet! You are as small as the
difference between the square of the difference between my little pony
and your big hairy hound and the cube of your sorry little
codpiece. Speak your mind!

[Exit Romeo]

                    Scene II: Juliet and Ophelia's conversation.

[Enter Ophelia]

Juliet:
Thou art as good as the quotient between Romeo and the sum of a small
furry animal and a leech. Speak your mind!

Ophelia:
Thou art as disgusting as the quotient between Romeo and twice the
difference between a mistletoe and an oozing infected blister! Speak
your mind!

[Exeunt]

Matrix67收集整理
转贴请注明出处