2 votes

Topic deleted by author

2 comments

  1. [2]
    escher
    (edited )
    Link
    Honestly, I'd just use a series of arrays of pairs. First array, (in this example four elements each with a pair of contestants): [0] <contestant 1, contestant 2> [1] <contestant 3, contestant 4>...

    Honestly, I'd just use a series of arrays of pairs.

    First array, (in this example four elements each with a pair of contestants):

    [0] <contestant 1, contestant 2>
    [1] <contestant 3, contestant 4>
    [2] <contestant 5, contestant 6>
    [3] <contestant 7, contestant 8>
    

    After you've determined the winner of each pair, you build a new array with half the number of elements, each consisting of pairs of consecutive wins:

    [0] <winner of 1 vs 2, winner of 3 vs 4)>
    [1] <winner of 5 vs 6, winner of 7 vs 8)>
    

    So you can start with any size array (or list of whatever python uses) of pairs of contestants, and build new arrays of half the previous size all the way down to the final pair of contestants after each contest has been decided.

    This will also be far easier than trying to construct a tree structure (which is overkill in my opinion). Ultimately, programming comes down to managing complexity. When faced with a choice of being clever or being simple, be simple.

    3 votes
    1. [2]
      Comment deleted by author
      Link Parent
      1. escher
        Link Parent
        Fine, make the pairs objects to allow the addition of who won, and wrap the array-layer generation in an object as well for easy management!

        Fine, make the pairs objects to allow the addition of who won, and wrap the array-layer generation in an object as well for easy management!