Skip to content

Instantly share code, notes, and snippets.

@norus
Last active April 16, 2018 18:37
Show Gist options
  • Select an option

  • Save norus/02556fc6635a76ff12a8b2dc636750a5 to your computer and use it in GitHub Desktop.

Select an option

Save norus/02556fc6635a76ff12a8b2dc636750a5 to your computer and use it in GitHub Desktop.
Fifa album sticker intersect finder
#!/usr/bin/env python
import sys
if len(sys.argv) != 3:
print '''
(!) First argument should be diego_has.txt
(!) Second argument should be diego_needs.txt
Run like this:\n\tpython fifa.py diego_has.txt diego_needs.txt
'''
sys.exit(1)
# Davaj, davaj!
class Fifa2018:
def __init__(self):
# Cards that Marc can exchange
self.marc_has = [47, 93, 97, 122, 141, 157, 215, 285, 297, 323,
348, 377, 396, 436, 462, 501, 503, 505, 512, 537,
597, 598, 610, 618, 633]
# Cards that Marc needs
self.marc_needs = [2, 4, 5, 8, 9, 12, 15, 17, 18, 19, 20, 23, 25,
27, 28, 29, 30, 31, 33, 40, 49, 56, 62, 63, 65,
68, 77, 79, 80, 82, 87, 89, 90, 95, 96, 103, 104,
108, 113, 119, 132, 133, 134, 144, 145, 146, 149,
153, 154, 155, 159, 162, 163, 164, 167, 168, 169,
174, 175, 176, 181, 182, 191, 195, 196, 198, 205,
206, 207, 213, 223, 226, 227, 240, 246, 250, 251,
253, 259, 260, 264, 268, 270, 272, 276, 277, 278,
280, 283, 289, 290, 291, 294, 296, 301, 309, 310,
312, 315, 317, 322, 325, 329, 330, 331, 332, 335,
336, 340, 346, 355, 359, 360, 367, 368, 382, 384,
386, 391, 399, 401, 411, 425, 418, 431, 432, 451,
455, 458, 467, 468, 473, 484, 485, 488, 489, 490,
492, 497, 507, 518, 524, 527, 529, 530, 532, 533,
543, 545, 546, 549, 555, 559, 560, 562, 569, 578,
579, 581, 586, 588, 589, 592, 595, 612, 616, 621,
628, 630, 632, 636, 650, 659, 660, 661, 663, 664,
669, 676, 678, 679, 681]
# Cards that Diego can exchange
with open(sys.argv[1]) as f:
self.diego_has = [int(x) for x in next(f).split(',')]
# Cards that Diego needs
with open(sys.argv[2]) as f:
self.diego_needs = [int(x) for x in next(f).split(',')]
# Print what Marc has that Diego needs
def diego_luck(self):
diego_intersect = set(self.diego_needs).intersection(self.marc_has)
if diego_intersect:
return ':) Good news, Diego! Marc has these cards that you do not have: {}'.format(', '.join(str(x) for x in diego_intersect))
else:
return ':( Bad news, Diego... Looks like Marc doesn\'t have any cards that you need.'
# Print what Diego has that Marco needs
def marc_luck(self):
marc_intersect = set(self.marc_needs).intersection(self.diego_has)
if marc_intersect:
return ':) Good news, Marc! Diego has these cards that you do not have: {}'.format(', '.join(str(x) for x in marc_intersect))
else:
return ':( Bad news, Marc... Looks like Diego doesn\'t have any cards that you need.'
if __name__ == '__main__':
davaj = Fifa2018()
print davaj.diego_luck()
print davaj.marc_luck()
@norus
Copy link
Author

norus commented Apr 16, 2018

  1. Create a file called diego_has.txt with cards that Diego can exchange in the following format:
    1, 123, 45
  2. Create a file called diego_needs.txt with cards that Diego needs in the following format:
    1, 123, 45
  3. Save above Python script as fifa.py:
    wget https://gist.githubusercontent.com/norus/02556fc6635a76ff12a8b2dc636750a5/raw/ff829a561a503594427a41df641ec924f7c29239/fifa.py
  4. Run as follows:
    python fifa.py diego_has.txt diego_needs.txt

Sample output:

:) Good news, Diego! Marc has these cards that you do not have: 285
:) Good news, Marc! Diego has these cards that you do not have: 291, 451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment