How to resolve the algorithm Fairshare between two and more step by step in the Arturo programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Fairshare between two and more step by step in the Arturo programming language

Table of Contents

Problem Statement

The Thue-Morse sequence is a sequence of ones and zeros that if two people take turns in the given order, the first persons turn for every '0' in the sequence, the second for every '1'; then this is shown to give a fairer, more equitable sharing of resources. (Football penalty shoot-outs for example, might not favour the team that goes first as much if the penalty takers take turns according to the Thue-Morse sequence and took 2^n penalties) The Thue-Morse sequence of ones-and-zeroes can be generated by:

Use this method:

Counting from zero;   using a function/method/routine to express an integer count in base b, sum the digits modulo b to produce the next member of the Thue-Morse fairshare series for b people.

Show the first 25 terms of the fairshare sequence:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Fairshare between two and more step by step in the Arturo programming language

Source code in the arturo programming language

thueMorse: function [base, howmany][
    i: 0
    result: new []
    while [howmany > size result][
        'result ++ (sum digits.base:base i) % base
        i: i + 1
    ]

    return result
]

loop [2 3 5 11] 'b ->
    print [
        (pad.right "Base "++(to :string b) 7)++" =>" 
        join.with:" " map to [:string] thueMorse b 25 'x -> pad x 2
    ]


  

You may also check:How to resolve the algorithm Pseudo-random numbers/PCG32 step by step in the Scheme programming language
You may also check:How to resolve the algorithm Sum and product of an array step by step in the dc programming language
You may also check:How to resolve the algorithm Knapsack problem/Unbounded step by step in the Ruby programming language
You may also check:How to resolve the algorithm 24 game/Solve step by step in the Prolog programming language
You may also check:How to resolve the algorithm Letter frequency step by step in the Pascal programming language