Escreva um Hangman Solver


28

Você precisa escrever um solucionador de forca. Testando contra esta lista de palavras em inglês [1] , vence o solucionador que resolve o maior número de palavras, com o número total de palpites incorretos sendo o desempate. Todas as palavras da lista de palavras serão testadas em ordem aleatória.

[1]: esta lista de palavras é retirada daqui , os números são removidos, as palavras com comprimento 1 ou com caracteres não alfabéticos são removidas e as 4096 palavras únicas mais frequentes são escolhidas como esta lista de palavras.

Os detalhes:

Seu programa irá interagir com o programa do jogo, que fornecerá a você os caracteres sublinhados e as letras adivinhadas corretamente. Seu programa dará a entender seus palpites e deve inferir a partir da entrada se o palpite anterior estava certo ou errado. Depois de estar errado por 6 vezes, seu programa perde. Seu programa deve estar pronto para o próximo jogo após o término de cada jogo (após vitória ou derrota).

O tamanho do seu código deve ser estritamente menor que 2048 bytes, e seu programa não deve usar recursos externos (incluindo, entre outros, o acesso à lista de palavras no armazenamento local ou na Internet).

Exemplo : (a entrada é precedida por >aqui apenas para esclarecimento - ela não está realmente presente na entrada)

>_______         // 7 underscores
a                // Now you wait for input again
>_a___a_
e
>_a___a_         // Implies that your guess is wrong
>_____           // new round, this will be given ONLY IF you already have 6 losses

Suponha que você esteja errado por 6 vezes, você receberá uma entrada final, o que implica que seu palpite está errado, e seu programa deve estar pronto para iniciar uma nova rodada (por exemplo, faça outra entrada).

Se você ganhar,

>_angman
h
>hangman
>_____           // new round

Depois de saber que você ganhou (porque a entrada não possui sublinhados), você deve estar pronto para aceitar a próxima rodada.

Seu programa deve terminar quando receber uma entrada END.

Se o seu programa não for determinístico (depende de aleatoriedade, pseudo-aleatoriedade, hora do sistema, temperatura ambiente, meu humor etc.), você deve declarar explicitamente isso na sua inscrição e sua pontuação será obtida 10 vezes (por mim, a menos que seja instruído de outra forma) e média.

Nota : se você usa idiomas como python, libere explicitamente seu stdout após cada declaração de impressão.

O programa do jogo é o seguinte (crédito para nneonneo ):

import sys, random, subprocess

proc = subprocess.Popen(sys.argv[1:], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
def p(x):
    proc.stdin.write(x+'\n')
    proc.stdin.flush()

wordlist=[]
f=open('wordlist.txt', 'r')
for i in f:
    wordlist.append(i[:-1] if i[-1]=='\n' else i)
# wordlist=[i[:-1] for i in f]
random.shuffle(wordlist)

score=0
totalerr=0

for s in wordlist:
    s2=[]
    for i in s:
        s2.append('_')
    err=0
    p(''.join(s2))
    while err<6 and '_' in s2:
        c=proc.stdout.readline().strip()
        nomatch=True
        for i in range(0, len(s)):
            if s[i]==c:
                s2[i]=c
                nomatch=False
        if nomatch:
            err+=1
            totalerr+=1
        p(''.join(s2))
    if err<6:
        score+=1
p('END')
sys.stderr.write('score is '+str(score)+', totalerr is '+str(totalerr)+'\n')

Uso: python ./game.py [yoursolverprogram]

Exemplo: python ./game.py ruby ./solver.rb

Isso deve funcionar como o antigo programa de pontuação, mas não depende de pipes nomeados, para que possa funcionar em outras plataformas. Consulte o histórico de revisões se você estiver interessado no antigo.


Quais ambientes de tempo de execução você terá? Posso usar o node.js?
aebabis

Se uma submissão falhar em uma palavra que não adivinhou letras e a próxima palavra tiver o mesmo comprimento, será impossível determinar apenas a partir da entrada que seis tentativas decorreram. Portanto, os envios devem armazenar o número de palpites como estado.
laindir

1
"Se o seu programa não é determinístico (depende de aleatoriedade, pseudo-aleatoriedade, hora do sistema, temperatura ambiente, meu humor etc.), você deve declarar explicitamente isso na sua inscrição e sua pontuação será obtida 10 vezes (por mim, a menos que seja instruído de outra forma) ) e média. " Seu próprio programa de teste não é determinístico, então acho que seria justo continuar assim com todos os envios?
Martin Ender

1
@ace Não se o meu envio lembrar quais palavras já foram usadas. ;) Suponho que se enquadre na categoria "seu programa depende da pseudo-aleatoriedade" ... embora seja a pseudo-aleatória no seu programa de teste. : D
Martin Ender

2
@ace: Posso sugerir o uso subprocessde um fifo externo para dirigir o jogo? Dessa forma, o código funcionará para outros sistemas operacionais (por exemplo, Cygwin no Windows). Aqui está game.pymodificado para usar subprocesspara iniciar o programa nomeado na linha de comando: gist.github.com/nneonneo/d173f8888e1ea0c6fe37 . Use-o como python game.py <program> [args], por exemplo python game.py python hangman.py.
N11

Respostas:


1

Python 2, pontuação = 2111

Corra com python -u. (Para testar com o controlador fornecido python ./game.py python -u ./solver.py.) São 2044 bytes de código + 1 para -u= 2045 bytes.

I=raw_input
a=I()
while'^'<a:
 c=g=''
 while len(set(g)-set(a))<6and'_'in a:
	m=1879
	while c in g:c='eunotitihencatpangnaottoesthesdoeitmbolocepnngcbelympvhanlrarnnccinatceaesdabceatelittlvuumineiltlatrnrttnomnnlnaildplttryliaxgtssclhemngfrssioninssenryinoeovortpcntapeetedlrruitardooiitacteutrsotdsoanedytsacnstshesmoeloluaiaceaceuhlortnegveprreanslrraneioeitslincssdsisuosycmieiebrinncrueoinytnabatepcciamenitnisecgaannehiphanotntnorvrvpcaddcdiittdnnieirsytescdeaaorfrerroleomdaeripmaandrgndipaimesctrsliavnopstmhiagamnimnlaaieceotlarscnbvnssvtaslplpisoiicinynriilirelaiohllvlndohenossvildgerltgterisahcreridsctnedainmteooeelnppeiemitceciyndetgfltrtsnatlrasrnsreiueletunsttainrctreydcpmiieecpedarulcaosoiulinrtpinoopptcpuarnioredabtilsnleoonslmltircninloaludrltrviocsatcgratduioeietnseaidltmmryalaaaorbctaglnlatatiosnloettuongaetlndesicircelunoeaofaciunhcdnnteeadtaadteairceneangugipadcrhaetftoloilisesaeaishtcinemcoleiibloyuoeiupovgtrccttsuttialnnnncatbamtrrndtperieonsavseoalncrrvvmctdmornstsunilnrscariranagloeoeciteptiplctpmadtnertslioractotlairneutorccaocletedoaammiiaurcadgdsmtmooaefmhedetvoelmoaemoaacoeieneislsaccllsunacnnspaomtdpnioocposrocniciicounnatosuvrsrodreacloapcansrsnrohlnotpiiptdneauaaatorofaatsnigiioegloreraiipaitnsssrststetomtoneifencntopxmstsruiosgopanriapiapelteeeelraaeeeipavauptneaalinnrlgipgoteienenrnfdmorouslpcaprmaeusnnnclltpcasrsitiuaictigsarsdenteetrtelnrecurupmautosotrssnisrdsnnulisrgomnpeatyotioipetalyanluatsoteoytirsmssyeatpryrtfclfnttniscloeuiaerasniracntfglaylurotngoaesuetillrrldnranosteldmpooonticteaprdcdmoecaafnftaivsmtrtlrpigcrnodueusmyepeotpnotltalgtltlvyhspphrtaliemyrtehrrdeiesoiiteptsptintnypmoinspsgiocacurarpruiardmnmrpgtpnoimtlsonpacrsnenpcinantayvryumpncyaelnrtrsisrdmnspgmarlttttptitsmeipuaervntgcunnncrtrnnitbltarssmaircptrenrerrerpceoiedchecefbrttutbumnbsnoeitaenutetreccosttofcdtgslgeaoacmicuiotelornahmticcsrdswaoignancoelrrsarnrnrrptiyadetilcricnasnoasenpstasiopdtnossrccllsoelirtfarrioemaeosioaeorcaesfnfsthklcsrdhlwakl'[int(a.replace('_','1'),36)%m];m-=6
	print c;g+=c;a=I()
 a=I()

Resultado

score is 2111, totalerr is 20751

Como funciona

O programa substitui todos os _s por 1s no estado atual, trata o resultado como um número inteiro de base 36 e aceita o módulo 1879, fornecendo uma função de hash bruto. Ele escolhe uma letra para adivinhar, indexando esse valor de hash na longa sequência de letras. Se ele já adivinhou essa letra antes, diminui o módulo em 6 (portanto, sempre permanece relativamente primo para 36) e escolhe uma letra diferente, repetindo até encontrar uma carta que ainda não havia adivinhado.

Eu projetei essa estratégia para ter muitas variáveis ​​ajustáveis ​​(as letras individuais da cadeia longa), a maioria das quais afetará independentemente a pontuação final em uma pequena quantidade. Isso o torna adequado para a otimização do estilo de escalada - usei a Diversified Late Acceptance Search .

Python 2, pontuação = 2854

Com o uso liberal de bytes não imprimíveis e compactação incorporada, podemos extrair muito mais informações.

Decodifique com xxd -re execute com python -u. (Para testar com o controlador fornecido python ./game.py python -u ./solver.py.) São 2047 bytes de código + 1 para -u= 2048 bytes.

00000000: efbb bf49 3d72 6177 5f69 6e70 7574 0a61  ...I=raw_input.a
00000010: 3d49 2829 0a77 6869 6c65 275e 273c 613a  =I().while'^'<a:
00000020: 0a20 633d 673d 2727 0a20 7768 696c 6520  . c=g=''. while 
00000030: 6c65 6e28 7365 7428 6729 2d73 6574 2861  len(set(g)-set(a
00000040: 2929 3c36 616e 6427 5f27 696e 2061 3a0a  ))<6and'_'in a:.
00000050: 096d 3d33 3433 310a 0977 6869 6c65 2063  .m=3431..while c
00000060: 2069 6e20 673a 633d 2727 2778 da05 c101   in g:c='''x....
00000070: 62a8 3808 04d0 b322 1923 bf04 b230 b1f5  b.8....".#...0..
00000080: f6fb 1e42 6c73 475a e2e1 277d 3d19 d0c1  ...BlsGZ..'}=...
00000090: 5f9e d177 4f21 50d6 67ab 49b2 9ce1 09cb  _..wO!P.g.I.....
000000a0: b4ca 793e ab4a 49a6 c567 e530 b9bf 41a9  ..y>.JI..g.0..A.
000000b0: 61b1 4dcc 77a1 7a3a c5a8 cb6a 3008 5958  a.M.w.z:...j0.YX
000000c0: fc15 ff50 d515 e0b3 326f 44d7 aecf 32fb  ...P....2oD...2.
000000d0: 4050 03b0 3302 5e1c f038 1ea2 bf04 19f6  @P..3.^..8......
000000e0: a847 1a8a 2571 47a3 0c68 a6c6 4b5c 72ed  .G..%qG..h..K\r.
000000f0: e463 a51a 509b aae2 bd85 dc96 5ca7 dbb0  .c..P.......\...
00000100: a5af bddc 6b77 f9ef 020c 86c1 8bba 2734  ....kw........'4
00000110: 4cb6 20bb e2b6 68af ba5d 5d4a 44ce 73a7  L. ...h..]]JD.s.
00000120: 5c72 4ad8 1d3a 0eed ea63 9629 9c56 518f  \rJ..:...c.).VQ.
00000130: e51b 32fa 2f4f da18 3592 de3c 335d edae  ..2./O..5..<3]..
00000140: 1f1f cd86 bedb cb3b 44c5 cf91 8047 d8b4  .......;D....G..
00000150: 33c2 aeff eea6 3184 5332 09bb a051 1191  3.....1.S2...Q..
00000160: 18dc f1dc a3a5 4220 36d7 c95c 7bb4 fc2d  ......B 6..\{..-
00000170: a518 9d56 937d bb35 b962 2e6d bdb6 dc07  ...V.}.5.b.m....
00000180: 5b10 ca25 275b 2523 d57c 1363 5ad7 f9ca  [..%'[%#.|.cZ...
00000190: 249e 8ea2 83c6 6af4 3de3 1fea 15ba ec1d  $.....j.=.......
000001a0: e70c 96b8 38d8 b225 62a4 63d0 fa2e 5c72  ....8..%b.c...\r
000001b0: 6057 ecf8 3db2 9f7d 185c 72ee 8e5a e519  `W..=..}.\r..Z..
000001c0: 02db bfbb c25a c738 d2b6 b454 8d56 5ab6  .....Z.8...T.VZ.
000001d0: 11ae 27cc e476 81e8 2321 9135 c833 3a4b  ..'..v..#!.5.3:K
000001e0: 8a89 919e 26e8 3623 e44d aaec 59db 6f6e  ....&.6#.M..Y.on
000001f0: 79da 3941 29e8 d274 7eb6 0aac 3249 8b1b  y.9A)..t~...2I..
00000200: b25d 1ff1 c496 f75c d125 e2aa f3b4 21a0  .].....\.%....!.
00000210: 7a55 d31d 4939 8433 ea97 f927 f9f3 0954  zU..I9.3...'...T
00000220: a861 2baa 7568 e1ce d489 f59d 1365 a69e  .a+.uh.......e..
00000230: fc22 bef1 a0cc 7dfc a320 7ad5 fa39 3f5d  ."....}.. z..9?]
00000240: 16b0 58b0 253c c54b f4d8 5729 cfb6 2371  ..X.%<.K..W)..#q
00000250: c328 c5ab 1315 fcc2 27ad 8462 b5d5 d6f8  .(......'..b....
00000260: 76aa fb12 c775 1733 24df 98f9 dd86 cbbe  v....u.3$.......
00000270: 0c6e eb38 695f 705b 062d e231 3812 bdc4  .n.8i_p[.-.18...
00000280: 4664 ae0e 30a9 2cfb 3cf2 84dc 806e eb86  Fd..0.,.<....n..
00000290: 7988 d147 1bc9 f7b3 ad1f 1914 2d97 99c2  y..G........-...
000002a0: d096 711b 4f24 74d3 ebd9 8d11 7a4a 6518  ..q.O$t.....zJe.
000002b0: e25a 9c0c 79b2 661c 8188 6a88 7315 ed7e  .Z..y.f...j.s..~
000002c0: b7ce 6d18 b06a 34d0 0a89 de1c 0509 65b4  ..m..j4.......e.
000002d0: ae5d 303d d2f2 7e98 cf07 ebb6 a4c0 e311  .]0=..~.........
000002e0: 13c4 1133 9b69 ecb6 9da7 75c8 1806 c136  ...3.i....u....6
000002f0: 2531 acbe aaa1 9353 fa13 ff28 fa62 999b  %1.....S...(.b..
00000300: b59f f13d 47ca a7f5 e706 06f1 9374 78b1  ...=G........tx.
00000310: 649a ea19 a156 efe0 084a b06b 31c0 d86d  d....V...J.k1..m
00000320: c913 a3d4 dbb0 6248 851f 688f 11fb cd91  ......bH..h.....
00000330: f339 9fb9 c9fe 0ecc acfc 6eeb 1544 6469  .9........n..Ddi
00000340: 223c 5d5e 14bd caaf f3ca fc4c 6cc4 b2a2  "<]^.......Ll...
00000350: ade5 5656 df3f 7046 c9ab cd63 3c5a caf3  ..VV.?pF...c<Z..
00000360: eec4 23ce aeb0 5aa8 7273 c1a7 d5b3 627a  ..#...Z.rs....bz
00000370: 4b5b ec3b 7f87 48cb 5740 51d8 79aa f4cd  K[.;..H.W@Q.y...
00000380: 5315 f53b ed89 2d7f 5736 d4f4 12e1 f1a0  S..;..-.W6......
00000390: 7d5b f45b 8323 4bd8 37fb 173e ed3e e85d  }[.[.#K.7..>.>.]
000003a0: 7f82 e83d de15 2925 cbb4 702f 04c4 b8f0  ...=..)%..p/....
000003b0: 4998 b5f4 7ad3 b8f3 9ad3 5008 1722 c7ee  I...z.....P.."..
000003c0: ca10 40f2 3fb1 8f2b 2262 f70e 8358 c2ac  ..@.?..+"b...X..
000003d0: 0b78 4ca2 163b 2f74 3c02 df67 a4eb f9f9  .xL..;/t<..g....
000003e0: 799c b5c4 14b6 d672 54d5 37c3 6a7d 1675  y......rT.7.j}.u
000003f0: f219 bd6e ee58 eda8 3af1 6989 c8c9 f1a8  ...n.X..:.i.....
00000400: eeeb dcfa bed7 eef5 4ea7 50ff bde8 92f8  ........N.P.....
00000410: 6648 2980 ebf9 7645 84d9 0ef5 1192 c672  fH)...vE.......r
00000420: 254f e460 8da5 79d6 0fbc 2138 1edf b1ad  %O.`..y...!8....
00000430: 355a 98ab 548b db38 43ef 12db ef01 b93c  5Z..T..8C......<
00000440: 933a cbf1 44e6 2b85 f22c f6db e922 e1e3  .:..D.+..,..."..
00000450: 113e 803f 562c 83df 898c 3dca 86fc c809  .>.?V,....=.....
00000460: c09d 8585 87b0 4a78 8908 fc4f e0f3 4731  ......Jx...O..G1
00000470: 671f c4de 53f3 a85f 8954 fed5 ee2c 99c4  g...S.._.T...,..
00000480: f091 6feb 5307 4f70 7df4 2620 d7d9 dca4  ..o.S.Op}.& ....
00000490: 4644 a948 4016 44bc 80df 7d6f c686 6499  FD.H@.D...}o..d.
000004a0: a4bc 75d0 2506 bf1d 2747 6b54 95be cfb1  ..u.%...'GkT....
000004b0: 7b4b d70a 89b0 ac68 e2c4 1394 ba20 4d01  {K.....h..... M.
000004c0: 204c 64f3 721f 2a53 862d 89f5 59df b273   Ld.r.*S.-..Y..s
000004d0: 7c32 470f 7055 ef6e 2167 d4dd f546 9c0e  |2G.pU.n!g...F..
000004e0: 9eda bf3a 78ce d946 28b5 2c8d f79f 7c31  ...:x..F(.,...|1
000004f0: f940 d75d 8940 aca2 f6af f538 1eaf 6ef7  .@.].@.....8..n.
00000500: c81d 56c5 955c 0506 7474 fa7d 4627 b6fe  ..V..\..tt.}F'..
00000510: 4aa9 9abd 825d 166f 852c 8a4b b87e 727f  J....].o.,.K.~r.
00000520: 43c6 d657 eeb5 46cb 449b ce1b cc11 a25c  C..W..F.D......\
00000530: 72b1 8ccd 7feb ac50 8c21 a75c 30cb a3a7  r......P.!.\0...
00000540: ebc3 326c 0a9e 8b3a 513e 560b 2c31 cb61  ..2l...:Q>V.,1.a
00000550: c6bc 6748 90e1 6e3c ae15 8e37 9264 f73f  ..gH..n<...7.d.?
00000560: 696b 3c62 47a8 f091 82a7 0f4e 2f7d 1343  ik<bG......N/}.C
00000570: d202 b436 3e36 7825 7fc7 8b0b 2543 cdff  ...6>6x%....%C..
00000580: 2a33 08af e34a 652e d547 d87d 0c4f b6d8  *3...Je..G.}.O..
00000590: 5105 ad4b 47e9 31ad 2bec 98f0 d6aa 487d  Q..KG.1.+.....H}
000005a0: d26b 33fa 651c 67b7 f189 7c01 cf87 24ee  .k3.e.g...|...$.
000005b0: f2d5 3634 49f3 6aad 898c 914f e6fe 202d  ..64I.j....O.. -
000005c0: 8f18 2e3b a1dc fe8c 624c 3d66 27ca 54da  ...;....bL=f'.T.
000005d0: 1183 c790 96fa f357 bee8 6171 d69e 451d  .......W..aq..E.
000005e0: 5aad 5bd5 681a 0cc1 b6ce c3d4 82d9 d7a6  Z.[.h...........
000005f0: e269 4bac bbff c406 7388 85d6 6dda f2c4  .iK.....s...m...
00000600: 0f75 e17c dd1d acfd 6086 904c c59c 935b  .u.|....`..L...[
00000610: 0a8f cef8 c935 51ad d44a d9b2 aa0b e01c  .....5Q..J......
00000620: 3ff9 bb87 3190 b4cc 2fed 4bd1 58a1 f06b  ?...1.../.K.X..k
00000630: ee44 1a6c 435d ae3a e7ef a501 a30e 6def  .D.lC].:......m.
00000640: 21ea 3b89 32e1 631b 53f8 c14a f636 51f9  !.;.2.c.S..J.6Q.
00000650: d662 ef32 b386 ed27 6b87 5b5e 8f5b 9776  .b.2...'k.[^.[.v
00000660: dfe0 e83d 1f29 fbf2 dc5b b843 60bf cbc8  ...=.)...[.C`...
00000670: aa9a 9ad2 f94e 2ea9 96b0 296c 937e 65a3  .....N....)l.~e.
00000680: eafd a4d0 85b5 9f4a c671 7ece 5811 c7b7  .......J.q~.X...
00000690: d3c6 75e0 70b3 224d c9aa d8f1 fb6e f4ea  ..u.p."M.....n..
000006a0: 1d7a cef7 5fc7 5a98 7fd5 28b5 753f 7c43  .z.._.Z...(.u?|C
000006b0: da79 9d90 1a51 33ae ca7a d5ea a990 fed3  .y...Q3..z......
000006c0: 5ff5 2975 7b99 8333 44c2 a7fa 17a3 875d  _.)u{..3D......]
000006d0: 70ef 2361 6d5a 1cc8 13a7 d482 30c6 2b84  p.#amZ......0.+.
000006e0: 4d4a a765 c81b 2e16 3e62 08d8 ce5a 2beb  MJ.e....>b...Z+.
000006f0: a823 42ef 633f 7858 cdaa 755c 3097 f029  .#B.c?xX..u\0..)
00000700: 2afa 06d8 47c0 2714 f3fa 1554 d8a5 1a8b  *...G.'....T....
00000710: 77ac b319 ac47 9b5e 5ba7 a5ae 7dc7 c86f  w....G.^[...}..o
00000720: e73b 2a62 7a3e 7b29 6583 b227 0417 bb6e  .;*bz>{)e..'...n
00000730: 98ef 9097 6f9b c655 8f20 32ce a60e 6556  ....o..U. 2...eV
00000740: ce62 c8c9 afab c30e 6908 5675 19c6 5019  .b......i.Vu..P.
00000750: 62dd 131b 9c2d 3968 3f42 5b96 e7c9 1e23  b....-9h?B[....#
00000760: f1b0 0280 9ce9 f9cc 92ec 7eb5 a7c6 9619  ..........~.....
00000770: 5aab b832 b7cf 865c 72f1 9454 e33a 9975  Z..2...\r..T.:.u
00000780: 5b8a d8e8 5f46 0a22 2397 7d77 f70a 33b7  [..._F."#.}w..3.
00000790: 5183 5d5e 7267 54c5 a204 1e2f 470a dad2  Q.]^rgT..../G...
000007a0: a554 e493 7f06 7ff9 5fdd dfff 8428 a74f  .T......_....(.O
000007b0: 2727 272e 6465 636f 6465 2827 7a69 7027  '''.decode('zip'
000007c0: 295b 696e 7428 612e 7265 706c 6163 6528  )[int(a.replace(
000007d0: 275f 272c 2731 2729 2c33 3629 256d 5d3b  '_','1'),36)%m];
000007e0: 6d2d 3d36 0a09 7072 696e 7420 633b 672b  m-=6..print c;g+
000007f0: 3d63 3b61 3d49 2829 0a20 613d 4928 29    =c;a=I(). a=I()

Resultado

score is 2854, totalerr is 19482

9

Python: 2006 bytes, pontuação = 1501

1885 bytes, pontuação = 1337

1961 bytes, pontuação = 1207

Aqui está o meu envio:

import sys
b='eJwdVQuW4ygMvJdyGgwYtAGJQQKHOf2Wp9/rJqGxVaqP+HxUMlGx5F86/XoqsUuonzAz5cf5vqjJ6OlQudxOJR3ibJ8cwuSmsTX12daVht8ubj15miaEH/GrESXrQrXbl1K0m2hs6dRjMkp1PuS2/9JoVslkLmp2L6J6f5kij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+T8IWooeMVWDnvoF6wcETdOUVYBFcFdCop/CJ07RpwyjNy1kslHYwdfNxGYGtX4lWduETDAFIeLJntoAk/sjHlLI5tIwp6mcLF5gxJOR2eugsO5/fey0EhMb72J+mrwyB3rkw2eT0cCPuAOUc5cw/b7mQi8942Eaig4nkYUE9xi3D+FTVRxd80XLL9MXhgISod0JBHxjPPCNirRsh/0TgWdrB/6u01zHbvUnBDc4yhknZxCXgrgSWdv8h1oQR3q8hjdbbE5zK6e4U9nhNkHxCwjCdN26sS9+BIMPe7+EDExPGccPLQYvC8+SY1ioz3AxVUWfdJi3RNjjEMyiWq31CjITE1cQPTO5En39bkFEzri7c2f8Dkow6qw=='.decode('base64').decode('zlib').split(';')
R=raw_input
def G(c):print c;sys.stdout.flush()
def P(w):
 if'END'==w:exit()
 d=b[len(w)].split(':');l=len(d[0]);p=f=0
 while p<l:
  G(d[0][p]);x=R();r=w==x;w=x;f+=r;p+=p+1+r
  if'_'not in x:return
 for c in d[p-l+1]+'zq':
  G(c);x=R();r=w==x;w=x;f+=r
  if'_'not in x or f>5:break
while 1:P(R())

Resultado da pontuação:

score is 1501, totalerr is 21608

Este programa é totalmente determinístico. O blob gigante (que é um pedaço de zlibdados compactados com base em 64 bits ) é uma lista de árvores de decisão (uma árvore por comprimento de palavra). Cada árvore de decisão codifica uma árvore binária completa com uma profundidade entre 2 e 5. Cada nó interno é um único caractere, e a decisão prossegue com base no fato de o caracter estar presente ou não na palavra da forca.

Cada nó folha da árvore binária contém uma tabela de frequência otimizada específica para esse ramo da pesquisa em árvore. A tabela é otimizada especificamente para favorecer a conclusão de determinadas palavras, ignorando completamente outras (que não podem ser alcançadas devido ao orçamento limitado de "falha"). A tabela não é otimizada para minimizar erros e, portanto, a contagem total de erros do programa é alta, apesar de sua pontuação (relativamente) boa.

O otimizador, que não é mostrado, usa um otimizador não linear não determinístico, utilizando uma estratégia de descida aleatória em gradiente para produzir as tabelas de frequência.


5
1337 é uma boa pontuação. Mantenha lá! = p
justhalf

Se você deseja jogar golfe, range(4)pode ser substituído por, [1]*4desde que você não precise realmente usar o valor de i.
user12205

@ace: Obrigado. Eu esqueci que você poderia fazer isso. (De qualquer forma, eu só reescreveu esse ciclo para a mais recente melhoria pontuação, então a coisa toda é ido agora ...)
nneonneo

@justhalf: eu também gostei dessa pontuação, mas quero continuar melhorando. Há muito terreno a cobrir ...
nneonneo

1
Btw, você pode barbear um caractere usando em decode('zip')vez dedecode('zlib')
justhalf 11/04

5

Rubi

Um envio conjunto do usuário PragTob e de mim.

MAX_TURNS = 6

frequencies = {?t=>[3,48,145,214,252,266,249,223,191,142,63,44,16,1,0,1],?h=>[2,14,81,125,85,91,60,42,30,14,11,6,1,1],?e=>[5,49,260,316,456,408,328,279,202,125,50,32,12,0,0,1],?a=>[4,60,211,259,249,266,253,192,152,111,51,42,15,1,0,1],?n=>[4,30,120,136,214,252,238,214,189,128,59,45,16,0,0,1],?d=>[1,25,100,104,131,123,131,81,63,36,14,15,7,1],?f=>[2,13,51,58,64,67,41,40,28,18,11,9,3,1],?o=>[9,44,150,165,195,220,214,168,155,104,46,37,14,1,0,1],?r=>[1,25,140,246,312,310,263,206,150,95,45,32,11,1],?y=>[3,29,41,58,86,94,83,63,52,31,21,12,2],?u=>[2,23,67,117,126,154,107,97,85,48,27,16,2,0,0,1],?b=>[2,22,53,60,72,59,41,30,36,16,7,6,1],?i=>[3,38,143,179,223,299,270,241,205,134,64,44,16,1,0,1],?s=>[3,23,129,176,195,208,177,136,117,71,44,23,13,1],?c=>[0,12,68,122,146,194,180,163,130,85,49,25,7,0,0,1],?l=>[0,18,153,172,190,196,164,131,125,67,35,20,5,0,0,1],?g=>[1,19,42,75,82,104,78,60,39,30,12,10,0,1],?w=>[1,21,56,56,40,41,18,16,6,2,1,0,0,1],?m=>[2,10,77,68,119,94,104,76,68,45,15,17,8,0,0,1],?p=>[1,24,82,84,94,129,105,88,99,56,24,11,7],?k=>[1,6,65,37,28,24,6,10,3,4],?j=>[0,5,5,6,7,6,5,6,2,0,1,1],?x=>[0,6,4,7,15,22,13,16,9,9,2,2],?v=>[0,3,21,39,47,58,63,42,40,23,10,9,2],?z=>[0,0,3,3,3,5,2,3,0,0,1],?q=>[0,0,1,9,5,13,8,3,5,4,3,2]}

while !(input=gets.chomp)['END']
  current_turns = MAX_TURNS
  won = false
  chars = frequencies.keys.sort_by {|c|
    -(frequencies[c][input.length-2] || 0)
  }
  i=0
  while (current_turns > 0) && !won
    c=chars[i]
    i += 1
    puts c
    $stdout.flush
    old_input     = input
    input         = gets.chomp

    if input == old_input
      current_turns -= 1
    # else
    #   frequencies[c][input.length-2] -= 1
    end
    won = !input[?_]
  end
end

Resultado:

score is 625, totalerr is 23196

Isso tem 1672 caracteres e ainda não é um jogo de golfe, por isso temos amplo espaço para aprimoramentos algorítmicos.

Primeiro, armazenamos um hash de frequências de caracteres (calculado a partir da lista de palavras) agrupados por tamanho de palavra.

Em cada rodada, simplesmente classificamos todos os caracteres pelas frequências para o comprimento atual e os experimentamos do mais comum ao menos comum. Usando essa abordagem, obviamente falhamos em todas as palavras que possuem apenas um caractere médio comum.


Acredito que isso esteja próximo da solução ideal.
justhalf

@justhalf tanto para a solução ideal ...;)
Martin Ender

@ m.buettner +1 <texto do preenchimento>
user80551

É o score is 625, totalerr is 23196ainda up-to-date com o seu algoritmo atualizado? Eu tentei um semelhante e eu tenho apenas 300 no máximo.
justhalf 9/14

1
@nneonneo Se você estava se referindo justhalf é comentário inicial ... que era sobre uma versão anterior (inválido) desta resposta que marcou sobre 3950.
Martin Ender

5

Atualizar Usando um método semelhante ao @nneonneo, chego a esse código, exatamente 2047 caracteres .

Ponto:

pontuação é 987, totalerr é 21964

Código:

import sys,re
R=raw_input
F=';;;topenayr;elsatrodin;eatslroncih;eastrinclodu;etnocsiralupd;enostciarldpmu;eitnoasrclupmdy;einocstarlpumdyg;itacslnorepumdgyv;intaoslecrupymdgfh;nitaoerclsmudpygfvh;itneaorscmpdlfuvybh;ratdgfihosw;;ceimontalu'.split(';')
G=[''.join('.'*int(c)if i%2 else c for i,c in enumerate(re.split(r'(\d+)',w)))if w else''for w in 'eJwdlA2S4yoMhK+0CpPJ28ppQPxuQFBITMq3f52JXY5TdpC69TXP50ziQ6RWKxV3stBw+XEtIXXvx4u+g5I5e1x0V+fGN236S/b0aU+7UjMNFoyOvVc8hSInersrxBWr0BUqNSchUXT835YlWCyUTtW9Q6PL1UfhRtmVR3gm72dvu/Vts3c+sqPFoSaWbUWqqi9dylLXe65MWM12/CEdkcLX6LVXU7HBuQXSqDyMKTOjgX40Dty966CXY66Q2H/r7b3b7qat2zF8NLbWZ1QpTLvXWN+1NancuPdoE8sXNi1DqrtssxY+7RzRdxUWa5FLDVPzJJnWpTZW4xN4Uay1BFvUIxNKtz2le7/N47Bt3XedKjyttQgl/dhlcfvNZaNkFN8OnsrULiPQGqeeOsZRPZVl+sXsT61413rvqr751pbIBR/CSyWWs+JLrl66li+lM1j2JVDQowzxlUeo451DGDXOnDlD5Dw+7jcrnC855BmvCr8jGpzsa1P/E0VeWqKGwWGtEKVNiodj/4mTRXtgUDQChs4k7UWZ/py7ldsbv5WZ44ugjdj735MDzpFDffPgtQruJdO6vT7rVwYMQa+dCc7xCgVyJ57+65bH6yxj43/D7cxl3vaPAS/YEGfzo/Ess2iINV5To1/5VbMqrXMsV7ZYZJU1KPAZH4rrUNA/pK8MjlCcYAipoCYryaesw1wbD6SFb2+n7YfOZ6xexOb0RZv34Kprn743BtGwYsnZXbadfX3Yw8jAFGtbYGxxc1p08LF4bbbDdYdsvA7wyPUVm3GD70u9t9I9q8oAMUPbaVdV/oXKNwNUIkCCTDyAnd46e21yAyJQFFRn35+G5i97rXeZwuW+tcPYa0VesXNAXzguNviOKGEyEbYjkT56VehF14eRgNYHSjePNnl3L3CAJsMDhNhP072ng0sRvk0Gq0LeMHqRvRUj3/xQNwt3cyBiaEH0we28VZ4LMIse/O34T32sybiAlf1sCXHEzgUNU3wiqOt74zXdqc/pOpXC1UIffoyNUCAjiyfjFb8fehue6hbaPKjXgI4RwIVgBAmXeiC5J5ihGFZKnGAFxLF/WmpxJ6HPtuXTdM1D8m3iWfKPSQFKQPEdmSL/+WA7vItr9JuMKGWsi/7kTrzGLXDoPzvy/jjxq4gMi0E+87xnz7SS+p08EXbM7h32M5QOxRNk3py6TdrHd0kftelzravf4MDBcrCGWvJu4toejG9Ok75SffANw9hp3/6Osegr6L1hfx4YRXoCVUrkXbwFecx74on+P/VTUoewuekqaRrP5/N/1MpqAw=='.decode('base64').decode('zlib').split(';')]
while 1:
 w=R();i=0
 if'END'==w:break
 f=0;l=len(w);g=set()
 if G[l]:
  while i<len(G[l]):
   c=G[l][i];print c;sys.stdout.flush();g.add(c);x=R();i=2*i+2-(w==x);f+=w==x;w=x
   if'_'not in x or f>5:i=0;break
 if i>=len(G[l]):
  for c in F[l]:
   if c in g:continue
   print c;sys.stdout.flush();x=R();f+=w==x;w=x
   if'_'not in x or f>5:break


Entrada antiga

Resultado:

pontuação é 656, totalerr é 22962

Não é uma média, pois esse algoritmo é determinístico, ou seja, sempre fornece a mesma pontuação para qualquer lista de palavras embaralhadas.

Aqui está minha entrada no Python 2.7; golfe (717 caracteres)

import sys
class S():
 def __init__(s):
  s.l=6
  s.g=set()
  s.p=''
F=[0,0,'onastifeybhmudgkprw','topenayridsubwglfhcmkxjv','elsatrodinphmcukwbfgyvjxzq','eatslroncihudpgmfbywvkqxjz','eastrinclodumphygbfvwkxjqz','etnocsiralupdmgyhfbvwkxqjz','enostciarldpmuygvhfbwxqkjz','eitnoasrclupmdyghfvbwxkjqz','einocstarlpumdygvbhfxwqkj','itacslnorepumdgyvfbhxkqw','intaoslecrupymdgfhvbqxjwz','nitaoerclsmudpygfvhbqxj','itneaorscmpdlfuvybh','ratdgfihosw',0,'ceimontalu']
s=S()
while 1:
 c=raw_input()
 if c=='END':sys.exit()
 if '_' not in c:s=S();continue
 if c==s.p:s.l-=1
 if s.l==0:s=S();continue
 s.p=c
 for x in F[len(s.p)]:
  if x not in s.g:
   s.g.add(x)
   print x
   try:
    sys.stdout.flush()
   finally:
    break

Isso usa uma idéia semelhante à @ m.buettner, armazenando uma lista ordenada de letras após a qual as suposições serão feitas. Mas, isso não usa dados de frequência diretamente, apenas tenta quase todas as permutações de letras possíveis e simula o jogo e, finalmente, obtém a permutação que dá a melhor pontuação.

Esta versão é otimizada usando as 9 primeiras letras, portanto, para palavras de 2 e 3 letras, a permutação já é a ideal, na classe do algoritmo em que as informações da entrada anterior são ignoradas. No momento, ainda estou executando o código das 10 melhores letras, otimizando as palavras de 4 letras (e também encontrando uma solução melhor para palavras mais longas).


entrada inválida

Para meus benchmarking, aqui está o código que usa a árvore de decisão completa, 11092 caracteres.

Ponto:

pontuação é 2813, totalerr é 17539

Código:

import sys,re
R=raw_input
F=';;;topenayri;elsatrodin;eatslroncih;eastrinclodu;etnocsiralupd;enostciarldpmu;eitnoasrclupmdy;einocstarlpumdyg;itacslnorepumdgyv;intaoslecrupymdgfh;nitaoerclsmudpygfvh;itneaorscmpdlfuvybh;ratdgfihosw;;ceimontalu'.split(';')
G=[''.join('.'*int(c)if i%2 else c for i,c in enumerate(re.split(r'(\d+)',w)))if w else''for w in 'eJw1momWqyyzhm8pgENc/9UoNGILSoto3Fd/nsq3zt49pBNlKKreAfzf//afbZycWkJQs6l+U8n4/smbKubuV9VNRZ3m7B/VFmNSpw41qPN/48+xn8/PcpbpnE5Vzzu7Oitnf9RtnsllFzb1TEEtZpt+lDP2fWx5o7FpjiqYe1rUY0I/20V5M/eT6r0956LmPKvJ+N+oNhP72Qd+f/pf1cZpYmihT6r1pg3RqWS9OkygzZUhx+PhUttX1S7TL28d2kSjbP6hg9hnWjBq6dV669NYF5jf2cfkGW/sg2q3+aM+Sk2qfYzabFS7yX1t+r0zy3TzV+o31V581pmkmqaoZs5FZXNIbD45q6wITrsaVcuih2Nojz22m1LDpnS/ptxmGUUx6tOZ3DTvRzVn0xevSzvQqD0O3RofMj/5bn/2S5lCl1rz66WbI/HJb3lapXL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u5gaqYbJKn8t0HZBGmLQcCiD0ygUqpsTejs+9Ik4ZtBy3FtQ7X1KrZSf32UXX/YED7spT7sqX7Abaenrd/bHysnFVIaJDF5oI0kePlJHUKgF4g+0L8O2XwMrTzmCqFl9xN/jqaRh2ddK1kJ0Pv4Y99DewyNPKN0RPyIgMp/G2z9IKfWiuV+/ve///0fiWqMOQ=='.decode('base64').decode('zlib').split(';')]
while 1:
 w=R();i=0
 if'END'==w:break
 f=0;l=len(w);g=set()
 if G[l]:
  while i<len(G[l]):
   c=G[l][i];print c;sys.stdout.flush();g.add(c);x=R();i=2*i+2-(w==x);f+=w==x;w=x
   if'_'not in x or f>5:i=0;break
 if i>=len(G[l]):
  for c in F[l]:
   if c in g:continue
   print c;sys.stdout.flush();x=R();f+=w==x;w=x
   if'_'not in x or f>5:break

2
I golfed seu código até 527 bytes sem alteração na funcionalidade: gist.github.com/nneonneo/c9f3ef399f0c588634d7
nneonneo

5

Perl, 1461 bytes, pontuação = 1412, totalerr = 21050

$|++;
while(!eof) {
  $l = $pg = '';
  %d = "[eaitrnoslcdupmhygfbvwkxjqz]<[scpardetmfbilwhognuvjkyqz]a[tlrncsidbpgmyuvkfwxzhoj]b[leoairusytjvmb]c[oetahiulrkcysq]d[eiaourlyvdgsmfwjnhqt]e[rnaslcdtmxevpfgqiwyobhkzju]f[ieoauflrty]g[erhiaunolygsmtdb]h[eaoituyrnldmbcw]i[notsclvdagrmefbpzxkuq]j[uoea]k[einaslywftogd]l[eyialoutdfvskcmpbwnr]m[eaipombuysnftl]n[tgedcsaionvufkylmhjqwxp]o[nrumlstwpocvdgfbaikyexjh]p[reoaliptuhsymdbfw]q[u]r[eaiotymdsruncgvklpbfwh]s[teisuhpoacmlykwfqndbr]t[iearhoyultcmwnsfbpg]u[rnstliceampbgdfyok]v[eiaoyu]w[aiehonrlsdtkfy]x[pctiaehuy]y[esomatpcwbildgrn]z[eoaiy]"
    =~ /(.?)\[(.*?)\]/g;
  %r = ">[etynrldgshmkpcwfoabxui]a[retclmnphisfvwbudgoxykjz]b[aiumoerylbhgspt]c[ienaouscrxtlyh]d[neairoludhsywgpk]e[rtldsvcmnphgefibkuwyzjox]f[eifnoalrustdmkwp]g[niaeroudgykt]h[tcsgwpenrxado]i[trsldnacmfhvpugwbekoxyz]j[nbdeao]k[carnosilewu]l[aeliobpuctfsrdgnwhkym]m[oeiarumstdynlghbp]n[oieaurngwkhtmsldy]o[icrplthmsfnobdwvgejyuzak]p[msaoepuixrlynt]q[eisncd]r[eaotpuigcrbdfhwlys]s[iesaunorbydclptmkgw]t[ansicreuolthpfxbygkwmd]u[ostcqlrfdbpagnmjhixev]v[ieoanrdlb]w[oaesrtydnlkph]x[eiaon]y[ltradcnsheomfbgpkuvzxw]z[iae]"
    =~ /(.?)\[(.*?)\]/g;
  while (<>) {
    chomp; last if !/_/ or /^END$/;
    $l++ unless /$pg/;
    last if $l>5;
    s/$pg//g for values %d, values %r;
    $_ = "<$_>";
    my %s;
    while (/([^_]?)_/g) {
      $x = $d{$1} || $d{''};
      $s = 180;
      for (split //, $x ){ $s{$_} += $s; $s -= 100 / length $x }
    }
    while (/_([^_])/g) {
      $x = $r{$1} || $d{''};
      $s = 180;
      for (split //, $x ) { $s{$_} += $s; $s -= 100 / length $x }
    }
    ($pg) = sort { $s{$b} <=> $s{$a} } a..z;
    print $pg, $/
  }
}

(Observe que são 1461 bytes depois de remover um pouco do espaço em branco opcional. Conforme impresso, é cem ou mais pesado, mas ainda bem abaixo de 2000.)

Tentei várias abordagens mais "sutis", mas essa acabou superando todas elas. As duas cadeias de dados são simplesmente listas de classificação dos caracteres com maior probabilidade de seguir cada caractere e os caracteres com maior probabilidade de preceder cada caractere (com os dígitos que não ocorrem na lista de palavras não estão representados). <e >são usados ​​para representar o início e o fim da palavra. Como exemplo, "w[aiehonrlsdtkfy]"significa que "wa" é mais comum que "wi" é mais comum que "nós" etc. %d, o mapeamento direto inclui uma classificação global, armazenada como $d{''}. É usado para lugares onde existem duas incógnitas seguidas ou onde todos os dígitos na lista de palavras estão esgotados (portanto, devemos lidar com uma palavra que não seja da lista de palavras).

Para cada posição desconhecida na palavra, ele examina o caractere anterior, atribui uma pontuação a cada caractere possível, começando em 180 para o melhor classificado e diminuindo para 80 no final da lista; então o mesmo é feito para o seguinte caractere. Todas as pontuações de todos os personagens são somadas e a que tiver a maior pontuação é selecionada.

Depois que uma letra é adivinhada, ela é removida diretamente das tabelas de classificação, para que não possa ser adivinhada novamente (até que iniciemos uma nova palavra e reinicialize as tabelas).

Atualização: ganhou vários pontos corrigindo um erro (não removíamos as letras da tabela reversa) e alterando a maneira como os pontos caem à medida que descemos na lista.


1
Bom uso de digrafos. Isso explora informações posicionais de uma maneira que minha solução não se importa ... se eu experimentar combinar essas abordagens?
Nneonneo 11/04

@nneonneo se divertir :)
hobbs

3

Python: 2046 bytes, score = 1365

pontuação é 1365, totalerr é 21343

import sys
from math import factorial as f
z=lambda r,x:f(r+x)/f(r)/f(x)
d='eJxtVouWwygI/dYEV03rg5Fg63z9Apo+ZtczZ5JU5HG5gP+0cyvHlhjORrI6lQpnZoq0Z8o46GO5\noJ/YE8XwpBw6UXGEcLPdM2MacpBzO8kVcr1TSttJxx5/Rg/u7h5EDJlI/jgBiRkCO1sDuWUETVci\nxkxM+junUWBQF+OeSgxUxg+B+ExnbB2hgJxp8cR5fA/dT6U7q7+Ovhf8/ahIEWrGQyR3+3X8ORKY\nnvI48vw88jClT4IDh+fh4mMQ2Nn8cWyfxpkmspj73EXYD9sfxzkwP6GKYP7ya3lQ5ZgsD30lIM6n\nZKZPkYqQzyV9bkeGgbGKeMyfUcxj96UUHOoP/IwrngrDIHtswBqFQ+YTDpftHeshJKkggNNWXd7U\nU5yw4me818L5KDjD/Lv8jyC6XldyulpFzvswm4T6faiQy0K6JmTKRyEYgZ7hrWm+VjezxuH1tcPK\nBLA8sNq7f/mHXkV4NDfeFG/0Fgp3PZErqM4s+WEXKb+ZhBQqXrH6PdE+E0SjUGWJzwfNei8KwM2L\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ro3\nvULus01HDncbYPWRYORC/wJ6k9G1\n'.decode('base64').decode('zip')
D=len(d)
R=raw_input
def G(c):print c;sys.stdout.flush()
def P(w):
 if'END'==w:exit()
 i,l,X=0,'e',6
 r=x=''
 while 1:
  if l not in r+x:
   G(l);w=R()
   if l in w:r+=l
   else:x+=l;X-=1
  if not(X and'_'in w):return
  if l in w:j=1
  else:j=z(12-len(r),X)
  i=(i+j)%D;l=d[i]
while 1:P(R())

Grande parte do código empresta da submissão python do nneonneo (sem a qual eu não teria isso abaixo do limite de 2048 bytes). Originalmente, achei que isso deveria ter cerca de 200 a mais, mas descobri um erro na minha ferramenta de criação de cadeias de dados. Agora que está corrigido, minha pontuação é 1365 muito mais razoável.

Em vez de criar árvores binárias com base no comprimento, criei uma única árvore binária para armazenar as informações de frequência. A árvore não tem profundidade uniforme, pois não adianta armazenar informações de frequência para algo mais profundo do que seis palpites incorretos (mas, em teoria, os palpites corretos poderiam ter doze profundidade para "consideravelmente" e "desconfortável"). Essa árvore de formato desajeitado é navegada pelo código fatorial (na verdade, usando a função de combinação ). Para tornar a sequência de dados mais compressível, preenchi todos os índices não utilizados com 's'.

Usei um script para calcular boas seqüências de caracteres para armazenar como d, e se alguém puder jogar mais alguns caracteres no restante do script, aqui estão algumas substituições que devem resultar em melhores pontuações. A linha superior é a string codificada no programa acima.

score | length of encoded string | actual string
1365  | 1646                     | ertanialuctrssssvsnoctmushsbmsmpyssssssssssssdgyssspvlshgxsmgvssndspcjssssstmplyushumrtsdnsdvvsllatsibhqyvgdkdwssucmssmssulcsmusscsssssogsdssssssspsssstlsupmsusgsdsulyncysvyssfsnhgsnyqscalusthrvpcncpssrhtpsssspsbgvfsssssobuysssdssssssssssssssscsssssssssssscsssopshcompidssbsssssysssssssssssssssgusxsssimssssssimydssssxscipyfuydhwyscbssssmsssssssssssbssdsssusssssvspmvmssssspcbissssbyitypmxcossdmcssssssssssssyssssssosvssssfcvsssssdghsssssdsmpvysssssopcmtysssssstaimcyphocvshmsysssssssssshssssskssssssocdphsssuxhssssssiocyfsssswacubsssdpuutcidmsssdppoitanoclussaodmacssspdssssspmssssssssssssssssssspssssssnpbissssssssssssssssssssfqssgssssssfdssssssvbssspumbydmsssspbsssigsssdmgysrsdvminscygsxgssssssssssgsssssodbsssssugssssodbssbcssmsssscumsspomssssfssssssssppfssbcuyrdympysssssssrsssssfsssssgkmsssmocugssmcosudhsmdssssssssspsgopssssspssfblsbvssssssynsouqssfgusssvnisssjfpysfssssmdfssssrslujsuucpombssssnsicussssopssscssmossbsdsssssssssssspssssmdsfssssssssssssfsgdhwdssssdlyssksssssysgsssssogsusssssmfssusslsuufcpyssssvyssssscyodsssmsspusssssdpssssusslubuysuumppwsssgssgidsssssdoussssssssssssspdssssozsssssdssdrscmcdomsssgospdiwudspmidsygfcsulcuysssfssssusssssshucssssschgfcsssschbmsssskuosinpmchvmpgmssssssrmucpslfpcrsssssssssssvoyssscssssscopslsspgcdflssssssrucmfgssslcpruysclysssblsgsssssscilugsdslsssvssssssupvlysssssssssssssosssscssssslgsssssdcvysssspndcssssmcsssssssssssssssssssslsssssrugssssssucnmsssscncigdpslmgshhosssssossssszrypboybsyfssmdssssssgihbudsospdcusmosmoindflyybvmfcsshrsghfowsdphossspscssssssgsssssscgssssscfmspmbhoyuhssuplsbhsssvnitocnusmdcucfmjssspssssssssssssomvsshsssssspssssssssssssssussssrgssssssolmfbsydmssssdsssssrdpsjdssssssssssssssssplasssmyssssssdsssssamlssssfssssssssssssssmpdmsssflsssssdslpyhgsrdssssssshssdlshpssssfsrsssssshrsxssssmlavssdlsnpruupysdprdliypoxmybssssssssxpmsssssssssssshguslsyssslrpflsssdbmsrcdspvsssypsamssmhsblssfssdbssssmsssssfdasssalpmsssamsshglysusssshglyspdsssunalcosydslkulbpofmdssxssssgsgufsssssdyssssdssssusmysspmdssvmsssssivsssssmpohsssshgopsssssinocdusyspvssssvssssssssssrgyssspmsvlmsrvssscfulyusdfssssssssssssssssssrpssspssrgoyssssgmhssssssssssssvssssssupssssqbvysssussysssapsuoscpmhssssssssssssdsrsssxssssssalbhmssdmsssssscmphssslfgrmchdgvdsosucdssfwsacdhsmpvvmsssssssssssplslssshrlhssmssvlbyssshdrgwkmssqcoglurspvlgcllascyphoudsrpusylfgsssspblyssssssbssssssomsslussrmvlussssfycossssssosphyssrscgshpragcscbchoralpbyssbsvdyssssssuxlssdlsssssssssssssssssssssdsssussmbdsssssamhssssssssssssssdsssssssdpssssssssssfsgsssssdlussslsusopxasmdspmssscpovdussvyslssmssussssssdmssssuspdlsssmftdglasssmalatmlocwvhpmgzssssussssssnyshsmlsunvsvlysstcnssssssssssssssspsssussssssdoyssssssfysssssshgpssssssdbunckgsssthylssycsubdssssssndsvsssssslyssugssssowssjuspxgusssshowcnuysloncsupdgfdsslsstacnslusfghwdlsbnsssspsussbyscsubssssslcghslsvddsmhssssjulynbyssssphugkousssowlcymns
1381  | 1662                     | ertaniocvsplttushtpyutsudwbvumgdlatcpisppmgdsyusuqphplgpmypppplppppppuhslypppppppyvpppppsulcspommdbpppppppppppppppppppppnjpppppsgppppydncmpppppfsnhgpmuqycalinscyvpcncpppppspppppppppppppppppppposbpgpppisbhpmpgxyppppppodbdppppupppppvfpppppmulympppbusoybppfscipypslhppodbpdppppppffpppppppopfppppuppppypppmppppppppcbipppppyityfcvppppdmcpppppppppuvppppppppxbppppppocmxppldgmpyppppsmpobuppppopcmtypgpppstaimcyphpchmvxpppppplppppphpgpppkppppppocdphpppuxhpppppgiophyppppwacubpsdvmuutcivappubppoitanocluspaddmacopfpdgpppplvmpppppppppppppppppppuypppplpppppppgupppppppppppppbfqppsgpppppugpppppppvbbcpdmppppcumppbgpppppppppppprpppppmpppyppppppppppppppppppppppppppygnpppppppppppppppppppvpsfplmpyppppppppppppppbrpppxrdyppppppppppppppppppppppppppppppvyupsmpppppppppppppppcyppppcuypppppppsbpumpppspppfpsuqpgkmpponmocucuddpppcfujppmdcmcoprslujpuuppppppppbgppupppppppppppnupppfblsonppppppnsicupphbmdppppppppppppppfppppwdppppdlyppkppppppppppyppdspupdpppmfpbvpplsuppppyppgpppppogppghpppdspppuppgohdpspsdhpslubyppcumpppugppypppppufcpppvypppppyodpppppwppppppgidpppppdroupppppppppppppppppgozpppygdpppppcmcdompspfospdiwpuupmidpcppgfcpppppppppppgupppppucuhpppplchdigprmhchbmppcruuosinpmchvmpgmppdppppppppplppppplflpppppprucmfgppplcpruypbdspocgdpppppppppppppppkppblplfocdpppgxpppyppppppppppogppppcvpppplyupvlysgypppppcilybppplpcppppplgpppppdcvypppppndcrugomcpppppppppppppppppppslmphsoocdmsopppucnrypboxncigdpplmgppppppppouppppmzppppppvppppomybsdpuvgirsghfowpdcuppdppvindflyppvmfchbugdppfpcfoypgppoyuhsphopscxppppmpgoncusmpsspmbhppsupsuplbhppppvnitoclaspdcucyffqpppppppuppppppprjdpppppppomvppppppppdppppprdpppppppphsppppppmuppbpppppmyppuppsdpgsppfppolmfbppddmpppppppppmpppvppflsupppxpruyppppppppppppppppppppppppppmppppppspppppppuslpppdmlrshyppypppppmppppyhppppspafspppchpppppumpppppppmpppppppslpybpdlycsrcupsducymliypuyvybppppppppppppnpppmppdppmppppudnyoxmpmhglyppppuahglyfdapppunalcosyddlkulpuppmdpusppppvpppppppppppppppppppppbpofpppgufpppppppppppppppppppphpppppyppmdpmvpppppppsdypppsppdpprvpsvgrdgysgmrpppmpmppppxmpohpppphgopppqupinocdushppvscfurgoyfvlmfppppppmpgsppppyppppppmpxdpppbusmyppmsyypppppposcpmhsppppppppplypprpppvpppadppppppppdmppppppcmphhupgfgrmchppsalosucddpfwschdswppppxppppppddvgppluvmppprdgacdlpprvgxlfpprgwkpppphgglursplubcllascyphohmdfylppgfpcosulxpgplgpppbpbhmlvumppppvbrmyppufpyrypdpppppdosphyppgppfshpragcpvmchoralpbyppbpvdyppdplupppppmpppppdfpppppplpbypmppppppmbdpppppppppppppppppppppuppppplappppvllyppppamhspppppppppppppppppspplpppppsppppppfsgpppppdlupmppppsospxappppxuuppppppmmftpvplppppuvyppppumqppppmcpovudppddglanyppppatmlocsvotcnspppppxmgzpppppdlpppppplgpyvmwgpppbfyppphpphpgpppunpdbusvlypppthuglypncfbsppgpppwspuppppppdoypppppppppppfudppwgsdjupppcnuyppppsyupdfnpsoumytacnslupgghwdlpvlpsdpppppyoypppppxpppppphowlppypsoncvboculynbcsubpphuglcghpppplcymnpppdjdvalutcrspgppknmcpypowodppppguppppppbchgxpsysppoctmduppppsmpnryppppkppsyrhppppupprtsdnsuqlwp
1382  | 1796                     | ertaniocvsluuuuuluouuuuflbvuuuurucmfguuulcpruyubuuuuuudsuuuuupgohcuuuygnuuuuuuuuuuuuuuuuuuuuuuuuuuuuouuuuuuuuuuuuuuuuuuuuyuuuuuybuuuuudmuuuuuuuuuuuuuouuuuusmuuuuuruguuuuosuuuuudmuuuuuuuuuuuusbpumuuusohuuupmrypblouoyfuuucnuuuuucfuuouupcnmoulonbuvuuuuuuybsduuusprsghuuuvqhopsuuuuuusonpuufownsicuudhbluvbuuuuuoyhuuuuuysfyuuuumpconcusmlxfmumcuuuuuuuuuuduuumuuuuuuuuuuuuuupuguuuuuoguuuuguuulrvmuuuuuuuuuuuuujvyuuduycyordpumuuuuguuuuuuuuuuuububuuusguuupwsduuuugidvbuuudouuuusdvmuugumyuuuuuufluuuuuopruyuuucdomuuuguspdiwuuupmiduumuuuuuusuuuuuuuusllpuuulrshcuuuuchidguuuuchbmuuuuuuosinpmchvmpgmuuuuuupydcumuuuslpybuugfvsrcdbuuccymcdyuuuuuuuuucgduuuuuuuuuuuuumpvuubluudncduuunhglyuguuuuhglyryguuuunalcosydulyupvuuumduuuuuuuuuuvuguuuuupvuuuuudcvkmuuupndcuuuumcuuduuuhmuuuulmpyuuduluuuuxucpmuuuuvucnmucyuxncimoculmgdurdgyuurpuuuufbuuuuugdpuuuumduuguzpgihbudvufpdcuuuurgoindflgkuvmfcpyuuuuuuuuuyuuymuuuucubvyuugsusyuuugsuuoscpmspmhbuuufusuplbhuuruvnitoclaumdcudmfuuuupcmphudugfgrmchuuuduosucduyfwschdswuuuuuuuuuspuuuuuulufcuuvrgdhuuuuprvuuuuuurgwkuuuuhgglurspyxpcllascyphoudsrpguusyguuuuuuuhguuuuubsuuuuupduuuuufmryuuuuuurypdulcuduosphypmuudfshprgfuucychoralpbyuuspadvyuuuuuuyuuuuubuuuumuuuuuuuuufsuuuuuuuuuuuuuuuuuuuukuuyuulfoyuuuuuuuuuuuuumuuuucmpuuucopuuuupgcuuuuuuuuauuuufdausuualpmuulduuuuusguuuuuuciluguuuluuuuuuuuxuumftuuuuuuuuuyuuuugsuuuuuuuuuuuuuuduuunusmyuupunvtymuyutcnsuuuuuuuumdsuuusvguuuusgmhuuymxuuuufyuuuuuuhpguuuuuqdbunckvlmuthugscfulfbsdfucpuwsuuuuuuuuuuyulyuuuuuuuuuuuuhwguuuuuuucnuyuuovuuupdfnuupluutacnsluuushwdaduuuuuuuluuuuyuuuuuuuhuuuuuxuuuuuualbhmuudvlynbuuuuuuhuguyuuuuudlcymnuvmuuuualcautlrsxgxnmcpyuhsuuuuuomduuuudsuuuuulhuuysuualvbyfughcossulquvdyluntryuuuufurtsdbfluuuomutsdyuxuuuvcyyrhtmuluguytnguuuuuuuuuuuuuuuuuuuushuuuudhpuuuufuuuuuuuuuuuuuuuuuuuumudluumbdupsluuuuliypoxmybuuuuuuuuuplauuuuvluuuuuuamhsuuuuuuuuuuuuuuuuuuuuluvuuuuuuuuuufsguuuuudluuuuuuusopxadbpuluuuuuuuuuuuuuuulubpofuuugufudmuuuuuupdluuuualdglahuuuhoatmlovavopmgzsdypuuuuuuuuuuuuuuuuuuuuuuuuuuivuuuuumpohuuuuhgopcuuuuinocdusyupvuuuucwhuuuguuuuuuuuuuuuuuuuuuuuuuuuuuufuduuuusdjuuuuuuuuuuuuuuuuspuuuuuuuucopuuuuguuuuuuulpsuuuuupypuuuuuuuuuuuuuuuuuuupsuuuuubocsuuuucsubuuuuulcghuyuuddvghuuuuuuuuuuuuuuuuuuklfuuuuowoduuuugusuuuubbchgxmpvuupoctmpuuuuusmpkuuuuuuuuuuuuuuuuusduuuuuusqulyuuusuquvuuuhltmpyuuuydtsubqlyuugdlatisbhdpmgdsuyuuuuuuuuuuuuuuuuuuuuudflyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuslpbvfuuuuyuuuuuuuuuuuvuuuguvluudoupspumcopduuuuuuuuuuuuuuuuuuuumuuuydusuvydcuxpuuucoguuuuuuuumuuuuumuuuuulumquuuhgcpovdxyuuuuuubsouyuuuuscipyfuuvguuuuuuusuuuuuuuuuuuuubuuuuumuuuuuuuupmuuuuuuupcbhluuuuyityfcvuuuudmcuuuuuuuuuuusvluuuuuxbdoyuupocmxuuudghuuuuuusmpobuuvuuopcmsyuuuuustaimcythmlhmvuuuuuuuuuuuuuhuupuukuuuuuuocdphuuuuxhuuuuonuidouuuuuwacubuuupjgitcivauuudppoitanoclusuaddmacoufpduuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuusofquuuuuucvsyuuuuuuuuuuuuuuuuumyuuuupbspduuuhwkuuuurupcpmuuuusmvuuuuuuuuuuuuuuuuuuuujuuuuuysuuuuuususmcuuvuulcssfuucuuuuuuuuuuuuuuuubpuuudrdyuuuusguruuuuncyuhuuufsnhguuqyucalinscyvpcncvluuugpuuuupuumuuuuuuuuuuuuucugusuufuusuquuufguuuuodbuujfuuufuuuodmdfuuuurslujuuupbuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuopfuuuuuuuuumduuuuuuuuuuuuuufuuuuwduuuudlyuukuuuuuuuuuuuuvuuuuuuuuumfuuuuulsuuuupyumpyuuuuuuuuuuuuuuuuupuuuuuudpsuuuuuslubyuuuumpuuuuuuuuuuuguuuuuuuuuuuuuuuuuuuuuuuuuugouuuuuuuudruuuuuuuuuuuuuuuupubcuuumcygfcuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuugfcuuuuuuuuuuuuuuuuuuouuuuuuuduuuuuurmucpupupcrupuuuuuuuuu
1388  | 1800                     | ertanioclcpruyuuuuuuuuuuuuuuuuouugohucmfguuulbvuuuuuuygnuuuuuuuuuuduouuuuuuuuuuuuuuuuuuuuyuuuuuybuuuuvsuuuuuuuuuuuuuuouuubusmuuuuurugupmuoduuuuuuuuuuuuuuuuuuuuhsouuuusouuuuuurpsumbuuyfuuuuuuuuuuuuuuonuuuusvuuuuuycfuuuucybsonuduhrsghobdvqhodmouuyuuvuuuuufwduuupslhsonpuuuuunscifyohbuvsyfuuubuuooncusmpuuumucuuuuuuuuuuuuuuuuuuuuuuuulxuuuuuuunuuuuuuuuuuumudrjduuyoduuuuuuhouuuuupombugrduplvuyuufuuogiuuuuuubuuumumyuuuuusduuugufuuuuuupwuuuubugidsguumpuuuuufluuuvbuprdmuuuusdvmuxgduuuuuuucdomuuuuyspdiospupmimdusluuuuulrshyzuuuuucuuguuhucuuuuuchlpuuucuchbmuumuuuosinpmchvmpgslpybuumuusrcduuugchmcdbuucumuumuuuupyducvuuufluucgduuuuuudnyuuuuuhglybluuuuhglyrupvuuunalcosydulkuluuuhcduuulmupvlyuuuuuuuuuuuuuuuuuucuuuuulguuuupdcvyuuuupndcuuuumcuvyuuuxuuuupmuuuuuuulucyuuuccuyuurvucmnrdgyxncigdpfumguugkmuuuumocuguzduuuupvuuuuumrpuuuuugirhbududpdcufbluuuindflyuuvmfcoyuuuuuduuuuuumpyuuucuuoscpgsuuuuuugsuuuuuumspmbmhuufusuplbhudmuvnitoclaumdcucgrmchupfhuosucduufwschdswuuumpduuuuurgduuuluuuuudgrdhuuuuprvuuuusurgwkspuuhuglurspgyucllascyphoudsrpuuuuuguuuuuuuuvuuuusbuuuhguomuxufcurmyuuuuuurypduuuuudosphypduuufshpragcycycporalpbyuubgvdyuuuudsuuufsspamuuubuuumuuuuuuuuuuufuuyhuuuuuuuuuuuuuuuuuuuuuukuuuuuuuyuuuuuuuuuuuuvuuuuulfoyuuumpuuuuuuuuuuuuucsuuuucuaopuupxauuuualpmuuufduuuuuuuuuuuuugcumftusguuuuuuciluguuuluuuuuuuuuyuugsxunyuuuuuuunvtyuuuutcnsuupmdsuduuuuuuuuuuusmyuumuuyuusvgufyusgmhuhpmxuuuuudbunckguuuthuglquyufbsvlmuuuwsscfulyuydfuuuuuuuuuuuuuuuuuwguuuuuuucnuyuuuuuuupdfnuuuluutacnsluuughwdluuuuuuuuuuuuvypamovuuuuuuuuuuuuuuusmhduuuuulyhouuualbhuguxuuunbulcymnuuusyumalutcrsuuuvmnmcpyuacdlhsuxgxuuuudvguuuugvysuuuuulnrgsuulvonhcumdyflssyrhcosulubrtsdnquuuwlputsdyuuuyuucyyrhtmuuuuxuunguuuuuuuuuuguuuuuuuuuuuuuuuuuuuuuuuuuuuuuuduuuuuuuuuuuuuuuuuhpuuuuuuuumuuuuuumbduuuuuuuuudluuuuuupsluuuuliypoxmybvluuuuuuamhsuuuuuuuuuuuuuuuuuuuuluuuuulmfbuuufsguuvuudluuuuuuusopxauupuldbuuuusuuuuuuuuluuuuuuuuuuuudmuuubpopdlugufaldglafdmualatmlocwvhpmgzuyuuuuuuvushuuhusdypuuufgyuupuuuuuuuuuuuuuuuuuivuuuuumpohuuuuhgopuuuuuinocdusyupvuuuuuuuuuuuuuuuufduuuuguuuuuusdjuuuuuuuuuuuuuuuuuuuuuuuuuucopuuusguuuuuuulpsuuuuupyuupuuuuuuuuuuuuupuuuyuuuuuubocsuuuucpsuuuuuulcghuuuusdvguuuuuuuuuuuuuuuuuuukowduuuowuuuuuugulfuuuubchgxuuuuupoctmuduuuusmpksuuuuubuuuuuuuuuuupuuuuuusqulyuuusuquuuuuhltmpyuuuydtsulpmuuugdlatisbhddkgdsypblvmpuuuuuuuuuuuuuuuuuuuluuuuupmuuuuudflyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuvfuuuuuuuuuuuuuuuuuuuuguuuuudouuuuumcopduuuuuuuuspuuuuuuuuuuuuuuyduuuuudcuuumuucogusuvyuuuxpuuuuuuuuuuuuuumuuhuumuuuxylumquubsocpovduscipyfuuvguuuuuuyuuuuuuuuuuuuuubusuuuuuuuuuuuupmuuuuumupcbiuuuuuyityfcvuuuhdmcuusvlyuuuuuuuuuuuuuxbuuuuupocmuuuudghdoyuuusmpobuuuuuopcmtyuuuuustaimcyphshhmvuuusoumyuuulyhuuvuukuuulyuocdphuuhuxhuuupxuiophyhowlwacuboncvmuutcivauuudppoitanoclusuaddmacoufpduuwuuuuuuuuuuuuuuuuusyuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuufquuuuuuuuuuuuuuuuspduuuuushuuuuluupbuuuuuuuuuuuygruuuvpmuuuymgvuuuuupcjuuuuusduuuuuuuuuuuuuuuuuuuumuuuuuuyvuuusfusucmuuuuuulcspuuucbruuuurdyuuuuuuuuuuuuunyuuuuusguuuuuuncyuuusmfsnhguuqyucalinscyppcncpuuumupuuuuuuuuusuuuuusuquuufgguuuuuuuujfuuufuuuuumdfuuuurslujuuupuuodbuuuuuuuuuuuuuuuuuuuuuuuuuuuuodbuuuuuuuuuuuuumduuopfuuuuuuuuufuuuuwduuuudlyuukuuuuuuuuuuuuuuuuuuuuuumfuuuuvlsuuuupyuuuuuuuuuuuuuuuuumpyupuuuuuudpsuuuuuslubyuuuumpuuuuuuuuuuuuuuuuuuuuuuuuuuuguuuuuuuuuuuuuuuuuuuudruuuugouuuuuuuuuuuuuuuuuuuygfcuuupubcuuumcouuuuuuuuuuuuuuuuuugfcuuuuuuuuuuuuuuuuuuuuuuuuuuduuuuuurmpucuuupcruuuuuuuuuuuuuuuuupuuuuuuuuuluuuuuufluuuuuur
1392  | 1848                     | ertaniocvslogppppppppppppppppppppppppppvypppppcyopmppmppppppppppdppppuprvppuprdgyppwrpppppgidpppppdouppppppppppppmppppppozpppppdrgoypcdcmopfpmppspdiwpdhdmidfpmpopppkbvypppspsyupppppposcpmhppchuppppppchbrmpmppuosinpmchvmpdmlpppppcmphpppgfgrmchpppdposucdpplwschpslhbppppfpcgdppppyplpppppprdgppblpprvcdpppprgwkpppphgglurspgypcllascyphoupsrvlypppgppppppppppvpppbppplgcolmpdcvyrmyppndcurypmlvmppdosphypppppfshprauypcyccoralpbyucnmvdypxncigdpblmgpsgpdppppppmpppzpvbpppdmppppsdvmpxgfgihbudppppdcuplppppindflyppvmfgvppppdppppppppgpppppcppppppgspppslpgsppppppmspmbhpppfpsuplbhppppvnitoclaumdcufmtppppppdpcumppppppppppppugpvpdppppnvtypmppmnybcppsptcnsppppppppvppvpppppppppppppphypppgupfyplmpyphpgppppppdbunckghgxthuglyycpfbsppppppwspppppppppppppvyppppppppppppwgpppppcycnsucuypppupdfnpppppptacnslupsphwdlpppymocugppgkyppppyhppppppuppppampsmhpppppflynbppppuyhugpppppppplcymnpppmpppalutcrspppppnmcpypfbppppppppppfdappppalpmyspxppppnryppppdsnhcmappppssyrhpppxppprtsdnapppwpyutsdgspppppcyyrhtmppdypppusmypppmdspvmghppupppppufcppdpppppsvgppppsgmhpppmxppppppppppppppupppppqupppppvlmgppppscfulyupdfppppppsppppppdpppppppppppppppppppplcppppgfpppppudvppppsbppppppppppppppppppppadpppppppppppppppppppphuppppxspppppalbhmppdvppppppkppppplfyoppppdvgppppvmpppppcacdlpcoxgxpppgcppppppppppppppplhppppplvbylypmdylsgpgfpcocisulxpllgpppfpppppvppppppppppppppppppppgppppppppppppppppppppppppppppppppppppppppppppppdpppppppppppppppppppppppppppmppppppmbdpppphpppppppppppppppppppppplappppvlppppamhspppppppppppppppppppplppppppppppppfsgppgppdlulugpppsopxapppplppppppppppppppplpppppuppppppdmpppppppdlpphoaldglappppalatmlocwpvpmgzpomvppvppppppphppppppppppppphupppppolmfbppdmpppppppppppppppppppppppppppppppgpppppppppppppppppppppppppppfudppppsdjuppppppdmpppppppppppppppppcopppppgpshpppplpuslppppypppppppppppppppppppphpppppphdlppppyliypoxmpblcowkdgpppppppppppppppppppppppppppppcshgpppppdguppvppppchgxppppppoctmppdbppsmusppppppppppppppppppdupppppsbpofpppsdylpppphlduymppppptsubqlypppplatisbgupmgdsusdypppfyvpypppppppppppppppppppivpppppmpohpppphgohpppppinocdusyppvppppupppppvfppppppppppppppppppppgpppppdopppppmcopdppppppppppppppspppppppppydpppppdcppppupcogupppppppppppppppppppppppppppsuppppxyppppppbsouyppppscipyfppvgpppppppppppppppppppppblfppppuppppppppmsppppbupcbimpvppyityfcvppppdmcppppppppppppppppppsxbppppppocmxpppdghpvppppsmpobpppppopcmtypppppstaimcyphpchmvppppppppppppphpppppkppdflyocdphpppuxhppppppiophyppppwacubpppvmuutcivapppsppoitanocluspaddmacopfpdpppvluppppspppppbplyppppppppppppppppppmppppppsuvypppxpuppfqpppppppppmpppppmppppplumqpppggcpopvdupppppppbppprpppppmpppypppppppppppspppppppppppppppppppmppppppppppppppppppsfhlpppsvlyppppppppppbrpppprdypppppuppppppdoypppppppppppppppppppsmpppppvppppppsyupppppsoumyppplypppppppppsppppdsuqpphfguppppxpppjfphowlppppmoncupprsldfppuppppppppppppppppppppppppppppppujppppppppppppppppppmdppppppppppppppfppppwdvsypdlyppkppppppppppppppppupspdpmfpushplsulpppypppppppppppygppppvlpppupmgvpdpsppcjpslubyppuumppppppppppppppppmupppppyvppppppsucmpppppulcsppppcdrppppppppppppppppppppnypppygsgfcppppncypppppfsnhgppqypcalinscgfpcncpppppppppppppppppcpppppdpppppprmucpppppcrppppppppppyppppppppppppodbylppppppflpppppprucmfgppplcpruypypppppppppppppppppppopfppppppppppppppppppppppppppppppoppppppppppppppppppppypuvppybppppppppppppppppppppompyppsmppppprugppppodmppppppppppppppppppphsoppppsopppppprypbopppyfppppppppppppgpouppgomoppppphwdpppppybsdpppgprsghfowdqmcopppppppppppppppppppcubppppcfoyppppoyuhpppppsfyppppmpconcusmppfmumcppppppppppppppppppppppppppppppppppppppppppppoppprjdbvppppppppppppppppdppppprdpppdsppppppgohcpppygnbppppmypppppsdpppppfpppppppppppppppppppppmppppppflpppppppruypppppppppppppppppppppppuppmppppppspppppppuslppppplrshyppppsbpumpppppppppppppppppponppppcumppppcfpyducpcnuslpybbmkfvsrcdvppccymcdyonphoppppppombppppsonppppmpnsicupudhuvbppnhglypppnyphglyrpppppunalcosydplkulppppmdpppppdppppppppppppppp
1396  | 1865                     | ertaniocvsluuuuuuuuuuuuuuuuuuuuuuuvyupmucyoduuuuuuuuuuuuuuurvuugurdgyuuurpuupwuuuuuugiduuuuudouuuuuuumuuuuuufuuuuuozrgoyuduukgucmcdomudmuospdiwuuupmiduuumfouuuuusyuuuuuuuoscpmhhucuuuuuchdigurluchbmuuuuuuosinpmchvmpgmdrcguuuuugrmchuuuuuosucpmufwschdswuudulbuuupslhucgdduuuuuurdgyuuuuprvbluuuurcluuuuxhgglurspyuuuulascyphovdsrpuupvllxuuugduuuuyuuubuuucumomulguuurmdcvuuuurpndcuuuumosphyulvyufshpragcucychoralpcduubuvducnmuuguxncigdpulmguubmuuusguuuuuuzuuuuupvvbuuudmuuuusdgiuhgbduupdcuuuuuuuindflyuuvmfcuuuuuuvuuuuuuuguuuuucuuuuubgsuuuuuugsuumvuumspmbhuuufusuplbhuuyuvnitoclmftdlucyfquuuuupuuuubcucumuuuuuuuuuuunyuuuuuuunvtyuuutcnsuuuuuuuuuuuuuupuuuuuuupvuuuyuuuuuufyuuhuuuhpguuuulmdbunckguuuthuglyycafbsuuuuuuwsuuuuupyuuuuuuuuuxuuuuuuuuvywguuuuuudcnuyuuuusyupdfnucyluutacnsluupghwdlspafuyhuugkmuyuumocugudmduuuuuuuuusmhuuuuuulynbuuuuuuhuguuyuuuuulcymnuuuuuuualutcrsumpuunmcpyuuuuuumuuuuuuuauuuffdauuysalpmubnryuuuudunhcuuuuuussyrhpuuuuuurtsdnuuuuwuputsdyxuuyugcyyrhtmuuuuuuunguuuuusymuupmdsuvmuusuduuuuuuuuuudufcuusdghuuusgmhuuumxuuuuuuuuuuuuuuuuuuuuquuuuuuvlmuuuuuscfulyuudfuuuuuuuuuuuuguuuuupduuuuuuuuuuuuuuuuuuuulcuuuugfuvuuuudsuuuusbuuuuuuuuuuuuuuaduuuuuuuuuuuuuuuuuuuuhuuuuuxuuuuuualbhmuudvuuuuuuuuuuuuukyuuulfdvguuuuvmuuuuuuacdlucuxgxucopuuuupgoyuuuuuuuulhuuuuulvbycuumdylyfugfucosulxuvciluguuusguuuuuuuuuuuuuuuuuuuuuuguuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuduuuuuuuuuuuuuuuuuuuuuuuuuuumuuuuuumbduuuuuuuuuuuuhouuuuuuuuuuuuplauuuuvluuuuuuamhsuuuuuuuuuuuuuuuuuuuuluupuuuuuuuuufsguuuuudlusuuuuuspoxauvuumuuuuuuuuuuuuuuuluuuuuuuuuuuudluuuuuulafuuuugudglaouuuuuatmlocwvopmgzuuuuuupomvuuuuhuuuuuuuuuuuuupuuuuuhhuuuuuolmfbuudmuuuuuuguuuuuuuuuuuuuuuuuuguuuuuuuuuuuuuuuuuuuuuuuuuuufuduuuusdjuuuuuuuuuuuuudmuuuuuuuuuuucopuuuuguuuuuuulpsuuuuhpyuuuuuuuuuuuuuuuuuushyuuuugybocsuuupcsubuuliylcghybuuddvguuuuuuuuuuuuuuuuuuukowduuuowuuuuuuguuuuuuubchgxuuuuupoctmpuuuuusmpkuuuuusuuuuuuuuuuuuduuuuuusqulyuubsuquuuguhltmpyupoydtsubqlyuugdlatisbhdpmgdsypdxuuusdyuuuuuvuuuuuuuuuuuuvuuuuuuuuivuuuuumpohuuuuhgopuuuuuinocdusydpvuuubvfuuuuuuuuuuuuuuuuuuuuguuuuudouuuuumcopduuuuuuuuuuuuuuuuuuuuspuuyduuuuudcuuuuuucoguuuuuuuuuuuuupuuuuuuuuuuuuuhuuuuupsuuuuuuubsouyuuupscipyfuuvguuuuuuuuuuuuuuuuuuuuubuuuuuuluuuuuuupmuuuuuufpcbibuuuuyitpmvuuugudmcuuuuuuuuuuuuuuuuuuuuuuuuuuxcyouuuufycvuuususmpsblyuuuopcmtyuuuuustaimcyphvmhmvuuuuuuuuuuuvuhuuulukuuusluocdfuuuuuxhuuuuuuiophyuuuuwacubuuuvmuutcivauuudppoitanoclusuaddmacoufpduuuuuuuuuuuuuuuuspuuuuuuuuuuuuuuuuuuuuuuuuuumlyuuuusuvyuufxpuuuuuuuuuuuuuumuuuqumuuuuulumquupbgcpovduuuuuuuruuuupmuuuyuuuuuuuuuuuuuuuusuuuuuuuuuuuuuuuuuuumuuuuuuuuuuuuusfuuuuuhluuuusvlyuuuubruuuurdyuuuuuuuuuuuuuuuuuudoyuuuuuuuuuuuuusmuuuuuuuuuuuvuuuuuusyuuuuuusoumyuuulyuuupuuuuusuquudfguuuhwuuuujpxuufuuuhomdfuuuuosrpndcuuduuuuuuuuuuuuuuuuuuuuuuuuuuuuuuvuuuuuuuuuuuuuuuuuulujuuuuuuuuuuuuuuuuuumduuuuumpcuufuuuuuuuuuuuuuuudguuuuluuuuuudrunhuupuuuuuuuuuuuuuuulyyguulumcuuumrfuuuuslcnvcypypuuuuuuuuuuuuuuuuuuuuuuuuuuuuupjuuuuuupyvuuuuululcsgfyuubuuuuuuuuuuuuuuupuuuuubyuuuuusguuuuunncyuuudrfsnhguuqyucalinscyvpcncyluuuupuuuuuuuuuuuuuuuuuuuuuuugupcruuuuuuuuuuuuuuuodbuuuuuuuuuluodbuufluuuuuurucmfguuulcpruyubuuuuuuuuuuuuuuugfcuuuuuuuopfuuuuuuuuuuuuuuuuduuuuuurmucpuuuduuuuuuuuuuuuuouuuuuybuvuuuuuuuuuuuuuuuuuuouuuuusmpyuuuruguuuuodmuuuuuuuuuuuuuuuuuuuhsouuuusouuuuuurypbouugyfuuuuuuuuuuuuuuouuuuumouugouhwduuuuuybsduuugprsghfowduhospuumcouuupbcuuuuuuucuuuuuucfoyuuuuoyuhuuuuusfyuuuumpconcusmpufmumcuuuuuuuuuuuuuuuupuuuuupuuuuuuuuuuuuuuuuuuuuuuuuurjduuuuuubvuuuuuuuuuuduuuuurdpuuuuuuuudsuuuuupgohbuuuygmyuucuusduuuuufuuuuuuuuuuuuuuuuuuuuumpuuuuufluuuuuupruyuuuuuuuuuuuuuuuuuuuuuuuuuumuunuuusuuuuuuuusluuuuulrshyuuuuuuuuuusbpumuuuuuuuuuuuucuuuuuoumuuucuupyducfuuuslpcnuuufvsrcdvuuuybmcdyuyhgkbuuuhouuuuupombuuuusonpuuuuunsicuuuhbumbuuuuuuuhglyruuuumunalcosyluykuluuuuduuuuuuuuuuuuduuuuuuuuuuuuuuuuuuuug
1402  | 1909                     | ertaniocvslpppkgpwppppppgidpppppumfoppuppsyppppppposcpomhppppdpppppzmcdomrpppospdiwpuupmdmipppfocmphpppgfgrmcupppdposuchphfwchcdswpppcmpoppppiuosinpmchdgpgmpppppvprvpppppdrgwkpppphgglurspyppcllascyphoudsrdscgppgppppppppppppppblppppcgpplpppprmypppppprypddlbppdsophlypupcfshprafcppymcoralpbyvlbpvdlglyppydcvypppppndcppppmcpppppppppppgpppppppplppppppcdppppppucnmppppxncigdpplmgppppppppppplpxpzppppppvpppppmdpppsppgihbudpvbpdcuqpppmpindflyppvmfcpuupppppppmftpgvmpppcdmpppusdgugxgpgscpyuppuspmnyplyfpsuplbhppppdnitoclaumvcucyfqpbhppppppppnvtypppmvfpvpppjdpbcupppppptcnspppppsthugllypppbspvppppppubcppcumpppppppppppppppppppwghppppppcubckgpxppupsycmlppnltacnspvppdhwdlppmpppphppppguppplmpypppppupppppppsmhpppxpplynblupppphugppppspamlcymnmppppvyalutcrsfyhppnmcpyppcyppppcuypppppppppppppyuspppfpnrypgkmpfnhmocugudssyrhpdpmppprtsdnppppwpputsdypppyppcayrhtmpppppppngpfblppppppppppppypppppppppppppppppmpppppppppppppppppppppuappppfdappppulpmpppdapppppppppxppppgspppppmdspdmsgmhpppplusmpppppppppdsupppppqupppppvlmpppypscfuufcldfppupgpppppppppppppyppppppppppppppppppppppppppppppvpgppppppppppppppppppppspppadpdpppppppppppppppppphulcppxpgfpppaludsppdvsbppppppppppppbhmpppdvgppppvmppppppacdlpppxgxppppppkppppppppppppplhppppplvbypplmdylfvpgfpcosulxppplgppppppcoppppppgcpppppppppppppgpppppfoypppplypppppsgpppppccilugppplppppppppppdpppppppppppppppppppppppppppmppppppmbdppppppppppppppppppppppppppplappppvlppppppamhspppppppppppppppppppplpppppphoppppfsgpppppdluppppppsopxapppplppppppppppppppplpppppuppppppdmpppppppdlppppamdglappspalatmlocwvhpmgzpspppppppppppphppppppppppppppppppppppppomvpppppppppppppppppppppppphspppppppgppppppppppppupppppgspppppolfudppdmsdjupppppppppppppppppppppppppmbpppppgcoppppplpsupppppyppppppppppppppppppppypdmpppbocsppppcsubppppplcghppshddvgphpppppfpppppppppppkowdpppowppdlppgupupslpbchliypoxmpoctmpypbppsmpkppppppppppppppgxppduppmppsqulypppsuqpvppphltmpyuppydtsubqlyupgdlatisubppmgdsuypppppppppppppppppbpofgufmppppppppppppppppppphppmppyppppppvpppppppsdyppppppdopppppppppppppppppppibhppppmpohpppmhgopppvfpinocdusyppvppppppppcopdpppdyppppppcogupppppppppppppppppppppppppphppppppxyppspppbsouyppppscipyfppvgpppppppppppppppppppppbppppppuppppsuppmppppppppcbipppppyityfcvppppdmcpppppppppppppppppppxlfbppppocmxpppdghppppbusmpompvpppopcmtypppppstaimcyphpchmvppppppspppppphpppppkppppppocdphpppuxhppppppiophyppppwacubpppvmuutcivapppdppoitanocluspaddmacopfpdpppppppvppppppppppppppppppppppppppppppppslpbyppppppppppppfqpppupppppvlupppppflyppppppppppppppbppppppppppspprpppspmpppyxpupppppppppppppppppppuvyppppumqppppmcpovdupppppppsfpppppppppppppppppppbrpppsrdyppppppppppppppppmpppppppppppppppppsmphlppppsvlyppppppppppppppppppppppppupppsppdoysuqpppfguppppppppjfpppfpppvpmdfppsyrslujpsoupppuplyppppppppppppppmypppphwppppppxpppppphowlpppmdoncvsyppfdppppfppppwdppppdlyppkppppppppppppppppupppppmfppppplsuppppypppppppppppppppppppuppupppppdpspppppslubyppuumpspdppppushpppplpppppppppppppppygppppvlpppppmgvppdrppcjpppppsdppppppppppppppygfcppmupppppyvppppppsucmpppppulcspgfccppppppppppppppppppppppnypdpppsgprmucpncypcrppfsnhgppqypcalinscyvpcncpplppppppflpppppprucmfgppplcpruypbppppppppppppppppgpppppppppodbpodbpppppppppppppppppppoppppppppppppppppppppypppppybppppopfpppppppppppppopppppsmppppprugppppodmpppppppppppppppppuvhsoppppsopppppprypbopppyfmpypppppppppppouppppmoppppphwdpppppybsdpppgprsghfowdqhospgpppppppppppppppppcppppppcfgoppppoyuhpppppsfypppompconcusmppfmmcouppppppppppppbcppppppppppppppppppppppppppppppppprjdppppppppppppppppppdppppprdppppppppppppppppppppbpppppmypppppsdpppppbvppppppppppppppppppppmppppppflppppppprsdhppyggnpppppohcpppppppppppuypppppsppppppmuslppppplrshypppppppppppppppppppppppppppcppppppumuppppppyducvpppslpybpppfvsrcdpppccsmcdyppyppppppppppppppppubpppompppppcfudnyppcnuhglynbmkpphglyrpppppunalcosydplkulpombmdppsonppppppnsicdpphbuvbppppppppppppppppppppppppppppppppppppppppppppppppuppppppppppppppppppppmpppppogrdypprppppppppppppppppppppvypppppcyodpppmfppppppprgoy

O script que eu usei para gerar as seqüências de dados está aqui , caso seja útil para qualquer pessoa!


Infelizmente, isso trava ao usar o apontador oficial. Lembre-se de que, em certo sentido, você realmente recebe apenas 5 palpites errados; o sexto palpite errado faz com que você perca instantaneamente.
Nneonneo

@nneonneo Ah ok, obrigado! Vou tentar corrigir isso e excluí-lo se não puder. No meu teste manual, espera que o sexto palpite errado seja uma perda, mas talvez eu tenha algo errado com as condições finais.
tttppp

Apenas para adicionar algumas informações extras para ajudá-lo a depurar: quando fornecida com a palavra distinct, a saída do seu programa era, em ordem eitanogsuc, o que significa que de alguma forma deixa de fornecer saída, mesmo que apenas adivinhe incorretamente por 5 vezes.
precisa saber é o seguinte

@ace Brilhante, obrigado. Isso é muito útil.
tttppp

@ace Por favor, você pode testar novamente isso? Testei manualmente "distinto", que agora perde no ponto correto (também testei "polvo", que perde, "ouvido", que vence e "END", que termina). Obrigado!
tttppp

1

A linguagem de programação D é minha ferramenta de escolha para este desafio.

A poucos metros do limite de 2.048 bytes, embora em algumas partes seja um pouco de golfe para diminuir a contagem de bytes, todo o trabalho pesado permanece perfeitamente legível. Esse solucionador não é muito bom em seu trabalho, e espero que seja derrotado facilmente, mas isso é apenas para fazer a bola rolar. Comece as coisas, por assim dizer.

EDIT # 1 :Como foi apontado, o código original é propenso a sofrer uma morte horrível quando esgota todas as vogais. Como ele não funciona corretamente, substituí-lo por uma abordagem um pouco mais brutal à adivinhação aleatória.

EDIT # 2 : o código original foi corrigido e agora permanece.

Pontuação :

25.7; totalerr: 24,529.9 (average of 10 tests).

Como funciona

Este solucionador é completamente aleatório. Até a aleatoriedade é aleatória, momentos divertidos!

Quando o programa recebe entrada, ele adivinha um caractere aleatório que ainda não adivinhou e o envia para STDOUT.

O algoritmo de adivinhação funciona assim:

  1. Selecione aleatoriamente um dos dois grupos de caracteres (consoantes ou vogais).
  2. Selecione aleatoriamente um dos dois modos:
    • Use a frequência das letras como peso no RNG. É mais provável que uma frequência mais alta seja selecionada.
    • Escolha um personagem em um índice aleatório, independentemente da frequência.
  3. Retorne um único caractere com base no modo selecionado na etapa 2.
import std.stdio, std.random, std.array, std.math, std.algorithm;

alias double[char] Hash;
alias uniform U;

bool first = true;
Hash cons, vowel;
char[] guessed;
Mt19937 rng;

int fails;

void main()
{
    rng.seed( unpredictableSeed );

    auto get() { return stdin.readln.replace( "\r", "" ).replace( "\n", "" ); }

    string input, last;

    while( ( input = get ) != "END" )
    {
        if( first ) last = input;
        if( input == last && !first ) ++fails;

        if( fails == 6 || !input.any!( x => x == '_' ) )
        {
            fails = 0;
            last = null;
            guessed = [];
            first = true;
            continue;
        }

        stdout.writeln( guess );
        stdout.flush;

        if( !first ) last = input;
        if( first ) first = false;
    }
}

char guess()
{
    reroll:
    Hash group;
    double min, max;
    bool useWeight = U( 0, 2, rng ) == 1;

    if( guessed.filter!( c => vowel.keys.any!( x => x == c ) ).count < vowel.length && U( 0, 2, rng ) == 1 )
    {
        group = vowel;
        min = useWeight ? 2.758 : 0;
        max = useWeight ? 12.702 : 4;
    }
    else
    {
        group = cons;
        min = useWeight ? 0.074 : 0;
        max = useWeight ? 9.056 : 20;
    }

    double choice = U!( "()" )( min, max, rng );
    char chr;

    if( useWeight )
    {
        foreach( k, v; group )
            if( v < choice )
                chr = k;
    }
    else
    {
        int counter = 0;

        foreach( k, v; group )
        {
            if( counter == cast( int )choice.floor )
            {
                chr = k;
                break;
            }

            ++counter;
        }
    }

    if( guessed.any!( x => chr == x ) || chr == char.init )
        goto reroll;
    else
    {
        guessed ~= chr;
        return chr;
    }
}

K keys( K, V )( V[K] a )
{
    K[] ks;
    foreach( k, v; a )  ks ~= k;
    return ks;
}

static this()
{
    cons = [ 't': 9.056, 'n': 6.749, 's': 6.327, 'h': 6.049, 'r': 5.987, 'd': 4.253, 'l': 4.025, 'c': 2.782, 'm': 2.406, 'w': 2.360, 'f': 2.228, 'g': 2.015, 'y': 1.974, 'p': 1.929, 'b': 1.492, 'v': 0.978, 'k': 0.772, 'j': 0.153, 'x': 0.150, 'q': 0.095, 'z': 0.074 ];
    vowel = [ 'e': 12.702, 'a': 8.167, 'o': 7.507, 'i': 6.966, 'u': 2.758 ];
}

@ace Parece que ele fica preso em um ciclo interminável de relaminação depois de esgotar todas as vogais. Não sei ao certo por que agora, mas até que eu consiga resolver isso, editei uma versão menos sofisticada. Posso ou não repassar vogal / consoante.
Tony Ellis

Usando o compilador dmd, ocorre um erro ./test.d(44): Error: cannot implicitly convert expression (uniform(0, Letters.length, rng)) of type ulong to int. Eu consegui consertar isso cast(int). Após 10 execuções, sua pontuação média é de 22,4 palavras, com 24529,1 palpites incorretos. I vai voltar a testar se você fixar a versão mais avançada :) divertimento têm
user12205

@ace Isso é ainda melhor do que eu pensava. Ha. De qualquer forma, o adivinho "mais inteligente" está consertado agora, embora, para ser honesto, funcionasse melhor quando estava quebrado, vá em frente.
Tony Ellis

Qual é o placar agora?
Just

@justhalf score = 25.7, totalerr = 24529.9 (média de 10 testes)
user12205

0

Solução JAVASCRIPT + HTML

<!DOCTYPE html>

<head>

    <title>Hangman Game</title>
    <meta charset="utf-8">

    <style type="text/css">

        *{

            font-family: sans-serif;
            color: teal;

        }

        #man {

            float: right;
            margin-left: 0%;
            position: absolute;
            top: 20px;
            left: 50%;

        }

    </style>

</head>

<body>

    <div>
        <h1>Welcome To Hangman!</h1>
        <h2>Your current word to guess is: <span id="word"></span></h2>
        <input type="text" name="letter" id="letter">
        <h3>You entered the letter: <span id="chosenLetter"></span></h3>
        <h3>Incorrect Letters: <span id="incorrect"></span></h3>
        <h3>Chances Left: <span id="chance"></span></h3>
        <h2>Game Status: <span id='gameStatus'>In Progress</span></h2>
        <img id='man' src="../images/hangman/white.PNG" />

    </div>

    <script type="text/javascript">

        var word = document.getElementById('word');
        var input = document.getElementById('letter');
        var displayLetter = document.getElementById('chosenLetter');
        var chanceDisplay = document.getElementById('chance');
        var gameStatus = document.getElementById('gameStatus');
        var image = document.getElementById('man');
        var incorrect = document.getElementById('incorrect');
        var list = ['apple', 'banana', 'elephant', 'fruit', 'pencil', 'boomerang', 'trophy', 'slippers', 'university', 'curtain','connection', 'grandmother', 'inflation', 'recording', 'conversation', 'king', 'reception', 'distribution', 'cigarette'];
        var imagesList = ['white.PNG','one.PNG','two.PNG','three.PNG','four.PNG','five.PNG','six.PNG','seven.PNG','eight.PNG'];
        var imagesIndex = 0;
        image.src = "../images/hangman/" + imagesList[imagesIndex];
        var currentWordIndex = Math.floor(Math.random()* list.length);
        var currentW = list[currentWordIndex];
        console.log(currentW);
        var wordLength = currentW.length;
        var chances= 8;
        chanceDisplay.textContent = chances;
        for(i = 0; i < wordLength; i++){

            var nodeDash = document.createElement('span');
            nodeDash.classList.add('dash');
            var textNode = document.createTextNode(' _ ');
            nodeDash.appendChild(textNode);
            word.append(nodeDash);

        }
        var dashes = document.getElementsByClassName('dash');

        input.addEventListener('keyup', function(){

            event.preventDefault();
            var alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
            if(event.keyCode === 13){

                var letterChosen = input.value;
                input.value = '';
                var match = 0;
                var checkLength = letterChosen.length;
                if(checkLength === 1){

                    console.log('length is correct');
                    var checkIfLetter = 0;
                    var checkIfCorrect = 0;

                    for(i = 0; i < alphabet.length; i++){

                        if(alphabet[i] == letterChosen){

                            console.log('is an alphabetic letter');
                            match += 1;
                            checkIfLetter++;
                            displayLetter.innerHTML = letterChosen;

                        } 

                    }

                    if(checkIfLetter == 0){

                        displayLetter.innerHTML = 'Not A Single Letter';

                    }

                    if(match == 1){

                        var checkIfDone = 0;

                        for(i = 0; i < (1 + currentW.length); i++){

                            if(letterChosen == currentW[i]){

                                dashes[i].textContent = ' ' + letterChosen + ' ';

                            } else{

                                checkIfCorrect ++;

                            }

                        }

                        for(i = 0; i < currentW.length; i++){

                            var temporaryCheck = ' ' + currentW[i] + ' ';

                            if(dashes[i].textContent == temporaryCheck){

                                checkIfDone++;

                            }

                        }

                        if(checkIfDone == currentW.length){

                            gameStatus.innerHTML = 'GAME ENDED: YOU WON!';
                            gameStatus.style.color = 'lightgreen';

                            for(i = 0; i < dashes.length; i++){

                                dashes[i].style.color = 'lightgreen';

                            }

                        }

                        if(!(checkIfCorrect <= currentW.length)){

                            incorrect.innerHTML += (letterChosen + ', ');
                            chances--;
                            chanceDisplay.textContent = chances;
                            imagesIndex++;
                            image.src = "../images/hangman/" + imagesList[imagesIndex];
                            if(chances == 0){

                                for(i = 0; i < dashes.length; i++){

                                    if(dashes[i].innerHTML == ' _ '){

                                        dashes[i].innerHTML = ' ' + currentW[i] + ' ';
                                        dashes[i].style.color = 'red';

                                    }

                                    gameStatus.innerHTML = 'GAME OVER: TRY AGAIN';

                                }


                            }

                        }

                    }

                } else{

                    displayLetter.innerHTML = "Not A Single Letter";

                }

            }

        });



    </script>

</body>


1
Bem-vindo ao PPCG! Parece um jogo da forca; infelizmente, a pergunta é sobre escrever um solucionador de forca (um programa que executa o forca em vez de permitir que o usuário jogue).
OOBalance
Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.