This question is similar to this one. I have provided all of the information needed below. If you are familiar with the other challenge then note that we are ranking all defenses instead of seeing the effectiveness of a single attack. This is important because it means that the tables are inverses of each other and the goal of this challenge is to be without user input.
In Pokemon there are 18 types:
Normal Fighting Flying Poison Ground Rock Bug Ghost Steel Fire Water Grass Electric Psychic Ice Dragon Dark Fairy
Pokemon have either one or two unique types that define them (a "type combination"). For example, a Bulbasaur has the type combination Grass/Poison (it has two types, Grass and Poison) and a Charmander has the type combination Fire (having just one type). The order of types does not matter (i.e. Grass/Poison is the same as Poison/Grass).
These types all have strengths and weaknesses:
- A type can be weak to another type. Fire is weak against Water. This results in Fire having a 2× multiplier against Water.
- A type can be resistant to another type. Water is resistant to Water. This results in Water having a 0.5× multiplier against Water.
- A type can be immune to another type. Flying is immune to Ground. This results in Flying having a 0× multiplier against Ground.
Anything else receives a standard 1× multiplier. Normal against Normal would result in a 1× multiplier is an example of this. These strengths and weaknesses can be compounded or negated as well. For example, Fire is weak to Water but a Fire/Water dual type would have a 1× multiplier against Water since the weakness from Fire would negate the resistance from Water. For a full table and a further explanation, see below.
The goal here is to output a list of all types combinations, sorted in the order of their defensive ability, and listing their numbers of (resistances+immunities), weaknesses, and the ratio between those. Specifically, the sort order is as follows: type combinations with the best ratio of (resistances+immunities) to weaknesses are listed first, and if there is a tie, type combinations with the most resistances and immunities will win the tiebreak. You can produce this list via any means (an obvious method is to do a type effectiveness calculation against each type combination, but you are allowed to store precalculated or partially precalculated output in your program if doing so would make it shorter.)
Type effectiveness table
For a human readable table, see the Pokemon database. Note: the columns of this list are what we are considering. But just in case, here is the table I'm thinking of in a compressed computer-friendly matrix of effectiveness. I've multiplied every value by 2 so we don't have to deal with pesky decimals:
Attacking type (same order) Nor 222222422222202222 Fir 214211224221422211 D Wat 211441222222222212 e Ele 222122224122222212 f Gra 241114241424222222 e Ice 242221422222422242 n Fig 222222222441122124 d Poi 222212114241222221 i Gro 224044212222122222 n Fly 222414120221422222 g Psy 222222122214242422 Bug 242212121422422222 T Roc 114242414122222242 y Gho 022222012221242422 p Dra 211114222222224224 e Dar 222222422204212124 Ste 142211404111121211 Fai 222222142221220142
If this problem had requested only output for single-type type combinations, then a valid output would look like this:
Steel -> 11/3 = 3.66 Electric -> 3/1 = 3 Poison -> 5/2 = 2.5 Fire -> 6/3 = 2 Water -> 4/2 = 2 Ghost -> 4/2 = 2 Fairy -> 4/2 = 2 Fly -> 4/3 = 1.333 Dragon -> 4/3 = 1.333 Fighting -> 3/3 = 1 Normal -> 1/1 = 1 Ground -> 3/3 = 1 Psychic -> 2/2 = 1 Bug -> 3/3 = 1 Dark -> 3/3 = 1 Grass -> 4/5 = 0.8 Rock -> 4/5 = 0.8 Ice -> 1/4 = 0.25
However, your program will also need to list all of the dual-type combinations in the output, so its output will be considerably longer.
Best of luck! Shortest code in bytes wins.