Skip to content

CS50x Problem Set 5 - Inheritance allows inheriting both alleles from one parent #277

Open
@BallyCode

Description

@BallyCode

My initially incorrect code passed check50 with this:

        // TODO: Randomly assign current person's alleles based on the alleles of their parents
        aperson->alleles[0] = parent0->alleles[rand() % 2];
        aperson->alleles[1] = parent0->alleles[rand() % 2];

inheriting both alleles from parent0.

The second line should have been aperson->alleles[1] = parent1->alleles[rand() % 2];

I discovered the error when I noticed a person with an OO blood type had parents with OO and BB blood types in the printout of the family.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions