Last active
May 14, 2020 20:06
-
-
Save asottile/35f6e2d3da7001536dfb0c8c69633313 to your computer and use it in GitHub Desktop.
figure out what shiny pokemon to do
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""figure out what shiny pokemon to do. | |
1. adjust SEEKING as needed | |
2. run this | |
""" | |
import collections | |
SEEKING = '''\ | |
Meowth | |
Ponyta | |
Weezing | |
Mr. Mime | |
Corsola | |
Darumaka | |
Yamask | |
Rookidee | |
Blipbug | |
Nickit | |
Gossifleur | |
Wooloo | |
Chewtle | |
Yamper | |
Rolycoly | |
Arrokuda | |
Sizzlipede | |
Hatenna | |
Impidimp | |
Milcery | |
Falinks | |
Pincurchin | |
Snom | |
Stonjourner | |
Eiscue | |
Indeedee-f | |
Indeedee-m | |
Morpeko | |
Cufant | |
Duraludon | |
''' | |
GMAX_S = '''\ | |
alcremie-gmax | |
appletun-gmax | |
butterfree-gmax | |
centiskorch-gmax | |
charizard-gmax | |
coalossal-gmax | |
copperajah-gmax | |
drednaw-gmax | |
duraludon-gmax | |
garbodor-gmax | |
gengar-gmax | |
grimmsnarl-gmax | |
hatterene-gmax | |
kingler-gmax | |
lapras-gmax | |
machamp-gmax | |
orbeetle-gmax | |
sandaconda-gmax | |
''' | |
GMAX = frozenset(GMAX_S.splitlines()) | |
DENS = { | |
('10C', 'sh'): {'clobbopus', 'falinks'}, | |
('10C', 'sw'): {"farfetch'd", 'clobbopus', 'falinks'}, | |
('11C', 'swsh'): {'meowth', 'cufant'}, | |
('13C', 'sh'): {'ponyta', 'indeedee-f', 'hatenna', 'blipbug'}, | |
('13C', 'sw'): {'indeedee-m', 'hatenna', 'blipbug'}, | |
('14C', 'sh'): {'mr. mime', 'indeedee-f'}, | |
('14C', 'sw'): {'indeedee-m', 'mr. mime'}, | |
('15C', 'swsh'): {'rolycoly'}, | |
('17C', 'swsh'): {'silicobra', 'yamask', 'stunfisk'}, | |
('18C', 'sh'): {'sizzlipede'}, | |
('18C', 'sw'): {'sizzlipede', 'darumaka'}, | |
('20C', 'sh'): {'sizzlipede'}, | |
('20C', 'sw'): {'sizzlipede', 'darumaka'}, | |
('22C', 'swsh'): {'mr. mime', 'snom'}, | |
('23C', 'sh'): {'mr. mime', 'eiscue', 'snom'}, | |
('23C', 'sw'): {'mr. mime', 'snom', 'darumaka'}, | |
('25C', 'swsh'): {'yamper', 'pincurchin', 'morpeko'}, | |
('27C', 'swsh'): {'applin', 'gossifleur'}, | |
('30C', 'swsh'): {'weezing'}, | |
('32C', 'swsh'): {'rookidee', 'cramorant'}, | |
('34C', 'swsh'): {'impidimp', 'milcery'}, | |
('36C', 'swsh'): {'impidimp', 'nickit', 'zigzagoon'}, | |
('38C', 'swsh'): {'dreepy', 'applin'}, | |
('40C', 'sh'): {'indeedee-f', 'wooloo', 'zigzagoon'}, | |
('40C', 'sw'): {'indeedee-m', 'wooloo', 'zigzagoon'}, | |
('41C', 'swsh'): {'arrokuda'}, | |
('42C', 'swsh'): {'chewtle'}, | |
('43R', 'sh'): {'corsola', 'yamask'}, | |
('43R', 'sw'): {'yamask'}, | |
('44R', 'swsh'): {'arrokuda', 'chewtle'}, | |
('46R', 'swsh'): {'blipbug'}, | |
('47R', 'sh'): {'corsola', 'yamask'}, | |
('47R', 'sw'): {'yamask'}, | |
('48R', 'swsh'): {'falinks'}, | |
('49R', 'swsh'): {'meowth', 'stunfisk'}, | |
('50R', 'swsh'): {'mr. mime', 'hatenna'}, | |
('51R', 'sh'): {'rolycoly'}, | |
('51R', 'sw'): {'rolycoly', 'stonjourner'}, | |
('52R', 'swsh'): {'yamask', 'stunfisk'}, | |
('53R', 'swsh'): {'sizzlipede'}, | |
('54R', 'swsh'): {'sizzlipede'}, | |
('55R', 'sh'): {'mr. mime', 'eiscue'}, | |
('55R', 'sw'): {'mr. mime', 'darumaka'}, | |
('56R', 'swsh'): {'yamper', 'pincurchin', 'morpeko'}, | |
('58R', 'swsh'): {'applin', 'gossifleur'}, | |
('59R', 'swsh'): {'gossifleur'}, | |
('5C', 'swsh'): {'blipbug'}, | |
('60R', 'swsh'): {'weezing'}, | |
('61R', 'swsh'): {'rookidee'}, | |
('62R', 'swsh'): {'impidimp'}, | |
('63R', 'swsh'): {'nickit', 'zigzagoon'}, | |
('64R', 'swsh'): {'dreepy', 'applin'}, | |
('65R', 'sh'): {'indeedee-f', 'wooloo'}, | |
('65R', 'sw'): {'indeedee-m', 'wooloo'}, | |
('67R', 'swsh'): {'arrokuda', 'chewtle'}, | |
('68R', 'swsh'): {'mr. mime', 'hatenna'}, | |
('69R', 'swsh'): {'nickit', 'zigzagoon'}, | |
('70R', 'swsh'): {'gossifleur'}, | |
('71R', 'swsh'): {'sizzlipede'}, | |
('72R', 'swsh'): {'yamper'}, | |
('73R', 'swsh'): {'mr. mime', 'snom'}, | |
('74R', 'swsh'): {'impidimp', 'milcery'}, | |
('77R', 'swsh'): {'charizard-gmax', 'sizzlipede'}, | |
('78R', 'swsh'): {'drednaw-gmax', 'arrokuda', 'chewtle'}, | |
('79R', 'sh'): {'applin', 'appletun-gmax', 'gossifleur'}, | |
('79R', 'sw'): {'flapple-gmax', 'applin', 'gossifleur'}, | |
('80R', 'swsh'): {'centiskorch-gmax', 'sizzlipede'}, | |
('81R', 'sh'): {'corsola', 'gengar-gmax', 'yamask'}, | |
('81R', 'sw'): {"farfetch'd", 'falinks', 'machamp-gmax'}, | |
('82R', 'sh'): {'ponyta', 'impidimp', 'alcremie-gmax'}, | |
('82R', 'sw'): {'impidimp', 'alcremie-gmax'}, | |
('83R', 'sh'): {'mr. mime', 'eiscue', 'lapras-gmax'}, | |
('83R', 'sw'): {'rolycoly', 'coalossal-gmax', 'stonjourner'}, | |
('84R', 'swsh'): {'duraludon-gmax'}, | |
('85R', 'swsh'): {'stunfisk', 'meowth', 'copperajah-gmax'}, | |
('86R', 'swsh'): {'weezing', 'garbodor-gmax'}, | |
('87R', 'swsh'): {'impidimp', 'hatterene-gmax', 'milcery'}, | |
('88R', 'swsh'): {'impidimp', 'nickit', 'zigzagoon', 'grimmsnarl-gmax'}, | |
('89R', 'swsh'): {'rookidee', 'corviknight-gmax'}, | |
('8C', 'swsh'): {'arrokuda', 'chewtle'}, | |
('90R', 'swsh'): {'butterfree-gmax', 'blipbug'}, | |
('91R', 'swsh'): {'arrokuda', 'chewtle', 'kingler-gmax'}, | |
('92R', 'swsh'): {'orbeetle-gmax', 'blipbug'}, | |
('93R', 'swsh'): {'yamask', 'sandaconda-gmax', 'stunfisk'}, | |
('9C', 'swsh'): {'chewtle'} | |
} | |
def main(): | |
dens = collections.defaultdict(set) | |
seeking_orig = {s.lower() for s in SEEKING.splitlines()} | |
seeking_orig.update(GMAX) | |
seeking_orig.difference_update(gmax[:-1 * len('-gmax')] for gmax in GMAX) | |
seeking = set(seeking_orig) | |
# only limit to pokemon we care about | |
dens = {k: v & seeking for k, v in DENS.items()} | |
# dedupe across games | |
for den, game in tuple(dens): | |
if (den, game) not in dens or game == 'swsh': | |
continue | |
other = {'sw': 'sh', 'sh': 'sw'}[game] | |
if dens[(den, other)] == dens[(den, game)]: | |
v = dens.pop((den, game)) | |
del dens[(den, other)] | |
dens[(den, 'swsh')] = v | |
dens_orig = dens | |
chosen = [] | |
for gmax in GMAX: | |
dens = {k: v & seeking for k, v in dens.items()} | |
k, v = max( | |
((k, v) for k, v in dens.items() if gmax in v), | |
key=lambda kv: len(kv[1]), | |
) | |
chosen.append((k, v)) | |
seeking -= v | |
dens = {k: v for k, v in dens.items() if gmax not in v} | |
while True: | |
dens = {k: v & seeking for k, v in dens.items()} | |
k, v = max(dens.items(), key=lambda kv: len(kv[1])) | |
dens.pop(k) | |
if not v: | |
break | |
else: | |
chosen.append((k, v)) | |
seeking -= v | |
seeking = set(seeking_orig) | |
dens = {k: dens_orig[k] for k, _ in chosen} | |
chosen = [] | |
while dens: | |
dens = {k: v & seeking for k, v in dens.items()} | |
k, v = max(dens.items(), key=lambda kv: len(kv[1])) | |
dens.pop(k) | |
if not v: | |
break | |
else: | |
chosen.append((k, v)) | |
seeking -= v | |
for (den, game), v in chosen: | |
print(f'{den} {game} ({len(v)})\t{", ".join(sorted(v))}') | |
print(f'missing: {", ".join(seeking)}') | |
if __name__ == '__main__': | |
exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment