Do you know your blood type and Rh factor? I always forget mine. Somewhere I should have a vaccination record, but where? I forget as well, where I put it.
Is there a way to evaluate my blood type and Rh factor without a blood test? If you know the blood types and Rh factors of your parents, you can at least limit the blood type and Rh factor you may have, using following algorithm and you can compute the highest probability, because blood types and Rh factors are not equally distributed.
I started with a ABO blood type and Rh factor look-up table, transformed the tables into 2-dimensional char arrays and by studying the blood type distribution by country and the weighted mean, not only all possible blood types and Rh factors but also the ones with the maximum probability could be easily computed
// your input:
String father_bloodtype = "AB";
String mother_bloodtype = "AB";
String father_RHtype = "-/-";
String mother_RHtype = "-/-";
void setup() {
Serial.begin(9600);
char* bloodtypes[] = {"A", "B", "AB", "O"};
char* RHtypes[] = {"+/+", "+/-", "-/-"};
char* your_bloodtype[4][4] =
{
{"A, B", "A, B, AB, O", "A, B, AB", "A, O"},
{"A, B, AB, O", "B, O", "A, B, AB", "B, O"},
{"A, B, AB", "A, B, AB", "A, B, AB", "A, B"},
{"A, O", "B, O", "A, B", "O"}
};
char* your_bloodtype_prob[4][4] =
{
{"A", "O", "A", "O"},
{"O", "O", "A", "O"},
{"A", "A", "A", "A"},
{"O", "O", "A", "O"}
};
char* your_RHtype[3][3] =
{
{"+/+", "+/+, -/-", "+/-"},
{"+/+, -/-", "+/+, +/-, -/-", "+/-, -/-"},
{"+/-", "+/-, -/-", "-/-"}
};
char* your_RHtype_prob[3][3] =
{
{"+", "+", "+"},
{"+", "+", "+"},
{"+", "+", "-"}
};
byte father_row;
byte mother_col;
for(byte i = 0; i < 4; i ++) {
if(father_bloodtype.compareTo(bloodtypes[i]) == 0) father_row = i;
if(mother_bloodtype.compareTo(bloodtypes[i]) == 0) mother_col = i;
}
Serial.print("Possible blood types: ");
Serial.println(your_bloodtype[father_row][mother_col]);
Serial.print("Blood type with highest probability: ");
Serial.println(your_bloodtype_prob[father_row][mother_col]);
for(byte i = 0; i < 3; i ++) {
if(father_RHtype.compareTo(RHtypes[i]) == 0) father_row = i;
if(mother_RHtype.compareTo(RHtypes[i]) == 0) mother_col = i;
}
Serial.print("Possible Rh factors: ");
Serial.println(your_RHtype[father_row][mother_col]);
Serial.print("Rh factor with highest probability: ");
Serial.println(your_RHtype_prob[father_row][mother_col]);
}
void loop() {
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.