Heros and Villains

BJ’s sister is remodeling his nephew’s room. It is a super hero themed. He has been getting into comic books and super heros ever since he met Spiderman. He’s asked us to build him a way to look up superheros and the villians they’ve fought and defeated.

The Challenge

In this challenge we’ll be searching and sorting lists of objects. We have a list of heros with their villians, the last time they fought, the number of times fought, and the number of wins.

Spiderman

Villian Last Fight Number Fights Number Wins
Venom 2007-5-4 100 89
Sandman 2017-6-14 90 90
Kingpin 2018-2-6 20 18
Hobgoblin 2018-6-6 222 189
Shocker 2013-11-20 76 63

DareDevil

Villian Last Fight Number Fights Number Wins
Bulls-eye 2017-8-24 200 189
Sandman 2017-6-14 90 90
Kingpin 2018-5-16 340 318
Red Skull 2016-12-26 12 9
Shocker 2014-10-2 32 30

Captain Marvel

Villian Last Fight Number Fights Number Wins
Bulls-eye 2017-8-24 200 189
Capt Nazi 2003-6-4 190 175
Black Adam 2018-7-24 246 238
Red Skull 2016-12-26 12 9
Hydra 2017-10-22 132 128

Captain America

Villian Last Fight Number Fights Number Wins
Kingpin 2017-2-14 147 139
Capt Nazi 2013-9-24 232 175
Black Adam 2015-4-12 246 238
Red Skull 1946-2-26 412 407
Hydra 2018-10-22 132 128

Superman

Villian Last Fight Number Fights Number Wins
Lex Luthor 2018-4-12 200 198
Doomsday 1992-11-15 1 0
Bane 2017-6-12 78 72
Killer Croc 2017-3-21 123 108
Ares 2015-5-30 89 78

Batman

Villian Last Fight Number Fights Number Wins
Lex Luthor 2017-8-26 27 18
Joker 2017-11-15 431 420
Bane 2018-11-22 248 244
Killer Croc 2016-7-29 113 108
Ares 2014-3-20 24 18

Wonderwoman

Villian Last Fight Number Fights Number Wins
Capt Cold 2017-3-26 127 110
Joker 2015-1-5 31 18
Bane 2013-11-12 48 24
Killer Croc 2017-2-9 13 8
Ares 2018-3-20 324 322

Flash

Villian Last Fight Number Fights Number Wins
Capt Cold 2018-3-6 17 11
Joker 2015-12-5 21 8
Bane 2016-10-9 158 124
Killer Croc 2007-12-9 143 138
Lex Luthor 2014-3-2 34 22

Your data may look something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[
'Superman': [
{
'name': 'Lex Luthor',
'lastFight': 2018-04-05,
'numberFights': 200,
'numberWins': 198
},
{
'name': 'Doomsday',
'lastFight': 1992-11-15,
'numberFights': 1,
'numberWins': 0
}
],
'Spiderman': [
{
'name': 'Venom',
'lastFight': 2007-05-04,
'numberFights': 100,
'numberWins': 89
}
]
]

Creating a Test Case

No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1

Starting off in level 1 we need to be able to tell if a hero has fought a villian. Have the user input the hero’s name and the villain and then let the user know if that hero has faced that villian.

A Step Further

Going a step further allow the user to enter a hero and then produce a list of the villians they have faced and order them by the most recent time they have fought.

Level 2

For level 2 we want to allow the user to enter a villian’s name and return a list of heros they have faced.

A Step Further

Going a step further order the list of heros by number of times the villian has fought the hero. Include the number of times the villian won.

Level 3

With the information provided if given a villian determine which hero is the most likely to win in a fight with that villian.

A Step Further

Going a step further, predict the chances of hero and villian winning when the user provides a hero and a villian.