3
2
Yes, I know there are already three pokemon type questions, but almost all submissions hardcode the whole chart in one way or other. I think it'd be nice to change the requirement a bit to encourage more shortcut-taking typically seen in decision problems.
Objective
Write a program/function/whatever that accepts the attacking type and the defending type(s), and output something that can be identified as the final multiplier.
As usual, you can see the pokemon type chart here. Also available as text form (copied from another question linked above and modified a bit):
Attacking Type
No Fi Fl Po Gr Ro Bu Gh St Fr Wa Gr El Ps Ic Dr Da Fa
Normal 1 2 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1
Fighting 1 1 2 1 1 0.5 0.5 1 1 1 1 1 1 2 1 1 0.5 2
D Flying 1 0.5 1 1 0 2 0.5 1 1 1 1 0.5 2 1 2 1 1 1
e Poison 1 0.5 1 0.5 2 1 0.5 1 1 1 1 0.5 1 2 1 1 1 0.5
f Ground 1 1 1 0.5 1 0.5 1 1 1 1 2 2 0 1 2 1 1 1
e Rock 0.5 2 0.5 0.5 2 1 1 1 2 0.5 2 2 1 1 1 1 1 1
n Bug 1 0.5 2 1 0.5 2 1 1 1 2 1 0.5 1 1 1 1 1 1
d Ghost 0 0 1 0.5 1 1 0.5 2 1 1 1 1 1 1 1 1 2 1
i Steel 0.5 2 0.5 0 2 0.5 0.5 1 0.5 2 1 0.5 1 0.5 0.5 0.5 1 0.5
n Fire 1 1 1 1 2 2 0.5 1 0.5 0.5 2 0.5 1 1 0.5 1 1 0.5
g Water 1 1 1 1 1 1 1 1 0.5 0.5 0.5 2 2 1 0.5 1 1 1
Grass 1 1 2 2 0.5 1 2 1 1 2 0.5 0.5 0.5 1 2 1 1 1
T Electric 1 1 0.5 1 2 1 1 1 0.5 1 1 1 0.5 1 1 1 1 1
y Psychic 1 0.5 1 1 1 1 2 2 1 1 1 1 1 0.5 1 1 2 1
p Ice 1 2 1 1 1 2 1 1 2 2 1 1 1 1 0.5 1 1 1
e Dragon 1 1 1 1 1 1 1 1 1 0.5 0.5 0.5 0.5 1 2 2 1 2
Dark 1 2 1 1 1 1 2 0.5 1 1 1 1 1 0 1 1 0.5 2
Fairy 1 0.5 1 2 1 1 0.5 1 2 1 1 1 1 1 1 0 0.5 1
You can choose to either accept one or two defending types (the final multiplier for two defending types is just the product of all individual defending types). Both types of submissions are allowed, as they will be in separate categories.
Rules
You can choose any methods of input in any form, structure or order (e.g ['fire',['water','rock']]
/['fire',['rock']]
/['fire','rock']
, 'water,ice,ghost'
/'water,ghost'
,dragondragonsteel
/dragondragon
).
The only requirement is that the types being inputted must be exactly their names and nothing else. Moreover, the types are required to be in one case only: so if you choose "psychic/Psychic/PSYCHIC", you must also use the same case for every other types (e.g "poison/Poison/POISON"). The available casing are: all lowercase, capital case and all uppercase.
You can output anything as long as different multipliers corresponds to one and only one output value.
There will not be two defensive types of the same type.
Standard loopholes are disallowed.
Shortest byte wins.
Can we use the two letter identifiers from the chart? – Jo King – 2018-07-09T09:17:48.663
I'm not sure if other aliases to the types should be allowed, because while I want the challenge to be liberal to allow creative solutions, allowing different identifiers seems to open too many possibilities (and potential loopholes too). – Voile – 2018-07-09T09:31:49.827
So, this is It's super effective! with more relaxed I/O formats. Is that correct? Or am I missing another difference? (I don't think this qualifies as
– Arnauld – 2018-07-09T09:55:17.620kolmogorov-complexity
, BTW.)@Arnauld Yes. People can still try hardcoding the whole matrix (even if it might not be the best approach anymore), so I decided to leave
kolmogorov-complexity
in ;-) – Voile – 2018-07-09T10:37:34.6402(and since there are more than 2 possible outputs, this is not a
decision-problem
either...) – Arnauld – 2018-07-09T13:04:20.497I really can't see any advantage to taking two defenders; we'd just have an 18 by 306 matrix with a domain of
{0, 0.25, 0.5, 1, 2, 4}
instead. – Jonathan Allan – 2018-07-09T21:18:59.927@Arnauld decision problems aren't limited to binary decision. That's like saying classifications are binary only. – Voile – 2018-07-10T01:56:20.550
Our tag is about decision problems in computability theory: a problem where a yes-or-no question is posed.
– Arnauld – 2018-07-10T05:56:37.387If anyone is interested: here is a minimal perfect hash function to convert the types in uppercase to [0..17] in Jelly.
– Arnauld – 2018-07-10T07:42:49.187@Arnauld okay. Removed
decision-problem
andkolmogorov-complexity
, addedclassification
. – Voile – 2018-07-10T08:15:04.190