Created
January 3, 2018 19:04
-
-
Save Bort-777/3f98f6880560c6a5171408f2057cf509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract CalculateRace { | |
function test() returns (uint8[11] race) { | |
return _calculateRace([1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0]); | |
} | |
function _calculateRace(uint8[11] _momRace, uint8[11] _dadRace) internal returns (uint8[11] race) { | |
bool remainder = false; | |
for (uint8 i = 0; i < 11; i++) { | |
race[i] = (_momRace[i] + _dadRace[i]) / 2; | |
if ((_momRace[i] + _dadRace[i]) % 2 != 0 && remainder) { | |
race[i] += 1; | |
remainder = false; | |
} else if ((_momRace[i] + _dadRace[i]) % 2 != 0) { | |
remainder = true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment