Your task is to calculate the expected chance of winning for 2 players in some game, each with their own ELO Rating. Player A has ELO Ra and player B has ELO Rb
The expected score for Player A (Ea) is: 1 / (1 + 10(Rb - Ra) / 400). There is a similar equation for Player B (Eb): 1 / (1 + 10(Ra - Rb) / 400).
If you want a more copiable version: 1 / (1 + 10^((a-b) / 400))
Ea + Eb should be equal to 1.
Therefore, the score for a player is their expected chance of winning some match, in decimal.
Your program/function should take 2 inputs, Player A's ELO, and Player B's ELO, and print/return their respective chance to win in decimal format. The output must add up to one, and you must be accurate to at least 5 decimal places (0.00000
). After 5 decimal places, you may have inaccurate digits, provided the two outputs still add up to one.
Examples:
1200 2100 -> 0.005591967 0.994408033
1 1 -> 0.5 0.5
60 20 -> 0.557312 0.442688
9999 9998 -> 0.501439 0.498561
9999 1 -> 0.999999 0.000001
In the final test case, some answers use scientific exponentiation to represent the value. This is not valid.
You can see in test case 3 here that 0.557312
is not quite accurate, because the 2
should be a 1
, but this is fine because it is after five decimal places and the outputs still add up to one.
This is an example of invalid output:
9999 9998 -> 0.5014391117091516, 0.49856088829084844
This looks like it satisfies the requirements at first glance, but the numbers add up to 1.00000000000000004
and therefore the output is not valid.
Trailing zeroes in the output is fine.
You may assume a player's ELO will always be greater than 0, and nobody will have an ELO higher than 9999.
The input and output format is flexible, but the input and output must still be in base 10.
As this is code-golf, the answer with the lowest byte count will win!
[9999, 998]
which most answers seem to fail for. \$\endgroup\$ – Emigna Feb 22 '17 at 7:429999, 1
including my own, so I can't post it :-( \$\endgroup\$ – Metoniem Feb 22 '17 at 8:50