How to resolve the algorithm Round-robin tournament schedule step by step in the ALGOL 68 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Round-robin tournament schedule step by step in the ALGOL 68 programming language

Table of Contents

Problem Statement

A round-robin tournament is also known as an all-play-all-tournament; each participant plays every other participant once. For N participants the number of rounds is N-1 if N is an even number. When there are an odd number of participants then each round one contestor has no opponent (AKA as a "bye"). The number of rounds is N in that case. Write a program that prints out a tournament schedule for 12 participants (represented by numbers 1 to 12).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Round-robin tournament schedule step by step in the ALGOL 68 programming language

Source code in the algol programming language

BEGIN # round-robin tournament schedule - translation of XPL0 #
    INT n = 12;            # number of players (must be even) #
    [ 1 : n ]INT player;
    FOR i TO n DO player[ i ] := i OD;
    FOR round TO n - 1 DO
        print( ( whole( round, 0 ), ":" ) );
        FOR i TO n OVER 2 DO
            print( ( REPR 9, whole( player[ i ], 0 ) ) )
        OD;
        print( ( newline ) );
        FOR i FROM n BY -1 TO ( n OVER 2 ) + 1 DO
            print( ( REPR 9, whole( player[ i ], 0 ) ) )
        OD;
        print( ( newline, newline ) );
        INT nth player   = player[ n ];
        player[ 3 : n ] := player[ 2 : n - 1 ];
        player[ 2     ] := nth player
    OD
END

  

You may also check:How to resolve the algorithm Repunit primes step by step in the Phix programming language
You may also check:How to resolve the algorithm Find common directory path step by step in the Swift programming language
You may also check:How to resolve the algorithm Vigenère cipher step by step in the Python programming language
You may also check:How to resolve the algorithm Deming's funnel step by step in the Haskell programming language
You may also check:How to resolve the algorithm Random sentence from book step by step in the Nim programming language