title: Write a Hangman Solver

text:
# Question
Title: Write a Hangman Solver
You are required to write a Hangman solver. Testing against this English word list\[1\], the solver that solves the most number of words wins, with the number of total incorrect guesses being the tie-breaker. All words in the word list will be tested in random order.

\[1\]: This word list is taken from here, then the numbers are removed, then words with length 1 or with non-alphabetical characters are removed, then the most frequent 4096 unique words are chosen as this word list.

### The details:

Your program will interact with the game program, which will give you through stdin the underscores and correctly guessed letters. Your program will give to stdout your guesses, and it has to infer from the input whether the previous guess was right or wrong. After being wrong for 6 times, your program loses. Your program must be ready for the next game after each game ends (after win or loss).

Your code length must be strictly less than 2048 bytes, and your program must not use any external resources (including but not limited to accessing the wordlist on local storage or from the Internet).

**Example**: (Input is preceded by `>` here only for clarification - it is not actually present in the input)

```
>_______         // 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

```

Suppose you are wrong for 6 times, you will receive a final input which implies your guess is wrong, and your program must be ready to start a new round (i.e. take another input).

If you win,

```
>_angman
h
>hangman
>_____           // new round

```

After knowing that you have won (because the input has no underscores), you must be ready to accept the next round.

Your program must terminate when it receives an input `END`.

If your program is not deterministic (depends on randomness, pseudorandomness, system time, ambient temperature, my mood etc.), you must explicitly state that in your submission, and your score will be taken 10 times (by me, unless otherwise instructed) and averaged.

**Note**: if you use languages like python, please explicitly flush your stdout after each print statement.

The game program is as follows (credit to 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')

```

Usage: `python ./game.py [yoursolverprogram]`

Example: `python ./game.py ruby ./solver.rb`

This should work like the old scoring program, but does not depend on named pipes, so it can work on other platforms. Refer to the revision history if you are interested in the old one.

# Answer
> 1 votes
# Python 2, score=2111

Run with `python -u`. (For testing with the given controller, `python ./game.py python -u ./solver.py`.) This is 2044 code bytes + 1 for `-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()

```

### Result

```
score is 2111, totalerr is 20751

```

### How it works

The program replaces all `_`s with `1`s in the current state, treats the result as a base-36 integer, and takes it modulo 1879, giving us a crude hash function. It chooses a letter to guess by indexing this hash value into the long string of letters. If it already guessed that letter before, it decreases the modulus by 6 (so it always remains relatively prime to 36) and picks a different letter, repeating until it finds a letter that it didn’t guess yet.

I designed this strategy to have many tweakable variables (the individual letters of the long string), most of which will independently affect the final score by a small amount. That makes it well suited to hill-climbing style optimization—I used Diversified Late Acceptance Search.

# Python 2, score=2854

With liberal usage of non-printable bytes and built-in compression, we can squeeze in a lot more information.

Decode with `xxd -r`, and run with `python -u`. (For testing with the given controller, `python ./game.py python -u ./solver.py`.) This is 2047 code bytes + 1 for `-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()

```

### Result

```
score is 2854, totalerr is 19482

```

# Answer
> 9 votes
# Python: 2006 bytes, score=1501

# ~~1885 bytes, score=1337~~

# ~~1961 bytes, score=1207~~

Here's my submission:

```
import sys
b='eJwdVQuW4ygMvJdyGgwYtAGJQQKHOf2Wp9/rJqGxVaqP+HxUMlGx5F86/XoqsUuonzAz5cf5vqjJ6OlQudxOJR3ibJ8cwuSmsTX12daVht8ubj15miaEH/GrESXrQrXbl1K0m2hs6dRjMkp1PuS2/9JoVslkLmp2L6J6f5kij4s0nkSPni/5GZtixSuKcKd7lYvsfi7yNYxseKXqV6fURkc//KXe+P6Hc071xuZteixiSRtzMnavwNfqcydqSzb+9hMTlW/UQSNe5uRx1EVp1OhA7gXb0v+i0rKN1rYsGlWBufozlFbzP+i2KXCpNKNjfTwkytcBnv+OgoV6blJ/8NDjF6iqUd2ojqcbrScmIaurHJxs6yHjck96brZJwncsIOHhzwyemZurKFrkmpIX9yXSNGsKdF+F+rF2fam0+KAMj3YdoXFJR+nY7AL4y1jaopNuBhk6sl03pSd7x2IxoyeLO6dGedjp9V0inusji0EAyR4pBttN6dt+UR/SYBHCVwuxPZSvqNYpZhPIWXM3Segs30IFXKZKSzqDkcdORud59xVJ8o4WsJQelUqXnIAjV/2whDybo1mDmhYCeAjZV4552gSWOa5aSG3WZ0SaqZVe4Y+o7R+Ps5knum0pDGNxrKA3De3Lwo/si420aemw2g/tdq5sKN1HyltpLNeY/qPUYwsLatc/pwRq5eSwK4l5LhHEnSIZhhG9xsFqeqDMRctmTnVQRoamwUtloiLNrgV+a0uzHBKAyUYl61yD+m++GkgeW1eiuMDEoCR6504z32V9JHD25tPVHFyXOGOc+A2vABogIw9vfxWBatuHwaWggEELdS+8De8z7ZHhir70cLoQpYYDOgfMw+ASbrhnbrwQ27x4TNt/3qHBEPSmwzlagqlH5J4Bk2FBqEvc9fXORUnnnceiMAc2kALwNdOB4W87eAw2uAwsIncpu+IYutsJwsJ/JfusCZNipqyL8uwjNHuDN3MJQBSg/Sr1ppByfD9RWaAt/QhLGDDv2C1PxSvBbfyEFqNO5ZwZpE2yqd2PjEwueV1aJoBdGxNjSl8klx3nuWAAxgCxKePt0bykLrCcQWspM61K3qcNuJYa53VMBWKNJCsrYkzZGfZf49fotx3ZYURvyYQ+GR6iOVCfT6fB4hkehfOws/k3PjFo82ZgaE60TxccO4DqKEKDVXSsuknSmuzZwB8C+h7YBS3oaRPSyGvurfnNvM2bMustIxXMYsM/WdvAvLn8hIx5CMCJQxEM2P2yLuyWYHvZziC+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())

```

Score output:

```
score is 1501, totalerr is 21608

```

This program is fully deterministic. The giant blob (which is a base-64-encoded chunk of `zlib` compressed data) is a list of decision trees (one tree per word length). Each decision tree encodes a complete binary tree with a depth between 2 and 5. Each internal node is a single character, and the decision proceeds based on whether the character is present or not in the hangman word.

Each leaf node of the binary tree contains an optimized frequency table specific to that branch of the tree search. The table is specifically optimized to favor completion of certain words, while completely ignoring others (which it cannot reach due to the limited "failure" budget). The table isn't optimized to minimize errors, and thus the totalerr count of the program is high despite its (relatively) good score.

The optimizer, which isn't shown, uses a nondeterministic nonlinear optimizer utilizing a randomized gradient descent strategy to produce the frequency tables.

# Answer
> 5 votes
## Ruby

A joint submission from user PragTob and myself.

```
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

```

Result:

```
score is 625, totalerr is 23196

```

This has 1672 characters and isn't golfed yet so we have ample room for algorithmic improvement.

First we store a hash of character frequencies (computed from the word list) grouped by word length.

Then in each round we simply sort all characters by the frequencies for the current length and try them from most common to least common one. Using this approach we obviously fail every single word that has even just a medium common character.

# Answer
> 5 votes
**Update** Using method similar to @nneonneo, I arrive to this code, **exactly 2047 chars**.

Score:

```
score is 987, totalerr is 21964
```

Code:

```
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

```

---

**Old entry**

Result:

```
score is 656, totalerr is 22962
```

It's not an average since this algorithm is deterministic, i.e., it always gives the same score for any shuffled list of words.

Here is my entry in Python 2.7; golfed (717 characters)

```
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

```

This uses similar idea as @m.buettner, storing an ordered list of letters following which the guesses will be made. But, this does not use frequency data directly, rather, it just tries almost every possible letter permutation and simulate the game, and finally taking the permutation that gives the best score.

This version is optimized using the top-9 letters, so for 2-letter and 3-letter words, the permutation is already the optimal one, in the class of algorithm where the information from previous input is ignored. I'm currently still running the code for top-10 letters, optimizing the 4-letter words (and also finding better solution for longer words).

---

**Invalid entry**

For my benchmarking, here is the code that uses the full decision tree, 11092 chars.

Score:

```
score is 2813, totalerr is 17539
```

Code:

```
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 '[encoded data, 10352 characters]'.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

```

# Answer
> 5 votes
# Perl, 1461 bytes, score=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, $/
  }
}

```

(Note, it's 1461 bytes after removing quite a bit of optional whitespace. As printed, it's a hundred or so heavier, but still well under 2000.)

I tried a bunch of more "subtle" approaches, but this one ended up beating them all. The two data strings are simply ranked lists of the characters most likely to follow each character, and the characters most likely to precede each character (with digraphs that don't occur in the wordlist not represented at all). `<` and `>` are used to represent the beginning and end of the word. As an example, `"w[aiehonrlsdtkfy]"` means that "wa" is more common than "wi" is more common than "we" etc. `%d`, the forward mapping, includes a global ranking, stored as `$d{''}`. It's used for places where there are two unknowns in a row, or where all the digraphs in the wordlist are exhausted (so we must be dealing with a non-wordlist word).

For every unknown position in the word, it looks at the preceding character, gives each possible following character a score, starting at 180 for the top-ranked, and decreasing to 80 at the end of the list; then the same thing is done for the following character. All the scores for all characters are added up, and the one with the highest score is selected.

After a letter is guessed, it's removed directly from the ranking tables, so it can't be guessed again (until we start a new word and re-initialize the tables).

**Update:** gained a bunch of points by fixing a bug (we weren't removing letters from the reverse table) and changing the way the points drop off as we go down the list.

# Answer
> 3 votes
# Python: 2046 bytes, score=1365

score is 1365, totalerr is 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\nDdObnZ+WEt+IGcQxc73QAcYSU6q+V2XPF3NxKnhHMb0Nwj2Tc2lcGR4XMGFxL3tjoRQVe5gBL/rA\nqHpaQZqizuyoMGv5MGfEx4Q6HNMhV/nTh0WF+js35a8RZHAGeqiyfTxY2kSW4yN40NK3wvTLkq7I\nk/4QVcJedkvanSsdBTPEnjEstrUs2FHyCO3Dj14HXeUNgmQS1wI4n9YhaT1egUmATRwABYwkd4tQ\ncCTWdqPiK5ssve67F1R6mUjznIMJJRZnv3/X8bXScmHZYiiTngWOIJCnHCjG+jZBv23gXsdOWpkX\n88IRd4FSMRW+CElyPYoEOMbes+IWG4Xo60PSaNrw6nZXjPMJPks+9lgHR41S+KutQOh6ViiiWdSL\nzI1etbyiz/3qJd8bK49tmakpe/F81vL0vUmUt7+tmDBtCtnCeG5v2cDy35IZTdtKpmQJh0yCdmmM\nWgAUcZ5crBA0nnY2bd32iySehf8Om0vHwPrMY78sPL97WZQKTtZDU0Mz64SRDYTJyo6B4qiojsog\nddZ9tH/vNKwtmUYVi0F4xFOtvFnFcNmSdBYZJenOacfqNc3mcJCJM+N34wUMG06oQmuOHH1BU+NU\nvXrSIc3asfhunl5kngmyCZ6pJ4lFN8CzTm33B24TVm06WoMVFoUcP7dfNaL/f3arAp6Ta0OSsgX8\nPuAsL8/5saVdRhS5hTlkG0nJhyal7kJXlrOATf5BG2j3xd4/EySk1aTElqLB3tOupqNr4aHd+wdq\nSNz0uhJA7iFkk1Gqp0mnG8k6gcyZq74XDbRp6ZxruSfLlx9Q1xZhHNq8pYgiti2AjHyItUme1fRO\n3S1l/EzGt/9b60aQ94vt8b/79vwoML/q15lP0sZlUDw3bQvGMJkjXfKtPT3Ny9VSYXix0E1dyf50\nYdbbJteynCo8esQcfqeUrTKklKQAuXSy3ndC+RMAvqVdXQH79Yxhee12LnBXr884xPqQtr8i1jvj\n4o4aWFNbZsxNPH2GWSX1IX1IwqlFDqILelFIesMRdwQEH2TqSdcq0yHWuxSpiakW5J6UJB2OJro3\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())

```

Much of the code borrows from nneonneo's python submission (without which I wouldn't have got this under the 2048 byte limit). Originally I thought this should score about 200 more, but I discovered an error in my data string creation tool. Now that's fixed my score is a much more reasonable 1365.

Rather than creating binary trees based on length, I created a single binary tree to hold the frequency information. The tree isn't uniform depth, as there's no point storing frequency information for anything deeper than six incorrect guesses (but the correct guesses could in theory be twelve deep for "considerably" and "uncomfortable"). This awkwardly shaped tree is navigated by the factorial code (actually using the combination function). In order to make the data string more compressable I padded all unused indexes with 's'.

I used a script to calculate good strings to store as d, and if someone can golf a few more characters out of the rest of the script, then here are some replacements that should result in better scores. The top row is the string encoded in the program above.

```
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

```

The script I used to generate the data strings is here, in case it's useful to anybody!

# Answer
> 1 votes
The  programming language is my tool of choice for this challenge.

Just shy of the 2,048 byte limit, although it is slightly golfed in some parts to get the byte count down, all the heavy lifting remains perfectly readable. This solver isn't very good at its job, and I expect it will be beaten easily, but this is just to get the ball rolling. Kick things off, so to speak.

**EDIT #1**: ~~As it has been pointed out, the original code is prone to dying a horrible death when it exhausts all the vowels. As it doesn't work properly, I've replaced it with a somewhat more brutish approach to random guessing.~~

**EDIT #2**: Original code has been fixed and now stands.

### Score:

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

### How it works

This solver is completely random. Even the randomness is random, fun times!

When the program receives input, it will guess one random character that it hasn't already guessed and send it to STDOUT.

The guessing algorithm works thusly:

1. Randomly select one of two character groups (consonants or vowels).
2. Randomly select one of two modes:
    * Use letter frequency as weight on the RNG. Higher frequency is more likely to be selected.
    * Pick a character at a random index, disregarding frequency.
3. Return a single character based on the mode selected in step 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 ];
}

```

---
Tags: code-challenge, game
---


title: Colors weave into a spire of flames

text:
# Question
Title: Colors weave into a spire of flames
https://www.youtube.com/watch?v=6vAhPeqlODg

Ok—jig's up—this one's only related to smash in name, but it'll give you something to burn your time with while you wait 'til December 7th

Given a color string `s` of form `#rgb`(in hex, so #000000 to #ffffff, dont worry about the three digit ones: ~~#123~~) you must average the rgb values, and turn it into a **flame** color(heyy see what I did there?)

to turn an average hex number `n`(0-255) to a "flame color" you must return a string `#rgb`with:

`r = n`

`g = n - 144`(the 144 is decimal, hex is 0x90) or if `n - 144` is \<0, then g = 0

`b = 0`

Given this is smash, we have to have items off. So no using arrays, maps, or sets(don't get into semantics about how strings are just abstracted arrays, I don't want to hear it)

1. Standard Loopholes are prohibited
2. Acceptable answers: a function which takes input through one input string and returns one output string
3. If the input string doesn't match the requirements provided above, your code MUST error out(doesn't matter what kind of Exception or Error)
4. This is code-golf, so the shortest(valid)answer (in each language) wins!
5. Bonus points for a one-liner (Not really tho, just cool points)

# Answer
# Perl 6, 108 bytes

```
{[$!=S/^\#(<[\d|A..F]>**2)**3$/{"#"~[~] ((sum("0x"X~$0)/3 X-0,144,255)Xmax 0)>>.fmt("%02x")}/,1/0][$! eq$_]}

```

Try it online!

Anonymous code block that takes a string and returns a string if it is in a valid format, or a div by zero error otherwise. Though I'm not really sure how you're defining `arrays`,`maps` or `sets`, since my code uses sequences (`Seq`) and `Match`s...
> 3 votes

# Answer
# Red, 96 bytes

```
func[s][c: hex-to-rgb do s n: c/1 + c/2 + c/3 / 3
to-hex/size n * 65536 +(256 * max 0 n - 144)6]

```

## Note:

It doesn't work in TIO (doesn't recognize `hex-to-rgb`\- maybe it is not implemented for Linux yet).

## Tests within the Red console:

(first 3 taken from Jo King - thanks!):

```
>> print f "#012345"
#230000
>> print f "#6789AB"
#890000
>> print f "#AA89AB"
#9F0F00
>> print f "code golf"
*** Script Error: code has no value
*** Where: do
*** Stack: f hex-to-rgb

```
> 1 votes

---
Tags: code-golf, restricted-source
---


title: Professor at MIT needs an AP!

text:
# Question
Title: Professor at MIT needs an AP!
The 5-card magic trick involves a magician whose assistant gives them 4 shown cards and a hidden one, in this order, and the magician must guess the hidden one.

# WARNING: Solution below! Leave now or get spoiled with it.

---

### The solution

The trick here is that the five cards are given *in a specific order*!

\\$c\_1,...,c\_5\\$ are the 5 cards in the given order.

\\$x\_n\\$ is the card number of \\$c\_n\\$ in \\$NO=\[\text{A,2,3,4,5,6,7,8,9,T,J,Q,K}\]\\$ (number order).

\\$a+b\\$, where \\$a\\$ is a card number and \\$b\\$ is an integer, is equal to the card number \\$b\\$ steps to the right of \\$a\\$ in \\$NO\\$, wrapping to the beginning if necessary.

\\$s\_n\\$ is the suit of \\$c\_n\\$ in \\$SO=\[\clubsuit,\diamondsuit,\heartsuit,\spadesuit\]\\$ (suit order).

\\$a\circ b\\$, where \\$a\\$ is a card number and \\$b\\$ is a suit, denotes the card with card number \\$a\\$ and suit \\$b\\$.

\\$a\<b\\$, where \\$a\\$ and \\$b\\$ are cards, is true if \\$a\\$'s suit is to the left of \\$b\\$'s suit in \\$SO\\$, or their suits are equal and \\$a\\$'s card number is to the left of \\$b\\$'s card number in \\$NO\\$.

\\$a\>b\\$, where \\$a\\$ and \\$b\\$ are cards, is true if \\$a\<b\\$ is false.

\\$PI(a,b,c)\\$, where \\$a\\$, \\$b\\$ and \\$c\\$ are cards, is the permutation index of this ordering of them, specified by the table below:
\\$\begin{array}{|c|c|}\hline\text{Comparison}&PI(a,b,c)\\\hline a\<b\<c&1\\\hline a\<b\>c\>a&2\\\hline a\>b\<c\>a&3\\\hline a\<b\>c\<a&4\\\hline a\>b\<c\<a&5\\\hline a\>b\>c&6\\\hline\end{array}\\$

The solution to the 5-card magic trick is problem is:$$c\_5=(x\_1+PI(c\_2,c\_3,c\_4))\circ s\_1$$

### The challenge

So far, so good. However, doing the computation specified above is already asked for here. Instead, your challenge is, given the 5 cards in no specific order, to order them properly. This means that the first four cards in the output will represent the fifth. In other words, be the assistant. Requirements:

* \\$s\_5=s\_1\\$.
* \\$x\_5=x\_1+PI(c\_2,c\_3,c\_4)\\$ (that is, this must be possible).

### Example

Let's consider the set `7H,2D,6D,5C,6C`. First of all, we take the 25 pairs:

```
7H,7H 7H,2D 7H,6D 7H,5C 7H,6C
2D,7H 2D,2D 2D,6D 2D,5C 2D,6C
6D,7H 6D,2D 6D,6D 6D,5C 6D,6C
5C,7H 5C,2D 5C,6D 5C,5C 5C,6C
6C,7H 6C,2D 6C,6D 6C,5C 6C,6C

```

Then, we obviously remove the 5 pairs that contain the same card twice, they don't exist in a single deck:

```
      7H,2D 7H,6D 7H,5C 7H,6C
2D,7H       2D,6D 2D,5C 2D,6C
6D,7H 6D,2D       6D,5C 6D,6C
5C,7H 5C,2D 5C,6D       5C,6C
6C,7H 6C,2D 6C,6D 6C,5C

```

Afterwards, since the suits must be the same, different suits in a pair is a no-no:

```

            2D,6D
      6D,2D
                        5C,6C
                  6C,5C
```

Finally, we check if it's possible to get from the first card to the second by adding at most 6, removing half of the remaining pairs:

```

            2D,6D

                        5C,6C

```

Now we have the valid pairs: `2D,6D` and `5C,6C`. The first card of each pair is card 1, while the last is card 5.

We're going to go with `5C,6C` here for easiness. The whole set is `7H,2D,6D,5C,6C`, so, removing the 2 cards in the pair we've chosen, we have `7H,2D,6D`. These cards will represent `6 - 5 = 1`, so we have to order them like "min, mid, max". `7H > 2D < 6D < 7H`, or simply `2D < 6D < 7H`, so we now have `2D,6D,7H`.

The last step is to put all of this together, so our result will be `5C,2D,6D,7H,6C`.

### Clarifications

* You may use `10` instead of `T`.
* You may use one of `♠♥♦♣`, `♤♡♢♧` or `♠♡♢♣` instead of `CDHS`, respectively.
* This is , the shortest code wins.

### Test cases

You can output one or more of the valid solutions included for each test case.

```
8S,TD,5C,QS,TS -> 8S,5C,QS,TD,TS
              ... 8S,TD,TS,5C,QS
              ... TS,5C,8S,TD,QS

JD,KH,4S,9D,8S -> 9D,KH,8S,4S,JD
              ... 4S,JD,KH,9D,8S

4H,4D,TH,KH,2C -> 4H,KH,4D,2C,TH
              ... TH,4D,2C,4H,KH
              ... KH,4D,TH,2C,4H

3S,KS,8S,KH,9H -> 9H,8S,KS,3S,KH
              ... 3S,KS,9H,KH,8S
              ... 8S,3S,9H,KH,KS
              ... KS,KH,9H,8S,3S

KH,TS,3C,7H,JD -> 7H,TS,JD,3C,KH

4C,KC,TD,JD,QS -> KC,JD,QS,TD,4C
              ... TD,4C,KC,QS,JD

AC,5H,8D,6D,8S -> 6D,AC,8S,5H,8D

AS,TC,3S,2H,9C -> 9C,2H,AS,3S,TC
              ... AS,9C,2H,TC,3S

4C,JS,AS,8H,JC -> JC,JS,AS,8H,4C
              ... JS,JC,4C,8H,AS

4H,QS,TH,QC,AC -> QC,4H,QS,TH,AC
              ... 4H,QS,QC,AC,TH

```

# Answer
> 3 votes
# Node.js, ~~190~~ ~~186~~ 180 bytes

```
f=(a,p,g=c=>"A23456789TJQK".search(c[0])+10,[A,B,C,D,E]=a.sort(_=>p>>i++&1,i=0))=>A[k=1]!=E[1]|[B,C,D].sort((a,b)=>k=k*2|a[1]+g(a)>b[1]+g(b))|(k^4)%6+1-(g(E)-g(A)+13)%13?f(a,-~p):a

```

Try it online!

## How?

### Identifying and comparing the card numbers

The helper function \\$g\\$ returns an index representing the number of a given card.

```
g = c => "A23456789TJQK".search(c[0]) + 10

```

We add \\$10\\$ to force two digits for all entries, so that these indices can be safely sorted in lexicographical order. Therefore an Ace is \\$10\\$ and a King is \\$22\\$.

Given 2 cards \\$a\\$ and \\$b\\$ in `"NS"` format, we can compare them by suit first and number second with:

```
a[1] + g(a) > b[1] + g(b)

```

### Generating the permutations of the input

We recursively try all \\$120\\$ possible permutations of the input array \\$a\\$ by successively sorting it with different permutation seeds \\$p\\$. The cards are separately loaded into \\$A\\$, \\$B\\$, \\$C\\$, \\$D\\$ and \\$E\\$.

```
[A, B, C, D, E] = a.sort(_ => p >> i++ & 1, i = 0)

```

This code shows when each permutation is first encountered. It takes \\$699\\$ iterations to try all of them.

### Testing the suits

The first obvious test is to make sure that the first and last cards are of the same suit. We reject the permutation if they're not equal.

```
A[k = 1] != E[1] // we also initialize k, which is used right after that

```

### Testing the distance

We compute the distance between the first card number and the last card number with:

```
(g(E) - g(A) + 13) % 13

```

Now comes the most tricky part. We have to test whether the order of the 3 other cards (\\$B\\$, \\$C\\$ and \\$D\\$) correctly describes this distance.

This test relies on the way the `sort()` algorithm of Node.js is working.

Assuming that the callback function of `sort()` is always returning a positive integer, Node.js will sort the array \\$\[A,B,C\]\\$ by applying these 3 steps:

1. compare \\$A\\$ with \\$B\\$
2. compare \\$A\\$ with \\$C\\$
3. compare \\$B\\$ with \\$C\\$

Let's consider the following code:

```
[1, 2, 3].sort((a, b) => k = k * 2 | (a > b), k = 1)

```

We have \\$A\<B\\$ (\\$1\<2\\$), \\$A\<C\\$ (\\$1\<3\\$) and \\$B\<C\\$ (\\$2\<3\\$). All comparisons processed in the callback function are falsy and \\$k\\$ is simply multiplied by \\$2^3\\$. So, we end up with \\$k=8\\$.

Now, if we do:

```
[3, 2, 1].sort((a, b) => k = k * 2 | (a > b), k = 1)

```

All comparisons are now thruthy, which generates the bitmask \\$k=15\\$.

Each permutation generates a unique bitmask, which is mapped to a unique distance:

```
 A, B, C | A>B | A>C | B>C | k  | distance
---------+-----+-----+-----+----+----------
 1, 2, 3 |  0  |  0  |  0  |  8 |    1
 1, 3, 2 |  0  |  0  |  1  |  9 |    2
 2, 1, 3 |  1  |  0  |  0  | 12 |    3
 2, 3, 1 |  0  |  1  |  1  | 11 |    4
 3, 1, 2 |  1  |  1  |  0  | 14 |    5
 3, 2, 1 |  1  |  1  |  1  | 15 |    6

```

Given \\$k\\$, we can convert it to the distance by doing:

$$d=((k\operatorname{xor}4)\bmod 6)+1$$

```
  k | xor 4 | mod 6 | +1
----+-------+-------+----
  8 |   12  |   0   |  1
  9 |   13  |   1   |  2
 12 |    8  |   2   |  3
 11 |   15  |   3   |  4
 14 |   10  |   4   |  5
 15 |   11  |   5   |  6

```

Putting everything together, we have the following test:

```
[B, C, D]
.sort((a, b) =>
  k = k * 2 | a[1] + g(a) > b[1] + g(b)
)
| (k ^ 4) % 6 + 1
- (g(E) - g(A) + 13) % 13

```

# Answer
> 1 votes
# Python 3,  ~~260 248~~  232 bytes

```
N="A23456789TJQK".find
D=lambda x,y="KC":(N(y[0])+~N(x[0]))%13+15*abs(ord(x[1])-ord(y[1]))
def f(l):a,e,b,c,d=[[x,y]+sorted({*l}-{x,y},key=D)for x in l for y in l if D(x,y)<6][0];print(a,*map(eval,"bbccddcdbdbcdcdbcb"[D(a,e)::6]),e)

```

Try it online!

*-12 bytes thanks to Eric the Outgolfer*
*-14 bytes by removing a list comprehension*

# Answer
> 1 votes
# Clean, ~~225~~ ~~220~~ 209 bytes

```
import StdEnv,Data.List
n=['A23456789TJQK':n]

```

#

```
filter(\[[x,s],b,c,d,e]#[p,q,r:_]=map snd(sort(zip2[(elemIndices a n,b)\\[a,b]<-[b,c,d]][1..]))
=[snd(span((<>)x)n)!!(p+if(p>q)0if(q<r)(q+r)q),s]==e)o permutations

```

Try it online!

As a composed function, `:: [[Char]] -> [[Char]]`, with some helpers.

**Expanded:**

```
n = ['A23456789TJQK': n] // infinitely repeating card number list

filter (...) o permutations // filter the permutations of the argument by ...
  \[[x, s], b, c, d, e] // deconstruct each permutation via pattern matching
    #[p, q, r: _] = ... // define p, q, r as ...
      map snd (...) // the second component of every element in ...
      sort (...) // the sorted list of ...
      zip2 ... [1..] // pairs of ... and the numbers 1, 2, 3, ..
      [... \\ [a, b] <- [b, c, d]] // ... for every pair of number a and house b in [b, c, d]
      (elemIndices a n, b) // pair of the value of that card number and the house
    = ... == e // check ... for equality against the last card
      [..., s] // ..., paired with house s
      snd (span ((<>) x) n) !! (...) // the card number ... places from x
      p + ... // this is kinda obvious
      if(p > q) 0 ... // if p is greater than q, zero, else ...
      if(q < r) (q + r) q // if q is less than r, q + r, else q

```

# Answer
> 1 votes
# Ruby, 175 bytes

```
->a{g=->j{j.tr('ATJQKCHS','1:;<=)_z').sum}
e=b=a.sort_by{|i|g[i]}
4.times{|i|(d=g[b[i+1]]-g[b[i]])<13&&(a=b[i,2];e=d)}
[a[e/7],*(b-a).permutation.to_a[e<7?e-1:12-e],a[e/7-1]]}

```

Try it online!

A lambda function taking an array of cards as strings

**Commented**

```
->a{g=->j{j.tr('ATJQKCHS','1:;<=)_z').sum}
#helper function converts card to integer, ATJQK to 1:;<= and CHS to )_z then sum ascii values

e=b=a.sort_by{|i|g[i]}
#sort according to g. we declare 2 variables here in order to avoid undefined variable error at pre-interpretation check stage.

4.times{|i|(d=g[b[i+1]]-g[b[i]])<13&&(a=b[i,2];e=d)}
#compare each pair of values. if in same suit, store the pair of cards to a
#and the value difference to e. Loop exits with the last suitable pair stored

[a[e/7],*(b-a).permutation.to_a[e<7?e-1:12-e],a[e/7-1]]}
#return array containing the two cards of the same suit in the correct order
#with the correct permutation of the remaining cards (b-a) in the middle

```

# Answer
> 1 votes
# Jelly, 41 bytes

```
ØD;“TJQK”¤io2)1¦€µUḊỤ3R¤œ¿+""Om4%13E
Œ!ÇƇ

```

A monadic Link accepting a list of lists of characters returning a list of all valid arrangements in the same format.

**Try it online!** (footer formats the result as a grid to avoid the implicit smashing print as performed by the Link's code when run as a full program)

Or see a test-suite.

I have a sneaking suspicion another approach will be much more terse. I shall have to revisit this challenge later!

...hmm, I had another poke around and got another 41 byter (test):

```
O¹*@<74$?€€29%⁽:0%⁴UµṪ_Ḣ%13Ḍ⁼Ụ3R¤œ¿Ɗ
Œ!ÇƇ

```

---
Tags: code-golf, card-games
---


title: Smallest Integer Disk

text:
# Question
Title: Smallest Integer Disk
This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers.

Your input will be a list of points with integer coordinates `x` and `y`. You can take this as a list of tuples, a list of lists, or any other way to represent a collection of pairs. `x` and `y` will both be (possibly negative) integers. Every point is guaranteed to be unique, and there will be at least one point.

Your output will be a disk in the form of three numbers, `X`, `Y`, and `R`. `X`, `Y`, and `R` are all integers, `X` and `Y` represent the disk's center and `R` represents its radius. The distance between every given point and the center must be less than or equal to `R`, and there must not exist such a disk with a smaller `R` that also satisfies this condition.

It is possible that there will be multiple possible solutions for a given input, your code must output at least one of them in this case.

You can use any kinds of geometry builtins your language supports if there are any, and input/output may be through built-in point/disk objects instead of just numbers.

## Test Cases

```
Input   (Possible) Output(s)
(x,y)   (X,Y,R)
-------------------------
(0,0)   (0,0,0)
-------------------------
(0,1)   (0,0,1)
(1,0)   (1,1,1)
-------------------------
(1,4)   (4,4,3)
(3,2)
(4,1)
(4,5)
(5,2)
(7,4)
-------------------------
(-1,0)  (0,0,2)
(2,0)   (1,0,2)
-------------------------
(-1,0)  (1,0,2)
(2,1)   (0,1,2)
-------------------------
(0,0)   (1,0,1)
(1,1)   (0,1,1)

```

Fewest bytes wins.

# Answer
# Jelly, ~~25~~ ~~24~~ ~~22~~ ~~21~~ ~~20~~ 18 bytes

```
«/r»/Œpµ³_²§½ṀĊ,)Ṃ

```

*Thanks to @EriktheOutgolfer for letting me know about `)`, saving 1 byte.*

*Thanks to @Dennis for saving 2 bytes.*

Try it online!

### Explanation

```
«/r»/Œpµ³_²§½ṀĊ,)Ṃ      Main link. Arg: points
                        e.g. [[1,4],[3,2],[3,1]]
«/                      Find minimums by coordinate
                        e.g. [1,1]
   »/                   Find maximums by coordinate
                        e.g. [3,4]
  r                     Inclusive ranges by coordinate
                        e.g. [[1,2,3],[1,2,3,4]]
     Œp                 Cartesian product of the x and y ranges
                        e.g. [[1,1],[1,2],[1,3],[1,4],...,[3,4]]
       µ                    Chain, arg: center
                            e.g. [1,3]
        ³                   Get the original points
                            e.g. [[1,4],[3,2],[3,1]]
         _                  Subtract the center from each
                            e.g. [[0,1],[2,-1],[2,-2]]
          ²                 Square each number
                            e.g. [[0,1],[4,1],[4,4]]
           §                Sum each sublist
                            e.g. [1,5,8]
            ½               Square root of each number
                            e.g. [1,2.24,2.83]
             Ṁ              Find the maximum
                            e.g. 2.83
              Ċ             Round up
                            e.g. 3
               ,            Pair with the center point
                            e.g. [3,[1,3]]
                )       Do the above for all points
                        e.g. [[3,[1,1]],[3,[1,2]],[3,[1,3]],...,[3,[3,4]]]
                 Ṃ      Find the lexicographically smallest pair
                        e.g. [3,[1,1]]

```
> 5 votes

# Answer
# Brachylog v2, 19 bytes

```
;Az{\-ᵐ~√ᵐ+}ᵐ≤ᵛ√;A≜

```

Try it online!

This program was easy to write – Brachylog's almost perfect for this sort of problem – but hard to golf. It wouldn't surprise me if there was a byte saving somewhere here, as few things I did seemed to have any effect (and it contains nested map instructions, normally a sign that you should be using member/findall, but I can't see a way to do it).

This is a function submission. Input is from the left argument to the function in the format `[[x,y],[x,y],…]`, output from the right argument in the form `[r,[[x,y]]]`. (If you want to try negative numbers in the input, note that Brachylog uses `_` for the minus sign, not `-`. This is confusing because the function → full program wrapper that Brachylog ships with, requested using the command-line argument `Z`, will present negative numbers in the *output* with a regular minus sign.)

## Explanation

```
;Az{\-ᵐ~√ᵐ+}ᵐ≤ᵛ√;A≜
;A                   Append something
  z                    to every element of the input
   {       }ᵐ        such that for each resulting element:
     -                 Subtracting
    \ ᵐ                  corresponding elements {of the (input, appended) element}
       ~√              and un-squarerooting
         ᵐ               {the result of} each {subtraction}
          +            and summing {the resulting square numbers}
             ≤       {lets us find} a number at least as large as
              ᵛ        every element {of the list of sums}
               √     which can be square-rooted;
                ;A   append the same list as initially to it.
                  ≜  Find the first integer solution to the above, lexicographically.

```

This is interesting in that we're asking Brachylog to find a value of certain properties (in this case, the radius of a disk centred at point `A` that fits all the input points), but hardly placing any requirements on it (all we require is that the radius is a number). However, Brachylog will internally calculate the radius in question symbolically rather than trying to use concrete numbers, so when the final  is reached, it accomplishes two things at once: first, it ensures that only integers are used for the coordinates of `A` and for the radius (forcing the squared radius to be a square number, and explaining the use of `≤ᵛ` to find a "maximum or greater"); second, it finds the smallest possible viable radius (as the radius comes first in the output).

One thing that isn't specified in the program at all is that all the points are measured against the same centre of a disk; as written, there are no constraints that we don't use a different centre for each point. However, the tiebreak order (which in this case is set by the third , and which as a structure constraint will be evaluated before the value constraint implied by ) wants `A` to be as short as possible (i.e. a single element, so we use the same centre each time; it tries a zero-length `A` first but that obviously doesn't work, so it tries a singleton list next). As a result, we end up getting a useful constraint (that we only have one disk) "for free".

This solution happens to generalise to any number of dimensions, with no changes to the source code; there are no assumptions here that things are two-dimensional. So if you happen to need the smallest integer sphere, you can have that too.
> 8 votes

# Answer
# Perl 6, 81 bytes

```
{min [X]([Z]($^p)>>.minmax).map:{$p.map({(@_ Z-$_)>>².sum**.5}).max.ceiling,$_}}

```

Try it online!

Takes a list of points as 2-element lists `((X1, Y1), (X2, Y2), ...)`. Returns a list `(R, (X, Y))`. Uses the same approach as Pietu1998's Jelly answer:

```
[X]([Z]($^p)>>.minmax)  # All possible centers within the bounding box
.map:{ ... }            # mapped to
$p.map({(@_ Z-$_)>>².sum**.5}).max  # maximum distance from any point
.ceiling                # rounded up,
,$_                     # paired with center.
min                     # Find minimum by distance.

```

The `minmax` method is useful here as it returns a `Range`. The Cartesian product of ranges directly yields all points with integer coordinates.
> 3 votes

# Answer
# 05AB1E, 26 bytes

```
øεWsàŸ}`âεUIεX-nOt}àîX‚}{н

```

Port of *@Pietu1998*'s Jelly answer.

Try it online or verify all test cases.

**Explanation:**

```
ø                    # Zip the (implicit) input, swapping the rows and column
                     #  i.e. [[1,4],[3,2],[3,1]] → [[1,3,3],[4,2,1]]
 ε    }              # Map each to:
  W                  #  Push the smallest value (without popping the list)
                     #   i.e. [[1,3,3],[4,2,1]] → [1,1]
   s                 #  Swap so the list is at the top of the stack again
    à                #  Pop the list and push the largest value
                     #   i.e. [[1,3,3],[4,2,1]] → [3,4]
     Ÿ               #  Take the inclusive range of the min and max
                     #   i.e. [[1,2,3],[1,2,3,4]]
`                    # After the map, push both lists separated to the stack
 â                   # And take the cartesian product of the two lists
                     #  i.e. [[1,2,3],[1,2,3,4]]
                     #   → [[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[2,4],[3,1],[3,2],[3,3],[3,4]]
  ε             }    # Map each pair to:
   U                 #  Pop and store the current value in variable `X`
    I                #  Push the input
     ε     }         #  Map each pair in the input to:
      X              #   Push variable `X`
       -             #   Subtract it from the current pair
                     #    i.e. [3,2] - [1,3] → [2,-1]
        n            #   Take the square of each
                     #    i.e. [2,-1] → [4,1]
         O           #   Sum the lists
                     #    i.e. [4,1] → 5
          t          #   Take the square-root of each
                     #    i.e. 5 → 2.23606797749979
            à        #  Pop the converted list, and push its largest value
                     #   i.e. [[3.0,2.23606797749979,2.0],[2.0,2.0,2.23606797749979],...,[2.0,2.0,3.0]]
                     #    → [3.0,2.23606797749979,...,3.0]
             î       #  Round it up
                     #   i.e. [3.0,2.23606797749979,...,3.0] → [3.0,3.0,3.0,4.0,4.0,3.0,3.0,4.0,4.0,3.0,3.0,3.0]
              X‚     #  Pair it with variable `X`
                     #   i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]]
                 {   # After the map, sort the list
                  н  # And take the first item (which is output implicitly)
                     #  i.e. [[3.0,[1,1]],[3.0,[1,2]],...,[3.0,[3,4]]] → [3.0,[1,1]]

```
> 2 votes

# Answer
# Matlab, 73 bytes

```
function g(x);[r,~,d]=fminimax(@(a)pdist2(x,a),[0 0]);[round(r) ceil(d)]

```

Simply find the smallest solution (floating point) and round to nearest point and ceil the radius (worst case for the minimax problem). I don't know for sure if that yields the correct solution for all possible cases (within the precision), but for the test cases it should work (if I didn't make a typing error).

Call it with

```
g([1 4;3 2;4 1;4 5;5 2;7 4])

```
> 2 votes

# Answer
# Java 10, ~~283~~ ~~279~~ ~~277~~ 257 bytes

```
C->{int M=1<<31,m=M,X=M,Y=M,x=M-1,y=x,t,a,b,r[]={x};for(var c:C){x=(t=c[0])<x?t:x;X=t>X?t:X;y=(t=c[1])<y?t:y;Y=t>Y?t:Y;}for(;y<=Y;y++)for(t=x;t<=X;r=m<r[0]?new int[]{m,t,y}:r,m=M,t++)for(var c:C){a=c[0]-t;b=c[1]-y;a*=a;m=(a=(int)Math.ceil(Math.sqrt(a+=b*=b)))>m?a:m;}return r;}

```

-20 bytes thanks to *@nwellnhof*'s tip of using `Math.hypot`.

The result-array is in the order `[R,X,Y]`.

Try it online.

**Explanation:**

```
C->{                  // Method with 2D int-array as parameter & int-array as return-type
  int M=1<<31,        //  Minimum `M`, starting at -2,147,483,648
      m=M,            //  Temp integer, starting at -2,147,483,648 as well
      X=M,            //  Largest X coordinate, starting at -2,147,483,648 as well
      Y=M,            //  Largest Y coordinate, starting at -2,147,483,648 as well
      x=M-1,          //  Smallest X coordinate, starting at 2,147,483,647
      y=x,            //  Smallest Y coordinate, starting at 2,147,483,647 as well
      t,a,            //  Temp integers, starting uninitialized
      r[]={x};        //  Result-array, starting at one 2,147,483,647
  for(var c:C){       //  Loop over the input-coordinates
    x=(t=c[0])<x?t:x; //   If the X coordinate is smaller than `x`, change it
    X=t>X?t:X;        //   If the X coordinate is larger than `X`, change it
    y=(t=c[1])<y?t:y; //   If the Y coordinate is smaller than `y`, change it
    Y=t>Y?t:Y;}       //   If the Y coordinate is larger than `Y`, change it
 for(;y<=Y;y++)       //  Loop `y` in the range [`y`,`Y`]:
   for(t=x;t<=X       //   Inner loop `t` in the range [`x`,`X`]:
          ;           //     After every iteration:
           r=m<r[0]?  //      If `m` is smaller than the first value:
              new int[]{m,t,y}
                      //       Replace the result with `m,t,y`
             :        //      Else:
              r,      //       Leave `r` unchanged
           m=M,       //      Reset `m` to -2,147,483,648 for the next iteration
           t++)       //      And increase `t` by 1
     for(var c:C)     //    Inner loop over the input-coordinates
       m=(a=(int)Math.ceil(Math.hypot(c[0]-t,c[1]-y)))
                      //     Subtract `t` from the X coordinate;
                      //     subtract `y` from the Y coordinate;
                      //     take the hypot (<- sqrt(x*x+y*y)) of those
                      //     ceil it
                      //     And set `a` to this value
          >m?         //     If `a` is larger than `m`:
           a          //      Set `m` to `a`
          :           //     Else:
           m;         //      Leave `m` unchanged
  return r;}          //  Return the result `r`

```
> 2 votes

# Answer
# Pyth, ~~34~~ 33 bytes

```
hSm+.EeSm@s^R2-Vdk2Qd*Fm}FhM_BSdC

```

Output is in the form `[R,x,y]`

Try it online here, or verify all the test cases at once here.

```
hSm+.EeSm@s^R2-Vdk2Qd*Fm}FhM_BSdCQ   Implicit: Q=eval(input())
                                     Trailing Q inferred
                                CQ   Transpose (group x and y coordinates separately)
                       m             Map each in the above, as d, using:
                              Sd       Sort d
                            _B         Pair with its own reverse
                          hM           Take the first element of each, yielding [min, max]
                        }F             Generate inclusive range
                     *F              Cartesian product of the above two lists, yielding all coordinates in range
  m                                  Map each coordinate in the above, as d, using:
        m          Q                   Map each coordinate in input, as k, using:
              -Vdk                       Take the difference between x and y coordinates in d and k
           ^R2                           Square each
          s                              Sum
         @        2                      Take the square root
      eS                               Take the largest of the result
    .E                                 Rounded up
   +                d                  Prepend to d
 S                                   Sort the result, first element as most significant
h                                    Take first element

```

*Edit: Saved a byte by rearranging output format, previous version:*

`heDm+d.EeSm@s^R2-Vdk2Q*Fm}FhM_BSdC`
> 2 votes

# Answer
# Wolfram Language (Mathematica), 66 bytes

Here's a brute force approach. I considered the much shorter `BoundingRegion[#,"MinDisk"]&` function but there is no way to force integer coordinates & radius.

```
Minimize[{r,RegionWithin[{x,y}~Disk~r,Point@#]},{x,y,r},Integers]&

```

Try it online!
> 2 votes

# Answer
# Javascript, 245 bytes

```
a=>{[b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);for(f=c;f<b;f++){for(g=e;g<d;g++){s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);n=n?n[2]>s?[f,g,s]:n:[f,g,s]}}return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]}

```

(Somewhat) more readable version:

```
a=>{
    [b,c,d,e]=a.reduce(([j,k,l,m],[h,i])=>[j>h?j:h,k<h?k:h,l>i?l:i,m<i?m:i],[,,,,]);
    for(f=c;f<b;f++){
        for(g=e;g<d;g++){
            s=a.reduce((o,[p,q])=>o>(r=(p-f)**2+(q-g)**2)?o:r);
            n=n?n[2]>s?[f,g,s]:n:[f,g,s]
        }
    }
    return [n[0],n[1],Math.ceil(Math.sqrt(n[2]))]
}

```

Just finds the bounding box, and tests each coordinate in that box for whether it's the best.

I could save 8 bytes with an approximate answer, by replacing:

`Math.ceil(Math.sqrt(n[2]))` with `~~(n[2]+1-1e-9)`
> 1 votes

# Answer
# Ruby, 113 bytes

```
->l{a=l.flatten;(z=*a.min..a.max).product(z).map{|x,y|[l.map{|u,v|(((x-u)**2+(y-v)**2)**0.5).ceil}.max,x,y]}.min}

```

Try it online!
> 1 votes

# Answer
# Charcoal, 65 bytes

```
≔Ｅθ§ι¹ζ≔Ｅθ§ι⁰ηＦ…·⌊η⌈ηＦ…·⌊ζ⌈ζ⊞υ⟦ικ⟧≔Ｅυ⌈ＥθΣＥιＸ⁻§λξν²ηＩ§υ⌕η⌊ηＩ⌈Ｘ⌊η·⁵

```

Try it online! Link is to verbose version of code. Explanation:

```
≔Ｅθ§ι¹ζ

```

Get the y-coordinates into `z`.

```
≔Ｅθ§ι⁰η

```

Get the x-coordinates into `h`.

```
Ｆ…·⌊η⌈ηＦ…·⌊ζ⌈ζ⊞υ⟦ικ⟧

```

Loop over the inclusive ranges from the minimums to the maximums of `h` and `z` generating the list of all potential disc centres.

```
≔Ｅυ⌈ＥθΣＥιＸ⁻§λξν²η

```

Loop over all the disc centres, then loop over all of the original points, then loop over both coordinates, subtract, square, sum, take the maximum, and save the resulting list.

```
Ｉ§υ⌕η⌊η

```

Find the position of the minimal maximum diameter and print the corresponding disc centre.

```
Ｉ⌈Ｘ⌊η·⁵

```

Print the minimal maximum diameter, but round it up to the next integer.
> 1 votes

---
Tags: code-golf, geometry
---