How to resolve the algorithm Fairshare between two and more step by step in the Draco programming language
How to resolve the algorithm Fairshare between two and more step by step in the Draco 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 Draco programming language
Source code in the draco programming language
proc fairshare(word n, base) word:
word result;
result := 0;
while n>0 do
result := result + n % base;
n := n / base
od;
result % base
corp
proc main() void:
[4]word bases = (2,3,5,11);
word b, n;
for b from 0 upto 3 do
write(bases[b]:2, ':');
for n from 0 upto 24 do
write(fairshare(n, bases[b]):3)
od;
writeln()
od
corp
You may also check:How to resolve the algorithm Menu step by step in the Scala programming language
You may also check:How to resolve the algorithm Reflection/Get source step by step in the zkl programming language
You may also check:How to resolve the algorithm Null object step by step in the 6502 Assembly programming language
You may also check:How to resolve the algorithm Find the missing permutation step by step in the 8080 Assembly programming language
You may also check:How to resolve the algorithm Sorting algorithms/Bubble sort step by step in the J programming language