segunda-feira, 19 de setembro de 2011

Solução do teste para o #GDD2011 Brasil

Já estou atrasado com o post, mas não podia deixar de postar o algoritmo que fiz para resolver os problemas do teste do Google Developer Day 2011, que aconteceu em São Paulo / SP / Brasil no dia 16 de setembro de 2011 (post em breve). Foi feito em Actionscript 3.0, mas a lógica se aplica em qualquer linguagem.

Se não me falha a memória, foram 4 problemas que tratavam de busca (data mining), ordenação e entrelaçamento de dados para obter alguns resultados, como a quantidade de algum tipo de palavra no idioma “Googlon”.

   1: package
   2: {
   3:     import flash.display.Sprite;
   4:  
   5:     import mx.utils.StringUtil;
   6:  
   7:     /**
   8:      * Classe que resolve o teste do Google Developer Day 2011.
   9:      * Teste: Idioma Googlon.
  10:      *
  11:      * @author Idemax Green
  12:      *
  13:      */
  14:     public class GoogleDeveloperDayTest extends Sprite
  15:     {
  16:         public static const ALPHABETIC_ORDER:String = 'kxwbrjqnclftdvgspmzh';
  17:         public static const DIVISION_RATE:uint      = 4;
  18:         public static const FOO_LETTERS:Array       = [ 't', 'x', 'l', 'q', 'b' ];
  19:         public static const MIN_BEAUTY_NUMBER:uint  = 450058;
  20:         public static const PREP_LENGHT:uint        = 5;
  21:         public static const TEXTO_A:String          = 'tggrsx mgwbqj ntz bqmbgxjd mgxq dgcvqh jjqnz cbl wsfl tfjzvb swmhnhtv nkzkw xhs tntkv xwlpc mfvcd hndkxm htvhk nrlnjdvm nxbl dlnwwffp ctjdxvk nsckd zgjxhjs dhwr knz hfhlgs wcpb kdl tzcjhxxr fmkw bqvkvbg ftwn tbwkwwq ktgfdbvr gcg ndhhjx wcrgh qpnrzsb rblbtvcl kdhstzxf mmb gxpdbqn xsvc psmczj bksgtj rbxq qnqt phbcfsrn zghpnwgs kjtk hnjg hjrhd ctsrqlzh wmtdpqb twftgkn xldnbw bzx slxvwnlz qrwhfp wptjzv hqdwfzk jgvzv fkhzhdn hmm vmdvj rjkwlc sctjv pglgfjq gllsngdw sblfcgq rpk hntr kjvwktz kcgv spcm fngvmmvc tcpstwpw fkzjrdf bqp jvmhm tznfnx smhjvlfw nhs bhkbp wdfspf gtbw jcgd vjlcs nhlrlms jrlhld rlbjbd mxc gzlp dmhxhqmd qjw xzk rqwvbqnj zdq pwpvp vgwmsc wbmndzb bgpfhv pwr lpdnjvlw jspsc vhtwvvfk tclfdpx zkbxbjkf jpnzg rmxrhjc vzhtz qsxc bqkz nmxgph llfktcb lzbfgvq krvtzxwp mfffltg kgtgmjg zqmd lsqvts tflfpxpj kmnnkc cdv bbr tdx qlsjbd ghhf kxv ntxbl kcrv djhhq rxmdvvmx zxwtdwt scsz xhzth klj blqd wsdhhq vghgn zsrtj jdj bsb kdwt jdxflvtk qnrkfxms cjnczb nvdxrkdd qkkdfl wtjmz ztvc cjh wggk jsrfbkkz hdxzjv qfztnpt hvjvl nxzdlsk mld spmqqt qtqmmk lqsbtxdc mbcvdc cns gxsph mczsfp qfdxcgj tgzd pfrv nngtzw vsrcfp gzbjvb xrngbhkj sbqlm qvvdlzj skwzl kvmt dzqprrrv ltw hgb nsfqdd nqn dfwqsmvx pcffw sxwm wfskvtw mvd zxm zkstgfbf dgw qcjpfrxm ccf hzrkd hmqnhd fjsvsvg jlhr xqdnf tlgkkc hrbs qhjzwb dhldj sfnhpdwj nnwqw wkgjkkzg dljkklt cvtvwc hwkzhdpn mqbb jqldxxtd rwjxcg kwppwjk zfz kcfzzn mngnnn dwjn lcsr tjw fkzzt tvwlcs gjpcbsnh btkpcrsl wbvp nkvpxsb ppcqw vfnj srsbpfd wwthnbf stxzj sdvzr bmwrn pxsdg wqrhzdk pfhfjjsz cljgzd sfxcpfm bsr pdrvv sfmsplkr ttcqtt zfsbrqc mbb dqpj kbkvhvf twcpdkn qrnlkdfp mnthnbrq hhc dsjhf lmgfpdfh nbw fzmmmh vtf svx jbpmdk pnhfzj wfsj ckfq qlnsd lwtc tkbvldl hbb bln sdbdwrp hkf mzck kdwwvfl bhs pngqd mbwpntp cbzgr swtkzwr nmscdnz vchshj bjlxfkcx klkwr xgzslfbs dmfhk phndxpbh nqmdgx xrrlxpm lqdv dtnv xfmt kdv nzsh qtznd xqwwc hxwrbmr dmw wpg pgmg tgcvgsss fhrlgsgx pmjn qpsxml skjh nlrntbh fgrcq dbdwc zvkzjmm dkhcgk mkf brfhcb vhw rqzqtdq mkdmd xlnfj vpshssp wbxsjj qdmkk fxpvk xfrh tqlg gzthqc cbglgsl kjvbssp wdjpgh hmmgqftc jtrvfdb grr qsvl zfkzw scm gxb vqzmwln rdktr mfltpnd sdddgjjr fvbbtlw xchlrr jkfxqwb ssktjcl mdxmbk rvgf vlrnskph rvhhf xjrfslt khb mknx sflrvsj gjx ncvg mxlwrvfx kpwd tkchp slwvcmzf ghrctf kbsm qknh htxfqq njwld mhj wmcgbs nlpsjg wnr wxd bgqkplw cgfcf ktz gnf jklz fwn gzfgrrs whng nvg xcnnsnrc tzgbls cwbpq zhpxqh wxxnpql tffdcgt jmlps mslrwcj shb wgbpbqb mlfqwcf fqq qwnbpt fmlbmxbx nrftsbmg mkmnph zktxzfh nbdd skcqbjwq wlhhvws lgqnqz fcns hmd wcrz xdg zbkn kkfps bddg txssxvxz lwbtfqkl kwlbznww wsrqqz kpq mkbclrz tvwpbn nspgpv zcvtmbfb rcfwt kwrqw gbplc bqqc cvz rmnf kktjlshd mgkv mckh rjjdrnl plmvssf kbl kmwrlc tgntgzkh nlxwh vjnv qbhdzkc qdthzxrk sdc fdst drhszzqs zqbdcjtt ktw gnrfb zxdgzpc mqxxnkhp kznmrm pgkqtd ddzqhndw xcqzptl dmj fxt fpgnf cwvsjnl swhqp cscqgl pcdfrg kvbtwmrx vscbwhsr gkf gnkch rfstrvgh ndhj hsvmnt vrj rbvnrkgj cqlwnf tlqfbpcr qhfqvqfm qnkflbxx tqqkvhvn vgqwhdqj dmrknp rzq hxl mqfrxx rwhlzgh rgkb jsqr mkr brsvj nhdqcbd xvbj qphqm rck mkkkd pvbbqstq ksrr qxnj ngq jkdlt rzjctxnf fvvs wdbbk vzg bnhxdv bqh qtvvdvsr qtwjpg vmh mdvqbt tpc kzhcgbf fbdrvcqn wtppcp whgx jtgd tsbvk gtjjptqt lpprdxs mdnjrwnl zcqwdc mcvbwlrs zqj csp vdqvmnz nvfvdk kcpz tws rpphccs dklt lzlx xnphn glnpjbwg cvs zskbkt mhhvcp kvjvgvk tqtmw mwppnzm mqzb nmhpngbl tpmct bxqjthp tlkkcjwt drfp dmdxcflq gsvkbv sqdbb dfn kzgwlm wrlx kfcjqm fgtjp mvqvthmq qqv rwhzl pvkzvjg cvwb ljtj lhqk dsgsf dglvth mbdh wbmwrs znsp dxf rzxbd rkttmqq bdgcfm lwfth dxfrk nkznw dbkvhnnm lxsxj nfwqh glkxtlw whw khlnk fxjjjcqt lfxwkktx nnzpnjk zrd bmrdcj wdnfm rxcrs jshfhxcn ntcmvgkw jjvlvcs hgnf tngkhct jmnjwtn dslcvq cxbbw grpnmj txvgjb hbqsf wksps qlgndfdb trls kqmdp gpdqljn xbdfkn vfwhqlxn vtl cmkkz vbtbfgbq rqqn bcpcldh djv gqdzmqcl rjmxrdp brj xdkwbs lkv czjd xdsm znxnx jch vvtnbw qbnt tdwsgsm kxdtvlm sxgmvbd xcdrkbs vgw zsbl';
  22:         public static const TEXTO_B:String          = 'wdqxrzb qllwjm hdkdbxz hvx grz hddfzlww ljcdfmdh fzxmqkm wsgmmqhl nwhzdx nbtlsr gfmctrnv xzxnwqfj nfbmw wcbffcdx cvnxt wgcchjj slm ptpphrjq lqwb qxvvg bzbfwjf rbvdxjjt fgz dkb bfnlltf rhg qmtjxbn swsqrtj rfnqqb kpthxd vcs fpmndfl tsz ggdkj hbqq vpdzdw zgb bhvgxkg fbrz gdvdtrfc ntsqmj pjlgqfc cmgmgs vgqqf jmnpw psn tgp rlwqz rmvh fmnqt xdgqkrqx xljd xgf jms mbrhxn txlsm vbstp bqmnk wtt dpmcrs zxg dkkwqj vzjfk zllhljtv fktjs npjkbsm nzqx nbnf vxx mgtjrq fwlqsj wqh gmdxqc sstpd bkjgccjw cmjsg qnldnjh tqlnjk dvgddq zdn zdbbswf xtbzgbvl rkfptf wckfxcs wlrdwwt wqvmx glx gktn rnzbh mdkbm rvj fgm wsvrbv nlcgzkht zqhzjnrb frsdwlqb hgt rhhdsjrt xwsnkncm xrg vvndxblq tjbvpq mqhbr mlsnfv xwxrvthc srd dhx jddtkcft cqlfnkh gbgkz jjpsv qmjb gzfrsn nhw cpsn cnvtln vhsdvsv dgkgnzhp fsh ndlwkc nxc bchztg cdwvnw gnk xcmh kll xkg mnsp hnhjvzw mlpzx mrg bjpbht fmn sqch wwbnrz npch vxtt bqzqzqjn dtnlgbv bhfvtzhn fqjj flwdvxs dhhwppjq dbxln kxtcj kqjcbt cvzsk jjxwr xwhb bjhl ffknnrk dgjszhg qng frcnhmwp fttnpb vxf xtg tkx kjl bshjwh fmjwt vgqcdwv pmpzrkrs csqh vkwgfrv clvcwxd snwq ntqwnl dsxqmsr kqsq lxt qsfvplt xrfrcgb xhfsv mkkgdvvr pgrtk skwzsczs psxcwk ssjdbmdp vhtdb qmct mmpbff cxbw zzmvbg lxjzjt vxnqkbjb dmzmdnjp nmmshg rrpkr xsdcglh gzfs npk hbtslj kbnxc ckvvqn dqtxd dtvf vwvtnk vdcxmwv frs bbj rnk njmdl pqvp qbqjv lwkfv mtql dbrjk vlvczxcj hcbjdvb qzjz qtrmr llnrgw wkcr lsf dvvdxq qfqxm lxpjgsl cldjgr smx tlddhr hbdgcj wtgl sbtk dvs nmf fgvw hzxhzzp jlv nzdthqvb jtd qnbzh jttlz btk nddfs bbm ztst gjkqxrvc wvmk sflzqlvd gxjnjqf xvvbfhl fgjfq gvsr vqrvzgw rhsvzx jbzdsjb vjnwv dxgdsq kmwb gxz pdkd kjpttmw xcsfjzwl zrnbwq ssvkwmjs xpf mmjbn pqxpcmj wnnkckx kqwjhzqv dgkfzlg scpkwxn tmqpn hnqcj xvgwb nvtwvxp lkx rqps tfpmd skqhhn mrp kjwghhtg vxmfjv qzkjlckz jrwn jhlxbvhm bcmcpzd tjzkxr qbccck dllp krpgfzgr bcnwwdj mndql scwvfljl blxdgcdv wflqjch fsbb nkhtm tkmzdkns lsm gptrp cvljzjsc wcjsrtl vzjvqxwh ctsw qms bxtzftl zzn vrkzdq qnp qwf brvfjwz ptpfpmf trkq rvlb jkw fvk cxvz tknwhxd lwhbjkpt fvhdv dcvghwrd rzj nvxv pdxr fgffl dtkccb pgvbl qrfrc cswrgm jjp kjm drsdvgvw kfmxswc sqfjljmq nhts fxhzlv wlwhg xlpb fhmnm jzw cpkpl xpqm bkldlgz hqkgn gkqkv nnb dqjww ljt ktlvbklv sclgl flbhwmtm xst njrt pmdkhtpf sjp qbfmmtr bwkxzwch fvbfk mkck pxppts vmjqmtkp dnljwhc hzfnpr gtvjsvbv fmkvfdxz xspk jmpdwkb bpvqjczf jnlfsr dhqbtksx kppnvwr fqztnfth crhn fvpncjt mndzmvl mkghv xmfrkxr mnxh glksf ndcqx qbks dgczbp cxvkvv lqtmsz rgjhkdf vxwpsk bzqxfg gbmffl mqdwxbt zwtgkk llptgx xrphkj dksjdxh mpkgxk vxtfbzzh blsp gmnqmqf jxlrpzfm dzssrvww zjvlrrbm vvdmkgkc hpmcx pdnbwlnc rhkm nzhhk mtjns pxvql bzq djjxsphc zgg lmbkfdx mvmfgctp tnbrqlbw sqmlnwm mfq vslsgqw vztrfv kmrjthfh lxch hkpm zftkw jqxtdz mlldss jscb tfdzlbp mwqkm qxmtklld fjvfshz btcghfk rzg gzg jnqfjzv fpvxs kjm skfrcr cttw jnbckcs qjjkbpw wcdl vllh ftnxlgq cbxb xhjzf tksszmw cgnd bmgjr skbbjjcf zdpd svrfvg mjtpcffx kwprzp fqmrmpsg nxsqknpg plpjrqh hvxc rnrld xtjzbpb rrmvbhlg chlzhvqz nfxb rbcshq vbp zznwh rkx kzldq xfkkcdtz qxr xschzw jckksdg xgff xxf nmvs fvswsf mnjzgnbn pwgj dxczqc kbzx lgnng fltrzbtf blzkgkdt kpqfkll ddjhh rfhpb mkqh rsllxg zvfbmg vkxtgpg hfx rlr pnhftxf jsmbl pllhql qzzswwjd ddw gsvm xjnlv cqlp hlznnxww wlnr hfhvsm dqht gkffmvkl qttx rcg xxp kcfpdldp ngrmpfl rqlh mdcxlhlt nbpk wtpdlgwh shskvrd mmtqcw bjgnf xrmvbt fvfk gkr sfhrlbt lpzlc brmkgpl zjwwfdl jlrzm dtmrkf qkz vzbj fmbq lpx lwg gtmrdrw bsgspb wrgjb xdcf bvdrgrdt mtcxtj gxmmcz hhvq rsfvhnq hltmt ctn mxhtnpt cmlsmdpk gntldw bhb nqxphdst bln wtntr lkqc sjmmfgv wjmn mmtgp qmcwlt jrncczlq zrflnp qtvklvq zqwfdz mgkr tltwhpjh wppd ngkhpx hrj ncn cczvpt bjg xdnf cdfsmxz sspbfl jkkfl tdxmx txhnq hzqd cjsqn zztl qlrlt nvd sprhqfnf qvr lgcwb zbbvlh wqhx hzzqg zbfvmqmz gxvfxkz ghmswglt vzpqfk djtl gthhcpgw drfdnwt vmnfp smgxfw ghqr nhkn slw xndrgzx hwkz gwcbpbn dfmwvdc pghq zcrkvcm tjpv zsv ghbkbsrb bbvnlzvh wrdpxg mzbfcfx sfvbzp nvx zjdbw';
  23:         public static const VERB_MIN_LENGHT:uint    = 7;
  24:         public static const VOCABULARIO:String      = 'kkfps kktjlshd kxdtvlm kxv kwrqw kwlbznww kwppwjk kbkvhvf kbl kbsm krvtzxwp kjtk kjvwktz kjvbssp kqmdp knz kcrv kcfzzn kcgv kcpz klkwr klj kfcjqm ktw ktgfdbvr ktz kdwwvfl kdwt kdl kdv kdhstzxf kvbtwmrx kvjvgvk kvmt kgtgmjg ksrr kpwd kpq kmwrlc kmnnkc kznmrm kzgwlm kzhcgbf khb khlnk xwlpc xbdfkn xrrlxpm xrngbhkj xjrfslt xqwwc xqdnf xnphn xcqzptl xcnnsnrc xcdrkbs xchlrr xlnfj xldnbw xfrh xfmt xdkwbs xdg xdsm xvbj xgzslfbs xsvc xzk xhs xhzth wkgjkkzg wksps wxxnpql wxd wwthnbf wbxsjj wbvp wbmwrs wbmndzb wrlx wqrhzdk wnr wcrgh wcrz wcpb wlhhvws wfskvtw wfsj wtjmz wtppcp wdbbk wdjpgh wdnfm wdfspf wgbpbqb wggk wsrqqz wsfl wsdhhq wptjzv wpg wmcgbs wmtdpqb whw whng whgx bksgtj bxqjthp bbr brj brfhcb brsvj bjlxfkcx bqkz bqqc bqvkvbg bqp bqmbgxjd bqh bnhxdv bcpcldh blqd bln btkpcrsl bddg bdgcfm bgqkplw bgpfhv bsb bsr bmwrn bmrdcj bzx bhkbp bhs rkttmqq rxcrs rxmdvvmx rwjxcg rwhlzgh rwhzl rbxq rblbtvcl rbvnrkgj rjkwlc rjjdrnl rjmxrdp rqwvbqnj rqqn rqzqtdq rck rcfwt rlbjbd rfstrvgh rdktr rvgf rvhhf rgkb rpk rpphccs rmxrhjc rmnf rzxbd rzjctxnf rzq jklz jkfxqwb jkdlt jbpmdk jrlhld jjqnz jjvlvcs jqldxxtd jcgd jch jlhr jtrvfdb jtgd jdxflvtk jdj jvmhm jgvzv jsrfbkkz jsqr jspsc jshfhxcn jpnzg jmnjwtn jmlps qkkdfl qknh qxnj qwnbpt qbnt qbhdzkc qrwhfp qrnlkdfp qjw qqv qnkflbxx qnrkfxms qnqt qcjpfrxm qlnsd qlgndfdb qlsjbd qfdxcgj qfztnpt qtwjpg qtqmmk qtvvdvsr qtznd qdthzxrk qdmkk qvvdlzj qsxc qsvl qpnrzsb qpsxml qphqm qhjzwb qhfqvqfm nkvpxsb nkzkw nkznw nxbl nxzdlsk nbw nbdd nrlnjdvm nrftsbmg njwld nqn nqmdgx nnwqw nngtzw nnzpnjk ncvg nlxwh nlrntbh nlpsjg nfwqh ntxbl ntcmvgkw ntz ndhj ndhhjx nvfvdk nvdxrkdd nvg ngq nsckd nsfqdd nspgpv nmxgph nmscdnz nmhpngbl nzsh nhlrlms nhdqcbd nhs ckfq cxbbw cwbpq cwvsjnl cbl cbglgsl cbzgr cjnczb cjh cqlwnf cns ccf cljgzd ctjdxvk ctsrqlzh cdv cvwb cvtvwc cvs cvz cgfcf cscqgl csp cmkkz czjd lkv lxsxj lwbtfqkl lwfth lwtc ljtj lqdv lqsbtxdc lcsr llfktcb lfxwkktx ltw lgqnqz lsqvts lpdnjvlw lpprdxs lmgfpdfh lzbfgvq lzlx lhqk fkzjrdf fkzzt fkhzhdn fxjjjcqt fxt fxpvk fwn fbdrvcqn fjsvsvg fqq fngvmmvc fcns ftwn fdst fvbbtlw fvvs fgrcq fgtjp fpgnf fmkw fmlbmxbx fzmmmh fhrlgsgx tkbvldl tkchp txvgjb txssxvxz twcpdkn twftgkn tws tbwkwwq trls tjw tqqkvhvn tqlg tqtmw tntkv tngkhct tclfdpx tcpstwpw tlkkcjwt tlqfbpcr tlgkkc tfjzvb tflfpxpj tffdcgt ttcqtt tdx tdwsgsm tvwlcs tvwpbn tgntgzkh tgcvgsss tggrsx tgzd tsbvk tpc tpmct tznfnx tzcjhxxr tzgbls dklt dkhcgk dxf dxfrk dwjn dbkvhnnm dbdwc drfp drhszzqs djv djhhq dqpj dljkklt dlnwwffp dfwqsmvx dfn dtnv ddzqhndw dgw dgcvqh dglvth dsjhf dslcvq dsgsf dmw dmrknp dmj dmfhk dmdxcflq dmhxhqmd dzqprrrv dhwr dhldj vbtbfgbq vrj vjnv vjlcs vqzmwln vchshj vlrnskph vfwhqlxn vfnj vtl vtf vdqvmnz vvtnbw vgw vgwmsc vgqwhdqj vghgn vsrcfp vscbwhsr vpshssp vmdvj vmh vzg vzhtz vhw vhtwvvfk gkf gxb gxsph gxpdbqn gbplc grr grpnmj gjx gjpcbsnh gqdzmqcl gnkch gnrfb gnf gcg glkxtlw glnpjbwg gllsngdw gtbw gtjjptqt gsvkbv gpdqljn gzbjvb gzlp gzfgrrs gzthqc ghrctf ghhf skwzl skjh skcqbjwq sxwm sxgmvbd swtkzwr swmhnhtv swhqp sbqlm sblfcgq srsbpfd sqdbb sctjv scsz scm slxvwnlz slwvcmzf sfxcpfm sfnhpdwj sflrvsj sfmsplkr stxzj sdbdwrp sdc sdddgjjr sdvzr svx ssktjcl spcm spmqqt smhjvlfw shb pxsdg pwr pwpvp pngqd pnhfzj pcffw pcdfrg plmvssf pfrv pfhfjjsz pdrvv pvkzvjg pvbbqstq pgkqtd pglgfjq pgmg psmczj ppcqw pmjn phbcfsrn phndxpbh mkkkd mkbclrz mkr mknx mkf mkdmd mkmnph mxc mxlwrvfx mwppnzm mbwpntp mbb mbcvdc mbdh mqxxnkhp mqbb mqfrxx mqzb mnthnbrq mngnnn mckh mcvbwlrs mczsfp mlfqwcf mld mfltpnd mfffltg mfvcd mdxmbk mdnjrwnl mdvqbt mvqvthmq mvd mgkv mgxq mgwbqj mslrwcj mmb mzck mhj mhhvcp zkbxbjkf zktxzfh zkstgfbf zxwtdwt zxdgzpc zxm zbkn zrd zqbdcjtt zqj zqmd znxnx znsp zcqwdc zcvtmbfb zfkzw zfsbrqc zfz ztvc zdq zvkzjmm zgjxhjs zghpnwgs zskbkt zsbl zsrtj zhpxqh hkf hxwrbmr hxl hwkzhdpn hbb hbqsf hrbs hjrhd hqdwfzk hnjg hntr hndkxm hfhlgs htxfqq htvhk hdxzjv hvjvl hgb hgnf hsvmnt hmqnhd hmd hmm hmmgqftc hzrkd hhc ';
  25:         public static const VOCABULARIO_LEN:uint    = ALPHABETIC_ORDER.length;
  26:  
  27:         /**
  28:          *
  29:          * Construtor.
  30:          *
  31:          */
  32:         public function GoogleDeveloperDayTest()
  33:         {
  34:             super();
  35:  
  36:             trace( 'Existem ' + countPrep( TEXTO_A ) + ' preposicoes no texto A.' );
  37:             trace( 'Existem ' + countPrep( TEXTO_B ) + ' preposicoes no texto B.' );
  38:  
  39:             trace( '\nExistem ' + countVerb( TEXTO_A ) + ' verbos no texto A.' );
  40:             trace( 'Existem ' + countVerb( TEXTO_B ) + ' verbos no texto B.' );
  41:  
  42:             trace( '\nExistem ' + countVerbFirstPearson( TEXTO_A ) + ' verbos na primeira pessoa no texto A.' );
  43:             trace( 'Existem ' + countVerbFirstPearson( TEXTO_B ) + ' verbos na primeira pessoa no texto B.' );
  44:  
  45:             trace( '\nVocabulario ordenado sem palavras duplicadas: ' + orderVoc( VOCABULARIO ));
  46:  
  47:             trace( '\nNo Texto A, ha ' + countBeautyNumbers( TEXTO_A ) + ' numeros bonitos distintos (atencao!).' );
  48:             trace( 'No Texto B, ha ' + countBeautyNumbers( TEXTO_B ) + ' numeros bonitos distintos (atencao!).' );
  49:         }
  50:  
  51:         /**
  52:          * Método que compara a predecessor e sucessor do vocabulário.
  53:          *
  54:          * @param $a Antecessor.
  55:          * @param $b Sucessor.
  56:          * @return -1: a < b
  57:          *          0: a = b
  58:          *          1: a > b
  59:          *
  60:          */
  61:         private function compareVerbFunction( $a:String, $b:String ):int
  62:         {
  63:             var rtn:int         = -1;
  64:             var aNumeric:String = getGooglonWordAsHash( $a );
  65:             var bNumeric:String = getGooglonWordAsHash( $b );
  66:  
  67:             if( aNumeric > bNumeric )
  68:                 rtn = 1;
  69:  
  70:             return rtn;
  71:         }
  72:  
  73:         /**
  74:          * Conta quantos números bonitos o texto tem.
  75:          *
  76:          * @param $text Texto.
  77:          * @return Quantidade de númeoros bonitos.
  78:          *
  79:          */
  80:         private function countBeautyNumbers( $text:String ):uint
  81:         {
  82:             var rtn:uint    = 0;
  83:             var words:Array = removeDuplicatedWords( $text.split( ' ' ));
  84:             var len:uint    = words.length;
  85:             var wNumber:uint;
  86:  
  87:             for( var i:uint = 0; i < len; i++ )
  88:             {
  89:                 wNumber = getWordNumber( words[ i ] as String );
  90:  
  91:                 if( wNumber >= MIN_BEAUTY_NUMBER && wNumber % DIVISION_RATE == 0 )
  92:                     rtn++;
  93:             }
  94:  
  95:             return rtn;
  96:         }
  97:  
  98:         /**
  99:          * Conta a quantidade de proposições no texto.
 100:          *
 101:          * @param $text Texto.
 102:          * @return Quantidade de proposições.
 103:          *
 104:          */
 105:         private function countPrep( $text:String ):uint
 106:         {
 107:             var rtn:uint    = 0;
 108:             var words:Array = removeDuplicatedWords( $text.split( ' ' ));
 109:             var len:uint    = words.length;
 110:  
 111:             for( var i:uint = 0; i < len; i++ )
 112:             {
 113:                 if( isGooglonPrep( words[ i ] as String ))
 114:                     rtn++;
 115:             }
 116:  
 117:             return rtn;
 118:         }
 119:  
 120:         /**
 121:          * Conta a quantidade de verbos no texto.
 122:          *
 123:          * @param $text Texto.
 124:          * @return Quantidade de verbos.
 125:          *
 126:          */
 127:         private function countVerb( $text:String ):uint
 128:         {
 129:             var rtn:uint    = 0;
 130:             var words:Array = removeDuplicatedWords( $text.split( ' ' ));
 131:             var len:uint    = words.length;
 132:  
 133:             for( var i:uint = 0; i < len; i++ )
 134:             {
 135:                 if( isGooglonVerb( words[ i ] as String ))
 136:                     rtn++;
 137:             }
 138:  
 139:             return rtn;
 140:         }
 141:  
 142:         /**
 143:          * Conta a quantidade de verbos em primeira pessoa no texto.
 144:          *
 145:          * @param $text Texto.
 146:          * @return Quantidade de verbos em primeira pessoa.
 147:          *
 148:          */
 149:         private function countVerbFirstPearson( $text:String ):uint
 150:         {
 151:             var rtn:uint    = 0;
 152:             var words:Array = removeDuplicatedWords( $text.split( ' ' ));
 153:             var len:uint    = words.length;
 154:  
 155:             for( var i:uint = 0; i < len; i++ )
 156:             {
 157:                 if( isGooglonVerbFirstPearson( words[ i ] as String ))
 158:                     rtn++;
 159:             }
 160:  
 161:             return rtn;
 162:         }
 163:  
 164:         /**
 165:          * Transforma a palavra em um hash (0123456789abcdefgh...) com base no tamanho no alfabeto.
 166:          *
 167:          * @param $word Palavra nativa (Googlon).
 168:          * @return Hash traduzido.
 169:          *
 170:          */
 171:         private function getGooglonWordAsHash( $word:String ):String
 172:         {
 173:             var rtn:String = '';
 174:             var len:uint   = $word.length;
 175:  
 176:             for( var i:uint = 0; i < len; i++ )
 177:                 rtn += ALPHABETIC_ORDER.indexOf( $word.charAt( i )).toString( VOCABULARIO_LEN );
 178:  
 179:             return rtn;
 180:         }
 181:  
 182:         /**
 183:          * Retorna o valor númerico da letra no alfabéto.
 184:          *
 185:          * @param $word Palavra nativa (Googlon).
 186:          * @return Valor numérico da palavra.
 187:          *
 188:          */
 189:         private function getWordNumber( $word:String ):uint
 190:         {
 191:             var rtn:uint  = 0;
 192:             var wLen:uint = $word.length;
 193:             var exp:uint  = 1;
 194:  
 195:             for( var i:uint = 0; i < wLen; i++ )
 196:             {
 197:                 rtn += ALPHABETIC_ORDER.indexOf( $word.charAt( i )) * exp;
 198:  
 199:                 exp *= 20;
 200:             }
 201:  
 202:             return rtn;
 203:         }
 204:  
 205:         /**
 206:          * Retorna se há uma letra M na palavra.
 207:          *
 208:          * @param $word Palavra.
 209:          * @return TRUE / FALSE.
 210:          *
 211:          */
 212:         private function hasMLetter( $word:String ):Boolean
 213:         {
 214:             var rtn:Boolean;
 215:             var len:uint = $word.length;
 216:             var letter:String;
 217:  
 218:             for( var i:uint = 0; i < len; i++ )
 219:             {
 220:                 letter = $word.charAt( i );
 221:  
 222:                 if( letter == 'm' )
 223:                 {
 224:                     rtn = true;
 225:  
 226:                     break;
 227:                 }
 228:             }
 229:  
 230:             return rtn;
 231:         }
 232:  
 233:         /**
 234:          * Retorna se a palavra Googlon é foo.
 235:          *
 236:          * @param $letter Palavra.
 237:          * @return TRUE / FALSE.
 238:          *
 239:          */
 240:         private function isFooLetter( $letter:String ):Boolean
 241:         {
 242:             var rtn:Boolean;
 243:             var len:uint = FOO_LETTERS.length;
 244:  
 245:             for( var i:uint = 0; i < len; i++ )
 246:             {
 247:                 if( $letter == FOO_LETTERS[ i ])
 248:                 {
 249:                     rtn = true;
 250:  
 251:                     break;
 252:                 }
 253:             }
 254:  
 255:             return rtn;
 256:         }
 257:  
 258:         /**
 259:          * Retorna se a palavra Googlon é uma preposição.
 260:          *
 261:          * @param $word Palavra.
 262:          * @return TRUE / FALSE.
 263:          *
 264:          */
 265:         private function isGooglonPrep( $word:String ):Boolean
 266:         {
 267:             var rtn:Boolean;
 268:  
 269:             if( $word.length == PREP_LENGHT )
 270:             {
 271:                 var lastLetter:String = $word.charAt( $word.length - 1 );
 272:  
 273:                 if( !isFooLetter( lastLetter ))
 274:                     rtn = !hasMLetter( $word );
 275:             }
 276:  
 277:             return rtn;
 278:         }
 279:  
 280:         /**
 281:          * Retorna se a palavra Googlon é um verbo.
 282:          *
 283:          * @param $word Palavra.
 284:          * @return TRUE / FALSE.
 285:          *
 286:          */
 287:         private function isGooglonVerb( $word:String ):Boolean
 288:         {
 289:             var rtn:Boolean;
 290:  
 291:             if( $word.length >= VERB_MIN_LENGHT )
 292:             {
 293:                 var lastLetter:String = $word.charAt( $word.length - 1 );
 294:  
 295:                 rtn = isFooLetter( lastLetter );
 296:             }
 297:  
 298:             return rtn;
 299:         }
 300:  
 301:         /**
 302:          * Retorna se a palavra Googlon é um verbo em primeira pessoa.
 303:          *
 304:          * @param $word Palavra.
 305:          * @return TRUE / FALSE.
 306:          *
 307:          */
 308:         private function isGooglonVerbFirstPearson( $word:String ):Boolean
 309:         {
 310:             var rtn:Boolean;
 311:  
 312:             if( $word.length >= VERB_MIN_LENGHT )
 313:             {
 314:                 var firstLetter:String = $word.charAt();
 315:                 var lastLetter:String  = $word.charAt( $word.length - 1 );
 316:  
 317:                 rtn = isFooLetter( firstLetter ) && isFooLetter( lastLetter );
 318:             }
 319:  
 320:             return rtn;
 321:         }
 322:  
 323:         /**
 324:          * Ordena alfabeticamente as palavras Googlon e remove as duplicadas.
 325:          *
 326:          * @param $words Palavras
 327:          * @return Palavras ordenadas sem duplicidade.
 328:          *
 329:          */
 330:         private function orderVoc( $words:String ):String
 331:         {
 332:             var words:Array = removeDuplicatedWords( $words.split( ' ' ));
 333:  
 334:             words.sort( compareVerbFunction );
 335:  
 336:             return StringUtil.trim( words.join( ' ' ));
 337:         }
 338:  
 339:         /**
 340:          * Remove as palavras duplicadas do vetor.
 341:          *
 342:          * @param $words Vetor de palavras.
 343:          * @return Vetor sem palavras duplicadas.
 344:          *
 345:          */
 346:         private function removeDuplicatedWords( $words:Array ):Array
 347:         {
 348:             var word:String;
 349:             var j:uint;
 350:             var jLen:uint;
 351:             var equalFound:Boolean;
 352:             var len:uint  = $words.length;
 353:             var rtn:Array = [];
 354:  
 355:             for( var i:uint = 0; i < len; i++ )
 356:             {
 357:                 word = $words[ i ] as String;
 358:                 jLen = rtn.length;
 359:                 equalFound = false;
 360:  
 361:                 for( j = 0; j < jLen; j++ )
 362:                 {
 363:                     if( word == rtn[ j ] as String )
 364:                     {
 365:                         equalFound = true;
 366:  
 367:                         break;
 368:                     }
 369:                 }
 370:  
 371:                 if( !equalFound )
 372:                     rtn.push( word );
 373:             }
 374:  
 375:             return rtn;
 376:         }
 377:     }
 378: }

Se encontrarem algum bug, comentem abaixo…